summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.sln1
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuth.csproj4
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationApprovedResponse.cs48
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationDeclinedResponse.cs34
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationRequest.cs57
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/OAuth/Constants.cs22
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/StandardOpenIdExtensionFactory.cs4
7 files changed, 170 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.sln b/src/DotNetOpenAuth.sln
index f49cd4d..87c3d3f 100644
--- a/src/DotNetOpenAuth.sln
+++ b/src/DotNetOpenAuth.sln
@@ -17,6 +17,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Specs", "Specs", "{CD57219F-24F4-4136-8741-6063D0D7A031}"
ProjectSection(SolutionItems) = preProject
..\doc\specs\OAuth Core 1.0.htm = ..\doc\specs\OAuth Core 1.0.htm
+ ..\doc\specs\OpenID OAuth Extension.htm = ..\doc\specs\OpenID OAuth Extension.htm
..\doc\specs\openid-attribute-exchange-1_0.html = ..\doc\specs\openid-attribute-exchange-1_0.html
..\doc\specs\openid-authentication-1_1.html = ..\doc\specs\openid-authentication-1_1.html
..\doc\specs\openid-authentication-2_0.html = ..\doc\specs\openid-authentication-2_0.html
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
index 5c13092..22fb28d 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
@@ -329,6 +329,10 @@
<Compile Include="OpenId\Extensions\ExtensionBase.cs" />
<Compile Include="OpenId\Extensions\ExtensionArgumentsManager.cs" />
<Compile Include="OpenId\Extensions\IClientScriptExtensionResponse.cs" />
+ <Compile Include="OpenId\Extensions\OAuth\AuthorizationRequest.cs" />
+ <Compile Include="OpenId\Extensions\OAuth\AuthorizationApprovedResponse.cs" />
+ <Compile Include="OpenId\Extensions\OAuth\Constants.cs" />
+ <Compile Include="OpenId\Extensions\OAuth\AuthorizationDeclinedResponse.cs" />
<Compile Include="OpenId\Extensions\OpenIdExtensionFactoryAggregator.cs" />
<Compile Include="OpenId\Extensions\StandardOpenIdExtensionFactory.cs" />
<Compile Include="OpenId\Extensions\ProviderAuthenticationPolicy\AuthenticationPolicies.cs" />
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationApprovedResponse.cs b/src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationApprovedResponse.cs
new file mode 100644
index 0000000..5e7bc49
--- /dev/null
+++ b/src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationApprovedResponse.cs
@@ -0,0 +1,48 @@
+//-----------------------------------------------------------------------
+// <copyright file="AuthorizationApprovedResponse.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.OpenId.Extensions.OAuth {
+ using System;
+ using DotNetOpenAuth.Messaging;
+
+ /// <summary>
+ /// The OAuth response that a Provider may include with a positive
+ /// OpenID identity assertion with an approved request token.
+ /// </summary>
+ [Serializable]
+ public class AuthorizationApprovedResponse : ExtensionBase {
+ /// <summary>
+ /// The factory method that may be used in deserialization of this message.
+ /// </summary>
+ internal static readonly StandardOpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage, isProviderRole) => {
+ if (typeUri == Constants.TypeUri && !isProviderRole && data.ContainsKey(Constants.RequestTokenParameter)) {
+ return new AuthorizationApprovedResponse();
+ }
+
+ return null;
+ };
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AuthorizationApprovedResponse"/> class.
+ /// </summary>
+ public AuthorizationApprovedResponse()
+ : base(new Version(1, 0), Constants.TypeUri, null) {
+ }
+
+ /// <summary>
+ /// Gets or sets the user-approved request token.
+ /// </summary>
+ /// <value>The request token.</value>
+ [MessagePart(Constants.RequestTokenParameter, IsRequired = true, AllowEmpty = false)]
+ public string RequestToken { get; set; }
+
+ /// <summary>
+ /// Gets or sets a string that encodes, in a way possibly specific to the Combined Provider, one or more scopes that the returned request token is valid for. This will typically indicate a subset of the scopes requested in Section 8.
+ /// </summary>
+ [MessagePart("scope", IsRequired = false, AllowEmpty = true)]
+ public string Scope { get; set; }
+ }
+}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationDeclinedResponse.cs b/src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationDeclinedResponse.cs
new file mode 100644
index 0000000..7c3a5ad
--- /dev/null
+++ b/src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationDeclinedResponse.cs
@@ -0,0 +1,34 @@
+//-----------------------------------------------------------------------
+// <copyright file="AuthorizationDeclinedResponse.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.OpenId.Extensions.OAuth {
+ using System;
+
+ /// <summary>
+ /// The OAuth response that a Provider should include with a positive
+ /// OpenID identity assertion when OAuth authorization was declined.
+ /// </summary>
+ [Serializable]
+ public class AuthorizationDeclinedResponse : ExtensionBase {
+ /// <summary>
+ /// The factory method that may be used in deserialization of this message.
+ /// </summary>
+ internal static readonly StandardOpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage, isProviderRole) => {
+ if (typeUri == Constants.TypeUri && !isProviderRole && !data.ContainsKey(Constants.RequestTokenParameter)) {
+ return new AuthorizationDeclinedResponse();
+ }
+
+ return null;
+ };
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AuthorizationDeclinedResponse"/> class.
+ /// </summary>
+ public AuthorizationDeclinedResponse()
+ : base(new Version(1, 0), Constants.TypeUri, null) {
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationRequest.cs b/src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationRequest.cs
new file mode 100644
index 0000000..99f0880
--- /dev/null
+++ b/src/DotNetOpenAuth/OpenId/Extensions/OAuth/AuthorizationRequest.cs
@@ -0,0 +1,57 @@
+//-----------------------------------------------------------------------
+// <copyright file="AuthorizationRequest.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.OpenId.Extensions.OAuth {
+ using System;
+ using DotNetOpenAuth.Messaging;
+
+ /// <summary>
+ /// An extension to include with an authentication request in order to also
+ /// obtain authorization to access user data at the combined OpenID Provider
+ /// and Service Provider.
+ /// </summary>
+ /// <remarks>
+ /// <para>When requesting OpenID Authentication via the protocol mode "checkid_setup"
+ /// or "checkid_immediate", this extension can be used to request that the end
+ /// user authorize an OAuth access token at the same time as an OpenID
+ /// authentication. This is done by sending the following parameters as part
+ /// of the OpenID request. (Note that the use of "oauth" as part of the parameter
+ /// names here and in subsequent sections is just an example. See Section 5 for details.)</para>
+ /// <para>See section 8.</para>
+ /// </remarks>
+ [Serializable]
+ public class AuthorizationRequest : ExtensionBase {
+ /// <summary>
+ /// The factory method that may be used in deserialization of this message.
+ /// </summary>
+ internal static readonly StandardOpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage, isProviderRole) => {
+ if (typeUri == Constants.TypeUri && isProviderRole) {
+ return new AuthorizationRequest();
+ }
+
+ return null;
+ };
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AuthorizationRequest"/> class.
+ /// </summary>
+ public AuthorizationRequest()
+ : base(new Version(1, 0), Constants.TypeUri, null) {
+ }
+
+ /// <summary>
+ /// Gets or sets the consumer key agreed upon between the Consumer and Service Provider.
+ /// </summary>
+ [MessagePart("consumer", IsRequired = true, AllowEmpty = false)]
+ public string Consumer { get; set; }
+
+ /// <summary>
+ /// Gets or sets a string that encodes, in a way possibly specific to the Combined Provider, one or more scopes for the OAuth token expected in the authentication response.
+ /// </summary>
+ [MessagePart("scope", IsRequired = false)]
+ public string Scope { get; set; }
+ }
+}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/OAuth/Constants.cs b/src/DotNetOpenAuth/OpenId/Extensions/OAuth/Constants.cs
new file mode 100644
index 0000000..32efee9
--- /dev/null
+++ b/src/DotNetOpenAuth/OpenId/Extensions/OAuth/Constants.cs
@@ -0,0 +1,22 @@
+//-----------------------------------------------------------------------
+// <copyright file="Constants.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.OpenId.Extensions.OAuth {
+ /// <summary>
+ /// Constants used in the OpenID OAuth extension.
+ /// </summary>
+ internal static class Constants {
+ /// <summary>
+ /// The TypeURI for the OpenID OAuth extension.
+ /// </summary>
+ internal const string TypeUri = "http://specs.openid.net/extensions/oauth/1.0";
+
+ /// <summary>
+ /// The name of the parameter that carries the request token in the response.
+ /// </summary>
+ internal const string RequestTokenParameter = "request_token";
+ }
+}
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/StandardOpenIdExtensionFactory.cs b/src/DotNetOpenAuth/OpenId/Extensions/StandardOpenIdExtensionFactory.cs
index 9dda6ad..a669672 100644
--- a/src/DotNetOpenAuth/OpenId/Extensions/StandardOpenIdExtensionFactory.cs
+++ b/src/DotNetOpenAuth/OpenId/Extensions/StandardOpenIdExtensionFactory.cs
@@ -9,6 +9,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId.ChannelElements;
using DotNetOpenAuth.OpenId.Extensions.AttributeExchange;
+ using DotNetOpenAuth.OpenId.Extensions.OAuth;
using DotNetOpenAuth.OpenId.Extensions.ProviderAuthenticationPolicy;
using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;
using DotNetOpenAuth.OpenId.Messages;
@@ -35,6 +36,9 @@ namespace DotNetOpenAuth.OpenId.Extensions {
this.RegisterExtension(StoreResponse.Factory);
this.RegisterExtension(PolicyRequest.Factory);
this.RegisterExtension(PolicyResponse.Factory);
+ this.RegisterExtension(AuthorizationRequest.Factory);
+ this.RegisterExtension(AuthorizationApprovedResponse.Factory);
+ this.RegisterExtension(AuthorizationDeclinedResponse.Factory);
}
/// <summary>