summaryrefslogtreecommitdiffstats
path: root/samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs')
-rw-r--r--samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs37
1 files changed, 0 insertions, 37 deletions
diff --git a/samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs b/samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs
deleted file mode 100644
index fce1ad4..0000000
--- a/samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using System.Linq;
-using System.ServiceModel;
-using System.ServiceModel.Channels;
-using DotNetOpenAuth;
-using DotNetOpenAuth.OAuth;
-
-/// <summary>
-/// A WCF extension to authenticate incoming messages using OAuth.
-/// </summary>
-public class OAuthAuthorizationManager : ServiceAuthorizationManager {
- public OAuthAuthorizationManager() {
- }
-
- protected override bool CheckAccessCore(OperationContext operationContext) {
- if (!base.CheckAccessCore(operationContext)) {
- return false;
- }
-
- HttpRequestMessageProperty httpDetails = operationContext.RequestContext.RequestMessage.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
- Uri requestUri = operationContext.RequestContext.RequestMessage.Properties["OriginalHttpRequestUri"] as Uri;
- ServiceProvider sp = Constants.CreateServiceProvider();
- var auth = sp.ReadProtectedResourceAuthorization(httpDetails, requestUri);
- if (auth != null) {
- var accessToken = Global.DataContext.OAuthTokens.Single(token => token.Token == auth.AccessToken);
-
- // Only allow this method call if the access token scope permits it.
- string[] scopes = accessToken.Scope.Split('|');
- if (scopes.Contains(operationContext.IncomingMessageHeaders.Action)) {
- operationContext.IncomingMessageProperties["OAuthAccessToken"] = accessToken;
- return true;
- }
- }
-
- return false;
- }
-}