summaryrefslogtreecommitdiffstats
path: root/samples/OAuthAuthorizationServer/Controllers
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2011-05-28 17:31:20 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2011-05-28 17:31:20 -0700
commitdbbc823b7580d4e7d5251539a8dcace730df2e3f (patch)
tree52489fda9952d9aa7ccd59fab795e6862e24753b /samples/OAuthAuthorizationServer/Controllers
parentbb155ca75f8906bde74d8adbf36fa4f4c4bcded7 (diff)
parent5ea256fa7309ad23f4278ef9113ccde5a231bff7 (diff)
downloadDotNetOpenAuth-dbbc823b7580d4e7d5251539a8dcace730df2e3f.zip
DotNetOpenAuth-dbbc823b7580d4e7d5251539a8dcace730df2e3f.tar.gz
DotNetOpenAuth-dbbc823b7580d4e7d5251539a8dcace730df2e3f.tar.bz2
Introduced ICryptoKeyStore, and worked it into OpenID OPs, RPs, and OAuth 2.0 roles.
Diffstat (limited to 'samples/OAuthAuthorizationServer/Controllers')
-rw-r--r--samples/OAuthAuthorizationServer/Controllers/HomeController.cs6
-rw-r--r--samples/OAuthAuthorizationServer/Controllers/OAuthController.cs21
2 files changed, 16 insertions, 11 deletions
diff --git a/samples/OAuthAuthorizationServer/Controllers/HomeController.cs b/samples/OAuthAuthorizationServer/Controllers/HomeController.cs
index 1887576..1311caa 100644
--- a/samples/OAuthAuthorizationServer/Controllers/HomeController.cs
+++ b/samples/OAuthAuthorizationServer/Controllers/HomeController.cs
@@ -4,7 +4,7 @@
using System.IO;
using System.Linq;
using System.Web.Mvc;
-
+ using System.Web.Security;
using OAuthAuthorizationServer.Code;
[HandleError]
@@ -39,6 +39,10 @@
});
dc.SubmitChanges();
+
+ // Force the user to log out because a new database warrants a new row in the users table, which we create
+ // when the user logs in.
+ FormsAuthentication.SignOut();
ViewData["Success"] = true;
} catch (SqlException ex) {
ViewData["Error"] = string.Join("<br>", ex.Errors.OfType<SqlError>().Select(er => er.Message).ToArray());
diff --git a/samples/OAuthAuthorizationServer/Controllers/OAuthController.cs b/samples/OAuthAuthorizationServer/Controllers/OAuthController.cs
index 47c1977..fb836a6 100644
--- a/samples/OAuthAuthorizationServer/Controllers/OAuthController.cs
+++ b/samples/OAuthAuthorizationServer/Controllers/OAuthController.cs
@@ -35,16 +35,6 @@
#endif
/// <summary>
- /// Creates the resource server's encryption service provider with private key.
- /// </summary>
- /// <returns>An RSA crypto service provider.</returns>
- internal static RSACryptoServiceProvider CreateResourceServerEncryptionServiceProvider() {
- var resourceServerEncryptionServiceProvider = new RSACryptoServiceProvider();
- resourceServerEncryptionServiceProvider.ImportParameters(ResourceServerEncryptionPublicKey);
- return resourceServerEncryptionServiceProvider;
- }
-
- /// <summary>
/// The OAuth 2.0 token endpoint.
/// </summary>
/// <returns>The response to the Client.</returns>
@@ -123,6 +113,7 @@
User = MvcApplication.LoggedInUser,
CreatedOnUtc = DateTime.UtcNow,
});
+ MvcApplication.DataContext.SubmitChanges(); // submit now so that this new row can be retrieved later in this same HTTP request
// In this simple sample, the user either agrees to the entire scope requested by the client or none of it.
// But in a real app, you could grant a reduced scope of access to the client by passing a scope parameter to this method.
@@ -133,5 +124,15 @@
return this.authorizationServer.Channel.PrepareResponse(response).AsActionResult();
}
+
+ /// <summary>
+ /// Creates the resource server's encryption service provider with private key.
+ /// </summary>
+ /// <returns>An RSA crypto service provider.</returns>
+ internal static RSACryptoServiceProvider CreateResourceServerEncryptionServiceProvider() {
+ var resourceServerEncryptionServiceProvider = new RSACryptoServiceProvider();
+ resourceServerEncryptionServiceProvider.ImportParameters(ResourceServerEncryptionPublicKey);
+ return resourceServerEncryptionServiceProvider;
+ }
}
}