summaryrefslogtreecommitdiffstats
path: root/samples/RelyingPartyMvc
diff options
context:
space:
mode:
Diffstat (limited to 'samples/RelyingPartyMvc')
-rw-r--r--samples/RelyingPartyMvc/.gitignore1
-rw-r--r--samples/RelyingPartyMvc/Controllers/HomeController.cs6
-rw-r--r--samples/RelyingPartyMvc/Controllers/UserController.cs30
-rw-r--r--samples/RelyingPartyMvc/Default.aspx10
-rw-r--r--samples/RelyingPartyMvc/Global.asax.cs5
-rw-r--r--samples/RelyingPartyMvc/Views/Shared/Site.Master.designer.cs28
-rw-r--r--samples/RelyingPartyMvc/Web.config27
7 files changed, 72 insertions, 35 deletions
diff --git a/samples/RelyingPartyMvc/.gitignore b/samples/RelyingPartyMvc/.gitignore
index 0986274..0b08797 100644
--- a/samples/RelyingPartyMvc/.gitignore
+++ b/samples/RelyingPartyMvc/.gitignore
@@ -2,3 +2,4 @@ Bin
obj
*Trace.txt
*.user
+StyleCop.Cache
diff --git a/samples/RelyingPartyMvc/Controllers/HomeController.cs b/samples/RelyingPartyMvc/Controllers/HomeController.cs
index 15ae689..65caae2 100644
--- a/samples/RelyingPartyMvc/Controllers/HomeController.cs
+++ b/samples/RelyingPartyMvc/Controllers/HomeController.cs
@@ -6,11 +6,11 @@ using System.Web.Mvc;
namespace RelyingPartyMvc.Controllers {
public class HomeController : Controller {
- public void Index() {
+ public ActionResult Index() {
Response.AppendHeader("X-XRDS-Location",
new Uri(Request.Url, Response.ApplyAppPathModifier("~/Home/xrds")).AbsoluteUri);
- RenderView("Index");
+ return View("Index");
}
- public void Xrds() { RenderView("Xrds"); }
+ public ActionResult Xrds() { return View("Xrds"); }
}
}
diff --git a/samples/RelyingPartyMvc/Controllers/UserController.cs b/samples/RelyingPartyMvc/Controllers/UserController.cs
index 991a4bd..35f6966 100644
--- a/samples/RelyingPartyMvc/Controllers/UserController.cs
+++ b/samples/RelyingPartyMvc/Controllers/UserController.cs
@@ -5,27 +5,34 @@ using System.Web;
using System.Web.Mvc;
using DotNetOpenId.RelyingParty;
using System.Web.Security;
+using DotNetOpenId;
namespace RelyingPartyMvc.Controllers {
public class UserController : Controller {
- public void Index() {
+ public ActionResult Index() {
if (!User.Identity.IsAuthenticated) Response.Redirect("/User/Login?ReturnUrl=Index");
- RenderView("Index");
+ return View("Index");
}
- public void Logout() {
+ public ActionResult Logout() {
FormsAuthentication.SignOut();
- Response.Redirect("/Home");
+ return Redirect("/Home");
}
- public void Login() {
+ public ActionResult Login() {
// Stage 1: display login form to user
- RenderView("Login");
+ return View("Login");
}
- public void Authenticate() {
+ public ActionResult Authenticate() {
var openid = new OpenIdRelyingParty();
if (openid.Response == null) {
// Stage 2: user submitting Identifier
- openid.CreateRequest(Request.Form["openid_identifier"]).RedirectToProvider();
+ Identifier id;
+ if (Identifier.TryParse(Request.Form["openid_identifier"], out id)) {
+ openid.CreateRequest(Request.Form["openid_identifier"]).RedirectToProvider();
+ } else {
+ ViewData["Message"] = "Invalid identifier";
+ return View("Login");
+ }
} else {
// Stage 3: OpenID Provider sending assertion response
switch (openid.Response.Status) {
@@ -34,14 +41,13 @@ namespace RelyingPartyMvc.Controllers {
break;
case AuthenticationStatus.Canceled:
ViewData["Message"] = "Canceled at provider";
- RenderView("Login");
- break;
+ return View("Login");
case AuthenticationStatus.Failed:
ViewData["Message"] = openid.Response.Exception.Message;
- RenderView("Login");
- break;
+ return View("Login");
}
}
+ return new EmptyResult();
}
}
}
diff --git a/samples/RelyingPartyMvc/Default.aspx b/samples/RelyingPartyMvc/Default.aspx
index c44a95d..1f81ae3 100644
--- a/samples/RelyingPartyMvc/Default.aspx
+++ b/samples/RelyingPartyMvc/Default.aspx
@@ -1 +1,9 @@
-<!-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. --> \ No newline at end of file
+<%@ Page Language="C#" AutoEventWireup="true" %>
+
+<script runat="server">
+ protected void Page_Load(object sender, EventArgs e) {
+ Response.Redirect("~/Home/Index");
+ }
+</script>
+
+<!-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. -->
diff --git a/samples/RelyingPartyMvc/Global.asax.cs b/samples/RelyingPartyMvc/Global.asax.cs
index 0f0b4ef..0659169 100644
--- a/samples/RelyingPartyMvc/Global.asax.cs
+++ b/samples/RelyingPartyMvc/Global.asax.cs
@@ -7,11 +7,6 @@ using System.Web.Routing;
namespace RelyingPartyMvc {
public class GlobalApplication : System.Web.HttpApplication {
- public GlobalApplication() {
- // since this is a sample, and will often be used with localhost
- DotNetOpenId.UntrustedWebRequest.WhitelistHosts.Add("localhost");
- }
-
public static void RegisterRoutes(RouteCollection routes) {
// Note: Change the URL to "{controller}.mvc/{action}/{id}" to enable
// automatic support on IIS6 and IIS7 classic mode
diff --git a/samples/RelyingPartyMvc/Views/Shared/Site.Master.designer.cs b/samples/RelyingPartyMvc/Views/Shared/Site.Master.designer.cs
index a3e9f70..11010db 100644
--- a/samples/RelyingPartyMvc/Views/Shared/Site.Master.designer.cs
+++ b/samples/RelyingPartyMvc/Views/Shared/Site.Master.designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.1434
+// Runtime Version:2.0.50727.3521
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -9,17 +9,17 @@
//------------------------------------------------------------------------------
namespace RelyingPartyMvc.Views.Shared {
-
-
- public partial class Site {
-
- /// <summary>
- /// MainContentPlaceHolder control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.ContentPlaceHolder MainContentPlaceHolder;
- }
+
+
+ public partial class Site {
+
+ /// <summary>
+ /// MainContentPlaceHolder control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.ContentPlaceHolder MainContentPlaceHolder;
+ }
}
diff --git a/samples/RelyingPartyMvc/Web.config b/samples/RelyingPartyMvc/Web.config
index c865def..2911699 100644
--- a/samples/RelyingPartyMvc/Web.config
+++ b/samples/RelyingPartyMvc/Web.config
@@ -9,6 +9,12 @@
-->
<configuration>
<configSections>
+ <section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <sectionGroup name="dotNetOpenId">
+ <section name="relyingParty" type="DotNetOpenId.Configuration.RelyingPartySection" requirePermission="false" allowLocation="true"/>
+ <section name="provider" type="DotNetOpenId.Configuration.ProviderSection" requirePermission="false" allowLocation="true"/>
+ <section name="untrustedWebRequest" type="DotNetOpenId.Configuration.UntrustedWebRequestSection" requirePermission="false" allowLocation="false"/>
+ </sectionGroup>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
@@ -21,6 +27,24 @@
</sectionGroup>
</sectionGroup>
</configSections>
+
+ <!-- this is an optional configuration section where aspects of dotnetopenid can be customized -->
+ <dotNetOpenId>
+ <untrustedWebRequest>
+ <whitelistHosts>
+ <!-- since this is a sample, and will often be used with localhost -->
+ <add name="localhost" />
+ </whitelistHosts>
+ </untrustedWebRequest>
+ </dotNetOpenId>
+
+ <!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names),
+ which is necessary for OpenID urls with unicode characters in the domain/host name. -->
+ <uri>
+ <idn enabled="All" />
+ <iriParsing enabled="true" />
+ </uri>
+
<appSettings/>
<connectionStrings/>
<system.web>
@@ -36,6 +60,7 @@
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
@@ -68,6 +93,8 @@
</controls>
<namespaces>
<add namespace="System.Web.Mvc"/>
+ <add namespace="System.Web.Mvc.Ajax"/>
+ <add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Linq"/>
<add namespace="System.Collections.Generic"/>