summaryrefslogtreecommitdiffstats
path: root/samples/OAuth2ProtectedWebApi/Code/BearerTokenHandler.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2013-03-02 21:22:38 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2013-03-02 21:22:38 -0800
commit36cadbb1b9bf9c6a9a97b3679f40ea155ce0a615 (patch)
treeaf2a6af1ce23217a2ae8190c7ad775bd540e3be8 /samples/OAuth2ProtectedWebApi/Code/BearerTokenHandler.cs
parent09651b96839ce22116a4047876bb5a43164c1102 (diff)
downloadDotNetOpenAuth-36cadbb1b9bf9c6a9a97b3679f40ea155ce0a615.zip
DotNetOpenAuth-36cadbb1b9bf9c6a9a97b3679f40ea155ce0a615.tar.gz
DotNetOpenAuth-36cadbb1b9bf9c6a9a97b3679f40ea155ce0a615.tar.bz2
Removes the memory crypto key store from the sample.
We now have a 'hard-coded' secret key store that trivial apps/samples may use to keep things simple until they create a database table.
Diffstat (limited to 'samples/OAuth2ProtectedWebApi/Code/BearerTokenHandler.cs')
-rw-r--r--samples/OAuth2ProtectedWebApi/Code/BearerTokenHandler.cs7
1 files changed, 5 insertions, 2 deletions
diff --git a/samples/OAuth2ProtectedWebApi/Code/BearerTokenHandler.cs b/samples/OAuth2ProtectedWebApi/Code/BearerTokenHandler.cs
index 04296b4..23ec087 100644
--- a/samples/OAuth2ProtectedWebApi/Code/BearerTokenHandler.cs
+++ b/samples/OAuth2ProtectedWebApi/Code/BearerTokenHandler.cs
@@ -9,12 +9,15 @@
using DotNetOpenAuth.OAuth2;
+ /// <summary>
+ /// An HTTP server message handler that detects OAuth 2 bearer tokens in the authorization header
+ /// and applies the appropriate principal to the request when found.
+ /// </summary>
public class BearerTokenHandler : DelegatingHandler {
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) {
if (request.Headers.Authorization != null) {
if (request.Headers.Authorization.Scheme == "Bearer") {
- string bearer = request.Headers.Authorization.Parameter;
- var resourceServer = new ResourceServer(new StandardAccessTokenAnalyzer(MemoryCryptoKeyStore.Instance));
+ var resourceServer = new ResourceServer(new StandardAccessTokenAnalyzer(AuthorizationServerHost.HardCodedCryptoKeyStore));
var principal = await resourceServer.GetPrincipalAsync(request, cancellationToken);
HttpContext.Current.User = principal;
Thread.CurrentPrincipal = principal;