diff options
Diffstat (limited to 'samples/OpenIdRelyingPartyMvc/Views')
9 files changed, 386 insertions, 0 deletions
diff --git a/samples/OpenIdRelyingPartyMvc/Views/Home/Index.aspx b/samples/OpenIdRelyingPartyMvc/Views/Home/Index.aspx new file mode 100644 index 0000000..82eb924 --- /dev/null +++ b/samples/OpenIdRelyingPartyMvc/Views/Home/Index.aspx @@ -0,0 +1,16 @@ +<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> + +<asp:Content ID="indexContent" ContentPlaceHolderID="MainContentPlaceHolder" runat="server"> + <h1>OpenID Relying Party </h1> + <h2>Provided by <a href="http://dotnetopenid.googlecode.com">DotNetOpenId</a> </h2> + <% if (User.Identity.IsAuthenticated) { %> + <p><b>You are already logged in!</b> Try visiting the + <%=Html.ActionLink("Members Only", "Index", "User") %> + area. </p> + <% } else { %> + <p>Visit the + <%=Html.ActionLink("Members Only", "Index", "User") %> + area to trigger a login. </p> + <p>Optionally, you can try out the <%=Html.ActionLink("JQuery login popup UX", "LoginPopup", "User")%>. </p> + <% } %> +</asp:Content> diff --git a/samples/OpenIdRelyingPartyMvc/Views/Home/xrds.aspx b/samples/OpenIdRelyingPartyMvc/Views/Home/xrds.aspx new file mode 100644 index 0000000..583c77c --- /dev/null +++ b/samples/OpenIdRelyingPartyMvc/Views/Home/xrds.aspx @@ -0,0 +1,22 @@ +<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" ContentType="application/xrds+xml" %><?xml version="1.0" encoding="UTF-8"?> +<%-- +This page is a required for relying party discovery per OpenID 2.0. +It allows Providers to call back to the relying party site to confirm the +identity that it is claiming in the realm and return_to URLs. +This page should be pointed to by the 'realm' home page, which in this sample +is default.aspx. +--%> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + <Service priority="1"> + <Type>http://specs.openid.net/auth/2.0/return_to</Type> + <%-- Every page with an OpenID login should be listed here. --%> + <%-- We use the Authenticate action instead of Login because Authenticate + is the action that receives OpenId assertions. --%> + <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/user/authenticate"))%></URI> + </Service> + </XRD> +</xrds:XRDS> diff --git a/samples/OpenIdRelyingPartyMvc/Views/Shared/Site.Master b/samples/OpenIdRelyingPartyMvc/Views/Shared/Site.Master new file mode 100644 index 0000000..d9b759c --- /dev/null +++ b/samples/OpenIdRelyingPartyMvc/Views/Shared/Site.Master @@ -0,0 +1,51 @@ +<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="OpenIdRelyingPartyMvc.Views.Shared.Site" %> + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head runat="server"> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <title>DotNetOpenAuth ASP.NET MVC Login sample</title> + <link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> + <asp:ContentPlaceHolder ID="HeadContentPlaceHolder" runat="server" /> +</head> +<body> + <div class="page"> + <div id="header"> + <p id="logo"><a href="">DotNetOpenAuth ASP.NET MVC Login sample</a></p> + <ul id="mainMenu"> + <li> + <%= Html.ActionLink("Home", "Index", "Home")%> + </li> + <li> + <%= Html.ActionLink("Member Area", "Index", "User")%> + </li> + </ul> + </div> + <div id="mainContent"> + <div class="columnsContainer"> + <div class="leftColumn"> + <h2>External OpenID Links</h2> + <ul> + <li><a href="http://dotnetopenid.googlecode.com">DotNetOpenAuth</a></li> + <li><a href="http://openid.net">About OpenID</a></li> + </ul> + </div> + <!--/leftColumn--> + <div class="rightColumn"> + <asp:ContentPlaceHolder ID="MainContentPlaceHolder" runat="server"/> + </div> + <!--/rightColumn--> + <div class="clear"> + </div> + </div> + <!--/columnsContainer--> + <div id="footer"> + <p>Andrew Arnott © Copyright 2009 </p> + </div> + <!--/footer--> + </div> + <!--/mainContent--> + </div> + <!--/page--> +</body> +</html> diff --git a/samples/OpenIdRelyingPartyMvc/Views/Shared/Site.Master.cs b/samples/OpenIdRelyingPartyMvc/Views/Shared/Site.Master.cs new file mode 100644 index 0000000..9fca9d7 --- /dev/null +++ b/samples/OpenIdRelyingPartyMvc/Views/Shared/Site.Master.cs @@ -0,0 +1,4 @@ +namespace OpenIdRelyingPartyMvc.Views.Shared { + public partial class Site : System.Web.Mvc.ViewMasterPage { + } +} diff --git a/samples/OpenIdRelyingPartyMvc/Views/Shared/Site.Master.designer.cs b/samples/OpenIdRelyingPartyMvc/Views/Shared/Site.Master.designer.cs new file mode 100644 index 0000000..a207a32 --- /dev/null +++ b/samples/OpenIdRelyingPartyMvc/Views/Shared/Site.Master.designer.cs @@ -0,0 +1,34 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4912 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace OpenIdRelyingPartyMvc.Views.Shared { + + + public partial class Site { + + /// <summary> + /// HeadContentPlaceHolder 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 HeadContentPlaceHolder; + + /// <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/OpenIdRelyingPartyMvc/Views/User/Index.aspx b/samples/OpenIdRelyingPartyMvc/Views/User/Index.aspx new file mode 100644 index 0000000..ef55c06 --- /dev/null +++ b/samples/OpenIdRelyingPartyMvc/Views/User/Index.aspx @@ -0,0 +1,12 @@ +<%@ Page Title="OpenID Relying Party, by DotNetOpenAuth" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" + Inherits="System.Web.Mvc.ViewPage" %> + +<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server"> + <h1>Members Only Area </h1> + <p>Congratulations, <b> + <%=Session["FriendlyIdentifier"] %></b>. You have completed the OpenID login process. + </p> + <p> + <%=Html.ActionLink("Logout", "logout") %> + </p> +</asp:Content> diff --git a/samples/OpenIdRelyingPartyMvc/Views/User/Login.aspx b/samples/OpenIdRelyingPartyMvc/Views/User/Login.aspx new file mode 100644 index 0000000..24f9f56 --- /dev/null +++ b/samples/OpenIdRelyingPartyMvc/Views/User/Login.aspx @@ -0,0 +1,20 @@ +<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> + +<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server"> + <% if (ViewData["Message"] != null) { %> + <div style="border: solid 1px red"> + <%= Html.Encode(ViewData["Message"].ToString())%> + </div> + <% } %> + <p>You must log in before entering the Members Area: </p> + <form action="Authenticate?ReturnUrl=<%=HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]) %>" method="post"> + <label for="openid_identifier">OpenID: </label> + <input id="openid_identifier" name="openid_identifier" size="40" /> + <input type="submit" value="Login" /> + </form> + + <script type="text/javascript"> + document.getElementById("openid_identifier").focus(); + </script> + +</asp:Content> diff --git a/samples/OpenIdRelyingPartyMvc/Views/User/LoginPopup.aspx b/samples/OpenIdRelyingPartyMvc/Views/User/LoginPopup.aspx new file mode 100644 index 0000000..67006fa --- /dev/null +++ b/samples/OpenIdRelyingPartyMvc/Views/User/LoginPopup.aspx @@ -0,0 +1,207 @@ +<%@ Page Title="Popup Login sample" Language="C#" Inherits="System.Web.Mvc.ViewPage" %> + +<!-- COPYRIGHT (C) 2009 Andrew Arnott. All rights reserved. --> +<!-- LICENSE: Microsoft Public License available at http://opensource.org/licenses/ms-pl.html --> + +<html> +<head> + <title>OpenID login demo</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link type="text/css" href="../../Content/theme/ui.all.css" rel="Stylesheet" /> + <link type="text/css" href="../../Content/css/openidlogin.css" rel="stylesheet" /> + <script type="text/javascript" src="../../Content/scripts/jquery-1.3.1.js"></script> + <script type="text/javascript" src="../../Content/scripts/jquery-ui-personalized-1.6rc6.js"></script> + <script> + $(function() { + $('#openidlogin').dialog({ + bgiframe: true, +// autoOpen: true, + modal: true, + title: 'Login or Create new account', + resizable: false, + hide: 'clip', + width: '420px', + buttons: { }, + closeOnEscape: true, + focus: function(event, ui) { + var box = $('#openid_identifier')[0]; + if (box.style.display != 'none') { + box.focus(); + } + }, + }); + + $('#loggedOut').dialog({ + bgiframe: true, + autoOpen: false, + title: 'Logged out', + resizable: false, + closeOnEscape: true, + buttons: { + "Ok": function() { $(this).dialog('close'); }, + }, + }); + + $('#loginAction').click(function() { + $('#openidlogin').dialog('open'); + return false; + }); + + $('#logoutAction').click(function() { + // TODO: asynchronously log out. + document.setClaimedIdentifier(); + //$('#loggedOut').dialog('open'); + return false; + }); + + //hover states on the static widgets + $('.ui-button, ul#icons li').hover( + function() { $(this).addClass('ui-state-hover'); }, + function() { $(this).removeClass('ui-state-hover'); } + ); + + document.usernamePlaceholder = "{username}"; + + function isCompleteIdentifier(identifier) { + return identifier && identifier != '' && identifier != 'http://' && identifier.indexOf(document.usernamePlaceholder) < 0; + }; + + function setSelection() { + var box = $('#openid_identifier')[0]; + var usernamePlaceholderIndex = box.value.indexOf(document.usernamePlaceholder); + if (usernamePlaceholderIndex >= 0) { + box.setSelectionRange(usernamePlaceholderIndex + document.usernamePlaceholder.length); + box.setSelectionRange(usernamePlaceholderIndex, usernamePlaceholderIndex + document.usernamePlaceholder.length); + } + }; + + function completeLogin() { + var box = $('#openid_identifier')[0]; + if (box.value.indexOf(document.usernamePlaceholder) >= 0) { + alert('You need to type in your username first.'); + box.focus(); + setSelection(); + return; + } + + if (!isCompleteIdentifier(box.value)) { + alert(box.value + ' is not a valid identifier.'); + return; + } + + var box = $('#openid_identifier')[0]; + $('#openidlogin').dialog('close'); + document.setClaimedIdentifier(box.value); + $('#loginForm').submit(); + return box.value; + }; + + document.selectProvider = function(button, identifierTemplate) { + var box = $('#openid_identifier')[0]; + $('#openidlogin .provider').removeClass('highlight'); + if (isCompleteIdentifier(identifierTemplate)) { + box.value = identifierTemplate; + $('#openidlogin .inputbox').slideUp(); + completeLogin(); + } else { + if (this.lastIdentifierTemplate == identifierTemplate) { + $('#openidlogin .inputbox').slideToggle(); + } else { + $(button).addClass('highlight').show(); + $('#openidlogin .inputbox').slideDown(); + box.value = identifierTemplate; + if (box.value == null || box.value == '') { + box.value = 'http://'; + } + + setSelection(); + } + + box.focus(); + } + this.lastIdentifierTemplate = identifierTemplate; + } + + $('#loginButton').click(function() { + completeLogin(); + return true; + }); + + document.openid_identifier_keydown = function(e) { + if (window.event && window.event.keyCode == 13) { + $('#loginButton').effect('highlight'); + completeLogin(); + } + }; + + document.setClaimedIdentifier = function(identifier) { + if (identifier) { + // Apply login + $('#loginAction').hide(); + $('#logoutAction').show(); + } else { + // Apply logout + $('#loginAction').show(); + $('#logoutAction').hide(); + } + $('#claimedIdentifierLabel')[0].innerText = identifier ? identifier : ''; + }; + + $('#logoutAction').hide(); + }); + </script> + + <style> + body{ font: 62.5% "Trebuchet MS", sans-serif;} + .ui-button {padding: .4em .5em .4em 20px;text-decoration: none;position: relative;} + .ui-button span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;} + #loginButton {padding: 0.1em 0.4em 0.1em 20px} + </style> +</head> +<body> + +<div style="margin-top: 10px"> + <p style="float: right; margin-top: 0px"> + <a href="#" id="loginAction" class="ui-button ui-state-default ui-corner-all"><span class="ui-icon ui-icon-locked"></span>Login / New user</a> + <a href="#" id="logoutAction" class="ui-button ui-state-default ui-corner-all"><span class="ui-icon ui-icon-unlocked"></span>Logout</a> + </p> + <p style="text-align: center; margin-top: 3px; font-family: Arial" id="claimedIdentifierLabel"/> +</div> + +<div id="openidlogin" class="ui-widget-content"> + <p>Log in with an account you already use:</p> + <div class="large buttons"> + <div class="provider" onclick="document.selectProvider(this, 'https://www.google.com/accounts/o8/id')"><div><img src="../../Content/images/google.gif"/></div></div> + <div class="provider" onclick="document.selectProvider(this, 'https://me.yahoo.com/')"><div><img src="../../Content/images/yahoo.gif"/></div></div> + <div class="provider" onclick="document.selectProvider(this, 'http://openid.aol.com/{username}')"><div><img src="../../Content/images/aol.gif"/></div></div> + <div class="provider" onclick="document.selectProvider(this, '')"><div><img src="../../Content/images/openid.gif"/></div></div> + </div> + <div class="small buttons"> + <div class="provider" onclick="document.selectProvider(this, 'http://www.flickr.com/photos/{username}')"><div><img src="http://flickr.com/favicon.ico"/></div></div> + <div class="provider" onclick="document.selectProvider(this, 'https://www.myopenid.com/')"><div><img src="http://myopenid.com/favicon.ico"/></div></div> + <div class="provider" onclick="document.selectProvider(this, 'http://{username}.livejournal.com/')"><div><img src="http://www.livejournal.com/favicon.ico"/></div></div> + <div class="provider" onclick="document.selectProvider(this, 'https://technorati.com/people/technorati/{username}/')"><div><img src="http://technorati.com/favicon.ico"/></div></div> + <div class="provider" onclick="document.selectProvider(this, 'https://{username}.wordpress.com/')"><div><img src="http://www.wordpress.com/favicon.ico"/></div></div> + <div class="provider" onclick="document.selectProvider(this, 'http://{username}.blogspot.com/')"><div><img src="http://blogspot.com/favicon.ico"/></div></div> + <div class="provider" onclick="document.selectProvider(this, 'https://myvidoop.com/')"><div><img src="http://www.myvidoop.com/favicon.ico"/></div></div> + <div class="provider" onclick="document.selectProvider(this, 'https://pip.verisignlabs.com/')"><div><img src="http://pip.verisignlabs.com/favicon.ico"/></div></div> + </div> + <% Html.BeginForm("Authenticate", "User", FormMethod.Post, new { id = "loginForm" }); %> + <div class="inputbox"> + <input type="text" id="openid_identifier" name="openid_identifier" onKeyDown="document.openid_identifier_keydown(this)" onFocus="$('#loginButton').addClass('ui-state-hover')" onBlur="$('#loginButton').removeClass('ui-state-hover')" /> + <a href="#" id="loginButton" class="ui-button ui-state-default ui-corner-all" style="color: white; font-size: 10pt"><span class="ui-icon ui-icon-key"></span>Login</a> + </div> + <% Html.EndForm(); %> + <p><a href="javascript:$('#openidlogin .help').slideToggle()">Get help logging in</a></p> + <div class="help"> + <p>If you don't have an account with any of these services, you can + <a href="https://www.myopenid.com/signup" target="OpenIdProvider">create one</a>. + <p>If you have logged into this site previously, click the same button you did last time.</p> + </div> +</div> + +<div id="loggedOut" class="ui-widget-content"> + <p>You have been logged out.</p> +</div> +</body> +</html>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyMvc/Views/Web.config b/samples/OpenIdRelyingPartyMvc/Views/Web.config new file mode 100644 index 0000000..e67c0eb --- /dev/null +++ b/samples/OpenIdRelyingPartyMvc/Views/Web.config @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<configuration> + <system.web> + <httpHandlers> + <remove verb="*" path="*.aspx"/> + <add path="*.aspx" verb="*" + type="System.Web.HttpNotFoundHandler"/> + </httpHandlers> + </system.web> + + <system.webServer> + <validation validateIntegratedModeConfiguration="false"/> + <handlers> + <remove name="PageHandlerFactory-ISAPI-2.0"/> + <remove name="PageHandlerFactory-ISAPI-1.1"/> + <remove name="PageHandlerFactory-Integrated"/> + <add name="BlockViewHandler" path="*.aspx" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/> + </handlers> + </system.webServer> +</configuration> |