summaryrefslogtreecommitdiffstats
path: root/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-07-17 22:04:56 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2010-07-17 22:04:56 -0700
commit7c86d53eac655514ac0c8b7c8ede95c0af5798fb (patch)
tree390b5c5a1f695812aa61c2fdfa845e4fe0ae3590 /projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
parent3ab1adf5a949a5799f6a7fee377ae3c7e77ec69a (diff)
parent17c604a07b35bcfd3a77299777521f04063bd6ae (diff)
downloadDotNetOpenAuth-7c86d53eac655514ac0c8b7c8ede95c0af5798fb.zip
DotNetOpenAuth-7c86d53eac655514ac0c8b7c8ede95c0af5798fb.tar.gz
DotNetOpenAuth-7c86d53eac655514ac0c8b7c8ede95c0af5798fb.tar.bz2
Merge branch 'oauth2templates' into oauth2
Diffstat (limited to 'projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs')
-rw-r--r--projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs17
1 files changed, 9 insertions, 8 deletions
diff --git a/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs b/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs
index e47e4ee..c0685bc 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,13 @@ 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);
+ var tokenAnalyzer = new SpecialAccessTokenAnalyzer(OAuthAuthorizationServer.AsymmetricKey, OAuthAuthorizationServer.AsymmetricKey);
+ 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 +71,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;
}
}