diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-10-04 16:45:52 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-10-04 16:45:52 -0700 |
commit | 9ffccf622b5c669027c8cbb9ee2f8735ea25d636 (patch) | |
tree | 5d25daff51635cd05e419d7fe42d25d6e1a3e262 /samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs | |
parent | 2e681a4b643fec2cdac42c729cb08ea3faa7a099 (diff) | |
download | DotNetOpenAuth-9ffccf622b5c669027c8cbb9ee2f8735ea25d636.zip DotNetOpenAuth-9ffccf622b5c669027c8cbb9ee2f8735ea25d636.tar.gz DotNetOpenAuth-9ffccf622b5c669027c8cbb9ee2f8735ea25d636.tar.bz2 |
Added WCF sample consumer and service provider.
It's pretty delicate and a poor sample, but hey, it worked.
Diffstat (limited to 'samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs')
-rw-r--r-- | samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs b/samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs new file mode 100644 index 0000000..20536d8 --- /dev/null +++ b/samples/ServiceProvider/App_Code/OAuthAuthorizationManager.cs @@ -0,0 +1,32 @@ +using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using DotNetOAuth;
+
+/// <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.GetProtectedResourceAuthorization(httpDetails, requestUri);
+ if (auth != null) {
+ string consumer = auth.ConsumerKey;
+
+ //// TODO: pass the consumer along to the operation somehow
+
+ return true;
+ }
+
+ return false;
+ }
+}
|