diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-22 23:14:41 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-22 23:14:41 -0700 |
commit | 7323ea7a7b17e6fc0c6636f4c5784d5bfe2179e9 (patch) | |
tree | 58bd5d97392da0f279fa1338ba628bd2da4790d6 /samples/OpenIdProviderMvc/Controllers/OpenIdController.cs | |
parent | 8f173adba793c6ef4efccb4ee21c17e24a442783 (diff) | |
download | DotNetOpenAuth-7323ea7a7b17e6fc0c6636f4c5784d5bfe2179e9.zip DotNetOpenAuth-7323ea7a7b17e6fc0c6636f4c5784d5bfe2179e9.tar.gz DotNetOpenAuth-7323ea7a7b17e6fc0c6636f4c5784d5bfe2179e9.tar.bz2 |
Initial stab at PPID identifiers to protect privacy.
Diffstat (limited to 'samples/OpenIdProviderMvc/Controllers/OpenIdController.cs')
-rw-r--r-- | samples/OpenIdProviderMvc/Controllers/OpenIdController.cs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/samples/OpenIdProviderMvc/Controllers/OpenIdController.cs b/samples/OpenIdProviderMvc/Controllers/OpenIdController.cs index fff0a62..a46c39a 100644 --- a/samples/OpenIdProviderMvc/Controllers/OpenIdController.cs +++ b/samples/OpenIdProviderMvc/Controllers/OpenIdController.cs @@ -7,6 +7,7 @@ namespace OpenIdProviderMvc.Controllers { using System.Web.Mvc.Ajax; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.Provider; + using OpenIdProviderMvc.Code; public class OpenIdController : Controller { internal static OpenIdProvider OpenIdProvider = new OpenIdProvider(); @@ -24,7 +25,7 @@ namespace OpenIdProviderMvc.Controllers { if (authRequest != null) { PendingAuthenticationRequest = authRequest; if (User.Identity.IsAuthenticated && (authRequest.IsDirectedIdentity || Models.User.GetClaimedIdentifierForUser(User.Identity.Name) == authRequest.LocalIdentifier)) { - return this.SendAssertion(); + return this.SendAssertion(true); } else { return RedirectToAction("LogOn", "Account", new { returnUrl = Url.Action("SendAssertion") }); } @@ -41,7 +42,7 @@ namespace OpenIdProviderMvc.Controllers { } [Authorize] - public ActionResult SendAssertion() { + public ActionResult SendAssertion(bool pseudonymous) { IAuthenticationRequest authReq = PendingAuthenticationRequest; PendingAuthenticationRequest = null; if (authReq == null) { @@ -53,6 +54,10 @@ namespace OpenIdProviderMvc.Controllers { authReq.ClaimedIdentifier = authReq.LocalIdentifier; authReq.IsAuthenticated = true; } else { + if (pseudonymous) { + throw new InvalidOperationException("Pseudonymous identifiers are only available when used with directed identity."); + } + if (authReq.LocalIdentifier == Models.User.GetClaimedIdentifierForUser(User.Identity.Name)) { authReq.IsAuthenticated = true; if (!authReq.IsDelegatedIdentifier) { @@ -62,6 +67,12 @@ namespace OpenIdProviderMvc.Controllers { authReq.IsAuthenticated = false; } } + + if (pseudonymous) { + var anonProvider = new AnonymousIdentifierProvider(); + authReq.ScrubPersonallyIdentifiableInformation(anonProvider, true); + } + return OpenIdProvider.PrepareResponse(authReq).AsActionResult(); } } |