summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/OAuth2/ChannelElements/UriStyleMessageFormatter.cs3
-rw-r--r--src/DotNetOpenAuth/OAuth2/ResourceServer.cs7
-rw-r--r--src/DotNetOpenAuth/OAuth2/UserAgentClient.cs1
-rw-r--r--src/DotNetOpenAuth/OAuth2/WebServerClient.cs23
4 files changed, 15 insertions, 19 deletions
diff --git a/src/DotNetOpenAuth/OAuth2/ChannelElements/UriStyleMessageFormatter.cs b/src/DotNetOpenAuth/OAuth2/ChannelElements/UriStyleMessageFormatter.cs
index cf1b522..2232b6c 100644
--- a/src/DotNetOpenAuth/OAuth2/ChannelElements/UriStyleMessageFormatter.cs
+++ b/src/DotNetOpenAuth/OAuth2/ChannelElements/UriStyleMessageFormatter.cs
@@ -171,8 +171,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
}
public T Deserialize(IProtocolMessage containingMessage, string value) {
- var message = new T();
- message.ContainingMessage = containingMessage;
+ var message = new T { ContainingMessage = containingMessage };
byte[] data = Convert.FromBase64String(value);
if (this.encrypted) {
diff --git a/src/DotNetOpenAuth/OAuth2/ResourceServer.cs b/src/DotNetOpenAuth/OAuth2/ResourceServer.cs
index f861582..af9dcfd 100644
--- a/src/DotNetOpenAuth/OAuth2/ResourceServer.cs
+++ b/src/DotNetOpenAuth/OAuth2/ResourceServer.cs
@@ -105,12 +105,7 @@ namespace DotNetOpenAuth.OAuth2 {
string username;
HashSet<string> scope;
var result = this.VerifyAccess(httpRequestInfo, out username, out scope);
- if (result == null) {
- principal = new OAuth.ChannelElements.OAuthPrincipal(username, scope != null ? scope.ToArray() : new string[0]);
- } else {
- principal = null;
- }
-
+ principal = result == null ? new OAuth.ChannelElements.OAuthPrincipal(username, scope != null ? scope.ToArray() : new string[0]) : null;
return result;
}
diff --git a/src/DotNetOpenAuth/OAuth2/UserAgentClient.cs b/src/DotNetOpenAuth/OAuth2/UserAgentClient.cs
index 367a36a..129102d 100644
--- a/src/DotNetOpenAuth/OAuth2/UserAgentClient.cs
+++ b/src/DotNetOpenAuth/OAuth2/UserAgentClient.cs
@@ -23,6 +23,7 @@ namespace DotNetOpenAuth.OAuth2 {
/// </summary>
/// <param name="authorizationServer">The token issuer.</param>
/// <param name="clientIdentifier">The client identifier.</param>
+ /// <param name="clientSecret">The client secret.</param>
public UserAgentClient(AuthorizationServerDescription authorizationServer, string clientIdentifier = null, string clientSecret = null)
: base(authorizationServer, clientIdentifier, clientSecret) {
}
diff --git a/src/DotNetOpenAuth/OAuth2/WebServerClient.cs b/src/DotNetOpenAuth/OAuth2/WebServerClient.cs
index 091b022..0998619 100644
--- a/src/DotNetOpenAuth/OAuth2/WebServerClient.cs
+++ b/src/DotNetOpenAuth/OAuth2/WebServerClient.cs
@@ -39,34 +39,34 @@ namespace DotNetOpenAuth.OAuth2 {
/// Prepares a request for user authorization from an authorization server.
/// </summary>
/// <param name="scope">The scope of authorized access requested.</param>
+ /// <param name="state">The state of the client that should be sent back with the authorization response.</param>
/// <returns>The authorization request as an HTTP response that causes a redirect.</returns>
- public OutgoingWebResponse RequestUserAuthorization(IEnumerable<string> scope = null) {
- var response = this.PrepareRequestUserAuthorization(scope);
- return this.Channel.PrepareResponse(response);
+ public void RequestUserAuthorization(IEnumerable<string> scope = null, string state = null) {
+ this.PrepareRequestUserAuthorization(scope, state).Send();
}
/// <summary>
/// Prepares a request for user authorization from an authorization server.
/// </summary>
- /// <param name="scope">The scope of authorized access requested.</param>
+ /// <param name="scopes">The scope of authorized access requested.</param>
+ /// <param name="state">The state of the client that should be sent back with the authorization response.</param>
/// <returns>The authorization request.</returns>
- public EndUserAuthorizationRequest PrepareRequestUserAuthorization(IEnumerable<string> scopes = null) {
+ public OutgoingWebResponse PrepareRequestUserAuthorization(IEnumerable<string> scopes = null, string state = null) {
var authorizationState = new AuthorizationState(scopes);
- return this.PrepareRequestUserAuthorization(authorizationState);
+ return this.PrepareRequestUserAuthorization(authorizationState, state);
}
/// <summary>
/// Prepares a request for user authorization from an authorization server.
/// </summary>
/// <param name="authorization">The authorization state to associate with this particular request.</param>
+ /// <param name="state">The state of the client that should be sent back with the authorization response.</param>
/// <returns>The authorization request.</returns>
- public EndUserAuthorizationRequest PrepareRequestUserAuthorization(IAuthorizationState authorization) {
+ public OutgoingWebResponse PrepareRequestUserAuthorization(IAuthorizationState authorization, string state = null) {
Contract.Requires<ArgumentNullException>(authorization != null);
Contract.Requires<InvalidOperationException>(authorization.Callback != null || (HttpContext.Current != null && HttpContext.Current.Request != null), MessagingStrings.HttpContextRequired);
Contract.Requires<InvalidOperationException>(!string.IsNullOrEmpty(this.ClientIdentifier));
- Contract.Ensures(Contract.Result<EndUserAuthorizationRequest>() != null);
- Contract.Ensures(Contract.Result<EndUserAuthorizationRequest>().ClientIdentifier == this.ClientIdentifier);
- Contract.Ensures(Contract.Result<EndUserAuthorizationRequest>().Callback == authorization.Callback);
+ Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
if (authorization.Callback == null) {
authorization.Callback = this.Channel.GetRequestFromContext().UrlBeforeRewriting
@@ -78,10 +78,11 @@ namespace DotNetOpenAuth.OAuth2 {
var request = new EndUserAuthorizationRequest(this.AuthorizationServer) {
ClientIdentifier = this.ClientIdentifier,
Callback = authorization.Callback,
+ ClientState = state,
};
request.Scope.ResetContents(authorization.Scope);
- return request;
+ return this.Channel.PrepareResponse(request);
}
/// <summary>