summaryrefslogtreecommitdiffstats
path: root/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2011-06-06 16:23:01 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2011-06-06 16:23:01 -0700
commit299fd439688e9e4a220c862b92ec82e82bdf0ab0 (patch)
tree52489fda9952d9aa7ccd59fab795e6862e24753b /projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
parente76823bc716477d3d5e26d17d0df7a2314bc2d82 (diff)
parentdbbc823b7580d4e7d5251539a8dcace730df2e3f (diff)
downloadDotNetOpenAuth-299fd439688e9e4a220c862b92ec82e82bdf0ab0.zip
DotNetOpenAuth-299fd439688e9e4a220c862b92ec82e82bdf0ab0.tar.gz
DotNetOpenAuth-299fd439688e9e4a220c862b92ec82e82bdf0ab0.tar.bz2
Merging OAuth 2.0 work into what will become DotNetOpenAuth 4.0.
Diffstat (limited to 'projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs')
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs19
1 files changed, 11 insertions, 8 deletions
diff --git a/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs b/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
index e47e4ee..2c9dc66 100644
--- a/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
+++ b/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
@@ -12,9 +12,7 @@ namespace RelyingPartyLogic {
using System.Web;
using System.Web.Security;
using DotNetOpenAuth.Messaging;
- using DotNetOpenAuth.OAuth;
- using DotNetOpenAuth.OAuth.ChannelElements;
- using DotNetOpenAuth.OAuth.Messages;
+ using DotNetOpenAuth.OAuth2;
public class OAuthAuthenticationModule : IHttpModule {
private HttpApplication application;
@@ -51,10 +49,15 @@ namespace RelyingPartyLogic {
return;
}
- IDirectedProtocolMessage incomingMessage = OAuthServiceProvider.ServiceProvider.ReadRequest(new HttpRequestInfo(this.application.Context.Request));
- var authorization = incomingMessage as AccessProtectedResourceRequest;
- if (authorization != null) {
- this.application.Context.User = OAuthServiceProvider.ServiceProvider.CreatePrincipal(authorization);
+ using (var crypto = OAuthAuthorizationServer.CreateAsymmetricKeyServiceProvider()) {
+ var tokenAnalyzer = new SpecialAccessTokenAnalyzer(crypto, crypto);
+ var resourceServer = new ResourceServer(tokenAnalyzer);
+
+ IPrincipal principal;
+ var errorMessage = resourceServer.VerifyAccess(new HttpRequestInfo(this.application.Context.Request), out principal);
+ if (errorMessage == null) {
+ this.application.Context.User = principal;
+ }
}
}
@@ -70,7 +73,7 @@ namespace RelyingPartyLogic {
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Web.Security.RoleManagerEventArgs"/> instance containing the event data.</param>
private void roleManager_GetRoles(object sender, RoleManagerEventArgs e) {
- if (this.application.User is OAuthPrincipal) {
+ if (this.application.User is DotNetOpenAuth.OAuth.ChannelElements.OAuthPrincipal) {
e.RolesPopulated = true;
}
}