Skip to content
This repository
Browse code

Fixed bug in OpenID Provider MVC sample that allowed users to log in …

…as others.

Fixes #207
  • Loading branch information...
commit cdd3e95f4eac8076ffd78641bf4cf61d4422572a 1 parent 2299e0d
Andrew Arnott authored September 26, 2012
13  samples/OpenIdProviderMvc/Controllers/OpenIdController.cs
@@ -2,6 +2,7 @@ namespace OpenIdProviderMvc.Controllers {
2 2
 	using System;
3 3
 	using System.Collections.Generic;
4 4
 	using System.Linq;
  5
+	using System.Net;
5 6
 	using System.Web;
6 7
 	using System.Web.Mvc;
7 8
 	using System.Web.Mvc.Ajax;
@@ -65,6 +66,11 @@ public class OpenIdController : Controller {
65 66
 				return response;
66 67
 			}
67 68
 
  69
+			if (!ProviderEndpoint.PendingAuthenticationRequest.IsDirectedIdentity &&
  70
+				!this.UserControlsIdentifier(ProviderEndpoint.PendingAuthenticationRequest)) {
  71
+				return this.Redirect(this.Url.Action("LogOn", "Account", new { returnUrl = this.Request.Url }));
  72
+			}
  73
+
68 74
 			this.ViewData["Realm"] = ProviderEndpoint.PendingRequest.Realm;
69 75
 
70 76
 			return this.View();
@@ -72,6 +78,13 @@ public class OpenIdController : Controller {
72 78
 
73 79
 		[HttpPost, Authorize, ValidateAntiForgeryToken]
74 80
 		public ActionResult AskUserResponse(bool confirmed) {
  81
+			if (!ProviderEndpoint.PendingAuthenticationRequest.IsDirectedIdentity &&
  82
+				!this.UserControlsIdentifier(ProviderEndpoint.PendingAuthenticationRequest))
  83
+			{
  84
+				// The user shouldn't have gotten this far without controlling the identifier we'd send an assertion for.
  85
+				return new HttpStatusCodeResult((int)HttpStatusCode.BadRequest);
  86
+			}
  87
+
75 88
 			if (ProviderEndpoint.PendingAnonymousRequest != null) {
76 89
 				ProviderEndpoint.PendingAnonymousRequest.IsApproved = confirmed;
77 90
 			} else if (ProviderEndpoint.PendingAuthenticationRequest != null) {

0 notes on commit cdd3e95

Please sign in to comment.
Something went wrong with that request. Please try again.