diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-07-20 08:39:39 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-07-20 08:39:39 -0700 |
commit | 4e2fc05605966377f30e9a59f80330e1a9c3f06c (patch) | |
tree | 6668201a57560c94b29eb6464fefa2220c417058 /src/DotNetOpenAuth.OAuth2.AuthorizationServer | |
parent | 2d24056882a645bc1ae519f0322d533d9bf86b96 (diff) | |
download | DotNetOpenAuth-4e2fc05605966377f30e9a59f80330e1a9c3f06c.zip DotNetOpenAuth-4e2fc05605966377f30e9a59f80330e1a9c3f06c.tar.gz DotNetOpenAuth-4e2fc05605966377f30e9a59f80330e1a9c3f06c.tar.bz2 |
Adds AuthorizationServer.DecodeRefreshToken
And a unit test.
Fixes #182
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2.AuthorizationServer')
2 files changed, 21 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthorizationServer.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthorizationServer.cs index 6a96c2d..7d829c5 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthorizationServer.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthorizationServer.cs @@ -251,6 +251,25 @@ namespace DotNetOpenAuth.OAuth2 { } /// <summary> + /// Decodes a refresh token into its authorization details. + /// </summary> + /// <param name="refreshToken">The encoded refresh token as it would appear to the client.</param> + /// <returns>A description of the authorization represented by the refresh token.</returns> + /// <exception cref="ProtocolException">Thrown if the refresh token is not valid due to expiration, corruption or not being authentic.</exception> + /// <remarks> + /// This can be useful if the authorization server supports the client revoking its own access (on uninstall, for example). + /// Outside the scope of the OAuth 2 spec, the client may contact the authorization server host requesting that its refresh + /// token be revoked. The authorization server would need to decode the refresh token so it knows which authorization in + /// the database to delete. + /// </remarks> + public IAuthorizationDescription DecodeRefreshToken(string refreshToken) { + var refreshTokenFormatter = RefreshToken.CreateFormatter(this.AuthorizationServerServices.CryptoKeyStore); + var token = new RefreshToken(); + refreshTokenFormatter.Deserialize(token, refreshToken); + return token; + } + + /// <summary> /// Gets the redirect URL to use for a particular authorization request. /// </summary> /// <param name="authorizationRequest">The authorization request.</param> diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/TokenCodeSerializationBindingElement.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/TokenCodeSerializationBindingElement.cs index 494a10b..5a1dbae 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/TokenCodeSerializationBindingElement.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/TokenCodeSerializationBindingElement.cs @@ -103,7 +103,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { if (authCodeCarrier != null) { var authorizationCodeFormatter = AuthorizationCode.CreateFormatter(this.AuthorizationServer); var authorizationCode = new AuthorizationCode(); - authorizationCodeFormatter.Deserialize(authorizationCode, message, authCodeCarrier.Code, Protocol.code); + authorizationCodeFormatter.Deserialize(authorizationCode, authCodeCarrier.Code, message, Protocol.code); authCodeCarrier.AuthorizationDescription = authorizationCode; } @@ -111,7 +111,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { if (refreshTokenCarrier != null) { var refreshTokenFormatter = RefreshToken.CreateFormatter(this.AuthorizationServer.CryptoKeyStore); var refreshToken = new RefreshToken(); - refreshTokenFormatter.Deserialize(refreshToken, message, refreshTokenCarrier.RefreshToken, Protocol.refresh_token); + refreshTokenFormatter.Deserialize(refreshToken, refreshTokenCarrier.RefreshToken, message, Protocol.refresh_token); refreshTokenCarrier.AuthorizationDescription = refreshToken; } |