diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-02-21 20:24:38 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-02-21 20:24:38 -0800 |
commit | 64c63ffe2cddf9123788c4e6e9693bd704c411af (patch) | |
tree | 8dfc00ee2e6b3acaa1fecfd01e78d5060f99b3bc /src/DotNetOpenAuth.OAuth2/OAuth2 | |
parent | 56e0f9d8803222246b355c139c76c9480abee5c0 (diff) | |
download | DotNetOpenAuth-64c63ffe2cddf9123788c4e6e9693bd704c411af.zip DotNetOpenAuth-64c63ffe2cddf9123788c4e6e9693bd704c411af.tar.gz DotNetOpenAuth-64c63ffe2cddf9123788c4e6e9693bd704c411af.tar.bz2 |
Split up end user authorization request message types between auth code and implicit.
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2/OAuth2')
3 files changed, 77 insertions, 17 deletions
diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ChannelBase.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ChannelBase.cs index 06b3eec..117d526 100644 --- a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ChannelBase.cs +++ b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ChannelBase.cs @@ -28,6 +28,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { typeof(AccessTokenSuccessResponse), typeof(AccessTokenFailedResponse), typeof(EndUserAuthorizationRequest), + typeof(EndUserAuthorizationImplicitRequest), typeof(EndUserAuthorizationSuccessAuthCodeResponse), typeof(EndUserAuthorizationSuccessAccessTokenResponse), typeof(EndUserAuthorizationFailedResponse), diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/Messages/EndUserAuthorizationImplicitRequest.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/Messages/EndUserAuthorizationImplicitRequest.cs new file mode 100644 index 0000000..71a243e --- /dev/null +++ b/src/DotNetOpenAuth.OAuth2/OAuth2/Messages/EndUserAuthorizationImplicitRequest.cs @@ -0,0 +1,63 @@ +//----------------------------------------------------------------------- +// <copyright file="EndUserAuthorizationImplicitRequest.cs" company="Outercurve Foundation"> +// Copyright (c) Outercurve Foundation. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.OAuth2.Messages { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OAuth2.ChannelElements; + + /// <summary> + /// A message sent by a web application Client to the AuthorizationServer + /// via the user agent to obtain authorization from the user and prepare + /// to issue an access token to the client if permission is granted. + /// </summary> + [Serializable] + public class EndUserAuthorizationImplicitRequest : EndUserAuthorizationRequest, IAccessTokenRequest { + /// <summary> + /// Gets or sets the grant type that the client expects of the authorization server. + /// </summary> + /// <value>Always <see cref="EndUserAuthorizationResponseType.Token"/>. Other response types are not supported.</value> + [MessagePart(Protocol.response_type, IsRequired = true, Encoder = typeof(EndUserAuthorizationResponseTypeEncoder))] + private const EndUserAuthorizationResponseType ResponseTypeConst = EndUserAuthorizationResponseType.AccessToken; + + /// <summary> + /// Initializes a new instance of the <see cref="EndUserAuthorizationImplicitRequest"/> class. + /// </summary> + /// <param name="authorizationEndpoint">The Authorization Server's user authorization URL to direct the user to.</param> + /// <param name="version">The protocol version.</param> + internal EndUserAuthorizationImplicitRequest(Uri authorizationEndpoint, Version version) + : base(authorizationEndpoint, version) { + } + + /// <summary> + /// Initializes a new instance of the <see cref="EndUserAuthorizationImplicitRequest"/> class. + /// </summary> + /// <param name="authorizationServer">The authorization server.</param> + internal EndUserAuthorizationImplicitRequest(AuthorizationServerDescription authorizationServer) + : this(authorizationServer.AuthorizationEndpoint, authorizationServer.Version) { + } + + /// <summary> + /// Gets the grant type that the client expects of the authorization server. + /// </summary> + public override EndUserAuthorizationResponseType ResponseType { + get { return ResponseTypeConst; } + } + + /// <summary> + /// Gets a value indicating whether the client requesting the access token has authenticated itself. + /// </summary> + /// <value> + /// Always false because authorization requests only include the client_id, without a secret. + /// </value> + bool IAccessTokenRequest.ClientAuthenticated { + get { return false; } + } + } +} diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/Messages/EndUserAuthorizationRequest.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/Messages/EndUserAuthorizationRequest.cs index 438873b..45fa049 100644 --- a/src/DotNetOpenAuth.OAuth2/OAuth2/Messages/EndUserAuthorizationRequest.cs +++ b/src/DotNetOpenAuth.OAuth2/OAuth2/Messages/EndUserAuthorizationRequest.cs @@ -16,10 +16,17 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// <summary> /// A message sent by a web application Client to the AuthorizationServer /// via the user agent to obtain authorization from the user and prepare - /// to issue an access token to the Consumer if permission is granted. + /// to issue an access token to the client if permission is granted. /// </summary> [Serializable] - public class EndUserAuthorizationRequest : MessageBase, IAccessTokenRequest { + public class EndUserAuthorizationRequest : MessageBase { + /// <summary> + /// Gets the grant type that the client expects of the authorization server. + /// </summary> + /// <value>Always <see cref="EndUserAuthorizationResponseType.AuthorizationCode"/>. Other response types are not supported.</value> + [MessagePart(Protocol.response_type, IsRequired = true, Encoder = typeof(EndUserAuthorizationResponseTypeEncoder))] + private const EndUserAuthorizationResponseType ResponseTypeConst = EndUserAuthorizationResponseType.AuthorizationCode; + /// <summary> /// Initializes a new instance of the <see cref="EndUserAuthorizationRequest"/> class. /// </summary> @@ -31,7 +38,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { Requires.NotNull(version, "version"); this.HttpMethods = HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.PostRequest; this.Scope = new HashSet<string>(OAuthUtilities.ScopeStringComparer); - this.ResponseType = EndUserAuthorizationResponseType.AuthorizationCode; } /// <summary> @@ -46,11 +52,11 @@ namespace DotNetOpenAuth.OAuth2.Messages { } /// <summary> - /// Gets or sets the grant type that the client expects of the authorization server. + /// Gets the grant type that the client expects of the authorization server. /// </summary> - /// <value>Always <see cref="EndUserAuthorizationResponseType.AuthorizationCode"/>. Other response types are not supported.</value> - [MessagePart(Protocol.response_type, IsRequired = true, Encoder = typeof(EndUserAuthorizationResponseTypeEncoder))] - public EndUserAuthorizationResponseType ResponseType { get; set; } + public virtual EndUserAuthorizationResponseType ResponseType { + get { return ResponseTypeConst; } + } /// <summary> /// Gets or sets the identifier by which this client is known to the Authorization Server. @@ -59,16 +65,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { public string ClientIdentifier { get; set; } /// <summary> - /// Gets a value indicating whether the client requesting the access token has authenticated itself. - /// </summary> - /// <value> - /// Always false because authorization requests only include the client_id, without a secret. - /// </value> - bool IAccessTokenRequest.ClientAuthenticated { - get { return false; } - } - - /// <summary> /// Gets or sets the callback URL. /// </summary> /// <value> |