diff options
Diffstat (limited to 'samples')
101 files changed, 1311 insertions, 1096 deletions
diff --git a/samples/DotNetOpenId.Samples.sln b/samples/DotNetOpenId.Samples.sln index 5bc28b4..86e8db0 100644 --- a/samples/DotNetOpenId.Samples.sln +++ b/samples/DotNetOpenId.Samples.sln @@ -5,10 +5,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelyingPartyPortal", "Relyi EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProviderPortal", "ProviderPortal\ProviderPortal.csproj", "{2A59DE0A-B76A-4B42-9A33-04D34548353D}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProviderCustomStore", "ProviderCustomStore\ProviderCustomStore.csproj", "{2D0B2C39-3F90-484E-848B-F3EF956835C3}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelyingPartyCustomStore", "RelyingPartyCustomStore\RelyingPartyCustomStore.csproj", "{DB54DC19-BA56-4C22-A8A0-C49289EA4F53}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelyingPartyMvc", "RelyingPartyMvc\RelyingPartyMvc.csproj", "{07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}"
EndProject
Global
@@ -25,14 +21,6 @@ Global {2A59DE0A-B76A-4B42-9A33-04D34548353D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A59DE0A-B76A-4B42-9A33-04D34548353D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A59DE0A-B76A-4B42-9A33-04D34548353D}.Release|Any CPU.Build.0 = Release|Any CPU
- {2D0B2C39-3F90-484E-848B-F3EF956835C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2D0B2C39-3F90-484E-848B-F3EF956835C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2D0B2C39-3F90-484E-848B-F3EF956835C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2D0B2C39-3F90-484E-848B-F3EF956835C3}.Release|Any CPU.Build.0 = Release|Any CPU
- {DB54DC19-BA56-4C22-A8A0-C49289EA4F53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DB54DC19-BA56-4C22-A8A0-C49289EA4F53}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DB54DC19-BA56-4C22-A8A0-C49289EA4F53}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DB54DC19-BA56-4C22-A8A0-C49289EA4F53}.Release|Any CPU.Build.0 = Release|Any CPU
{07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/samples/ProviderCustomStore/.gitignore b/samples/ProviderCustomStore/.gitignore deleted file mode 100644 index f4e2383..0000000 --- a/samples/ProviderCustomStore/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -Bin -obj -*.user -*Trace.txt diff --git a/samples/ProviderCustomStore/Default.aspx b/samples/ProviderCustomStore/Default.aspx deleted file mode 100644 index 375b3cb..0000000 --- a/samples/ProviderCustomStore/Default.aspx +++ /dev/null @@ -1,29 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" %>
-
-<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId" TagPrefix="openid" %>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head runat="server">
- <openid:XrdsPublisher runat="server" XrdsUrl="~/op_xrds.aspx" />
- <title>OpenID Provider, by DotNetOpenId</title>
-</head>
-<body>
- <form id="form1" runat="server">
- <h1>
- OpenID Provider, with custom store
- </h1>
- <h2>
- Provided by <a href="http://dotnetopenid.googlecode.com">DotNetOpenId</a>
- </h2>
- <p>
- This sample implements a custom store for associations, which can be useful when
- deploying an OpenId provider site on a web farm.
- </p>
- <p>
- This is a very stripped-down sample. No login is required on this site as it automatically
- responds affirmatively to any OpenId request sent to it. Start the authentication
- process on the Relying Party sample site.
- </p>
- </form>
-</body>
-</html>
diff --git a/samples/ProviderCustomStore/Global.asax b/samples/ProviderCustomStore/Global.asax deleted file mode 100644 index 3fe35c6..0000000 --- a/samples/ProviderCustomStore/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="ProviderCustomStore.Global" Language="C#" %>
diff --git a/samples/ProviderCustomStore/Global.asax.cs b/samples/ProviderCustomStore/Global.asax.cs deleted file mode 100644 index ad31f4f..0000000 --- a/samples/ProviderCustomStore/Global.asax.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System;
-using ProviderPortal;
-
-namespace ProviderCustomStore {
- public class Global : System.Web.HttpApplication {
- public Global() {
- // since this is a sample, and will often be used with localhost
- DotNetOpenId.UntrustedWebRequest.WhitelistHosts.Add("localhost");
- }
-
- protected void Application_BeginRequest(object sender, EventArgs e) {
- URLRewriter.Process();
- }
- }
-}
\ No newline at end of file diff --git a/samples/ProviderCustomStore/Properties/AssemblyInfo.cs b/samples/ProviderCustomStore/Properties/AssemblyInfo.cs deleted file mode 100644 index 166993e..0000000 --- a/samples/ProviderCustomStore/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("ProviderCustomStore")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("ProviderCustomStore")]
-[assembly: AssemblyCopyright("Copyright © 2008")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/samples/ProviderCustomStore/ProviderCustomStore.csproj b/samples/ProviderCustomStore/ProviderCustomStore.csproj deleted file mode 100644 index 4ed2879..0000000 --- a/samples/ProviderCustomStore/ProviderCustomStore.csproj +++ /dev/null @@ -1,118 +0,0 @@ -<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{2D0B2C39-3F90-484E-848B-F3EF956835C3}</ProjectGuid>
- <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>ProviderCustomStore</RootNamespace>
- <AssemblyName>ProviderCustomStore</AssemblyName>
- <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Data" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Web" />
- <Reference Include="System.Xml" />
- <Reference Include="System.Configuration" />
- <Reference Include="System.Web.Services" />
- <Reference Include="System.EnterpriseServices" />
- <Reference Include="System.Web.Mobile" />
- </ItemGroup>
- <ItemGroup>
- <Content Include="Default.aspx" />
- <Content Include="Global.asax" />
- <Content Include="op_xrds.aspx" />
- <Content Include="Server.aspx" />
- <Content Include="user.aspx" />
- <Content Include="user_xrds.aspx" />
- <Content Include="Web.config" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="..\ProviderPortal\Code\URLRewriter.cs">
- <Link>URLRewriter.cs</Link>
- </Compile>
- <Compile Include="CustomStore.cs" />
- <Compile Include="CustomStoreDataSet.Designer.cs">
- <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- </Compile>
- <Compile Include="Global.asax.cs">
- <DependentUpon>Global.asax</DependentUpon>
- </Compile>
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Server.aspx.cs">
- <DependentUpon>Server.aspx</DependentUpon>
- <SubType>ASPXCodeBehind</SubType>
- </Compile>
- <Compile Include="Server.aspx.designer.cs">
- <DependentUpon>Server.aspx</DependentUpon>
- </Compile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\src\DotNetOpenId\DotNetOpenId.csproj">
- <Project>{5D6EDC86-F5B2-4786-8376-4E7C24C63D39}</Project>
- <Name>DotNetOpenId</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="CustomStoreDataSet.xsc">
- <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
- </None>
- <None Include="CustomStoreDataSet.xsd">
- <Generator>MSDataSetGenerator</Generator>
- <LastGenOutput>CustomStoreDataSet.Designer.cs</LastGenOutput>
- <SubType>Designer</SubType>
- </None>
- <None Include="CustomStoreDataSet.xss">
- <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
- </None>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
- <ProjectExtensions>
- <VisualStudio>
- <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
- <WebProjectProperties>
- <UseIIS>False</UseIIS>
- <AutoAssignPort>True</AutoAssignPort>
- <DevelopmentServerPort>1230</DevelopmentServerPort>
- <DevelopmentServerVPath>/</DevelopmentServerVPath>
- <IISUrl>
- </IISUrl>
- <NTLMAuthentication>False</NTLMAuthentication>
- <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
- </WebProjectProperties>
- </FlavorProperties>
- </VisualStudio>
- </ProjectExtensions>
-</Project>
\ No newline at end of file diff --git a/samples/ProviderCustomStore/Server.aspx b/samples/ProviderCustomStore/Server.aspx deleted file mode 100644 index 8b487a5..0000000 --- a/samples/ProviderCustomStore/Server.aspx +++ /dev/null @@ -1,44 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" Inherits="Server" CodeBehind="server.aspx.cs" ValidateRequest="false" %>
-
-<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId.Provider" TagPrefix="openid" %>
-<html>
-<head>
- <title>This is an OpenID server</title>
-</head>
-<body>
- <form id="Form1" runat='server'>
- <p>
- This is an OpenID server endpoint.
- </p>
- <p>
- For more information about OpenID, see:
- </p>
- <table>
- <tr>
- <td>
- <a href="http://dotnetopenid.googlecode.com/">http://dotnetopenid.googlecode.com/</a>
- </td>
- <td>
- Home of this library
- </td>
- </tr>
- <tr>
- <td>
- <a href="http://www.openid.net/">http://www.openid.net/</a>
- </td>
- <td>
- The official OpenID Web site
- </td>
- </tr>
- <tr>
- <td>
- <a href="http://www.openidenabled.com/">http://www.openidenabled.com/</a>
- </td>
- <td>
- An OpenID community Web site
- </td>
- </tr>
- </table>
- </form>
-</body>
-</html>
diff --git a/samples/ProviderCustomStore/Server.aspx.cs b/samples/ProviderCustomStore/Server.aspx.cs deleted file mode 100644 index 9d4a9f6..0000000 --- a/samples/ProviderCustomStore/Server.aspx.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System;
-using System.Collections.Specialized;
-using System.Diagnostics;
-using DotNetOpenId.Provider;
-using ProviderCustomStore;
-
-public partial class Server : System.Web.UI.Page {
- protected void Page_Load(object sender, EventArgs e) {
- var builder = new UriBuilder(Request.Url);
- builder.Query = null;
- builder.Fragment = null;
- Uri providerEndpoint = builder.Uri;
- NameValueCollection query = Request.RequestType == "GET" ? Request.QueryString : Request.Form;
- OpenIdProvider op = new OpenIdProvider(CustomStore.Instance, providerEndpoint, Request.Url, query);
- if (op.Request != null) {
- if (!op.Request.IsResponseReady) {
- var request = (IAuthenticationRequest)op.Request;
- if (request.IsDirectedIdentity) throw new NotSupportedException("This sample does not implement directed identity support.");
- request.IsAuthenticated = true;
- }
- Debug.Assert(op.Request.IsResponseReady);
- op.Request.Response.Send();
- Response.End();
- }
- }
-}
diff --git a/samples/ProviderCustomStore/Server.aspx.designer.cs b/samples/ProviderCustomStore/Server.aspx.designer.cs deleted file mode 100644 index 6a53f1f..0000000 --- a/samples/ProviderCustomStore/Server.aspx.designer.cs +++ /dev/null @@ -1,23 +0,0 @@ -//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-// Runtime Version:2.0.50727.1434
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-
-
-public partial class Server {
-
- /// <summary>
- /// Form1 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.HtmlControls.HtmlForm Form1;
-}
diff --git a/samples/ProviderCustomStore/Web.config b/samples/ProviderCustomStore/Web.config deleted file mode 100644 index 1d4b0d4..0000000 --- a/samples/ProviderCustomStore/Web.config +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0"?>
-<!--
- Note: As an alternative to hand editing this file you can use the
- web admin tool to configure settings for your application. Use
- the Website->Asp.Net Configuration option in Visual Studio.
- A full list of settings and comments can be found in
- machine.config.comments usually located in
- \Windows\Microsoft.Net\Framework\v2.x\Config
--->
-<configuration>
- <configSections>
- <section name="urlrewrites" type="ProviderPortal.URLRewriter"/>
- </configSections>
- <connectionStrings/>
- <!--
- Original version created by Richard Birkby (2002-02-22, http://www.codeproject.com/aspnet/URLRewriter.asp)
- Maps from old website to new website using Regular Expressions
- rule/url - old website url (Regular Expression)
- rule/rewrite - new website replacement expression
- Of two or more rules which match a given request, the first will always take precedance.
- -->
- <urlrewrites>
- <rule>
- <!-- This rewrites urls like: user/john ->user.aspx?username=john-->
- <url>/user/(.*)</url>
- <rewrite>/user.aspx?username=$1</rewrite>
- </rule>
- </urlrewrites>
- <system.web>
- <compilation debug="true" />
- <sessionState mode="InProc" cookieless="false"/>
- <membership>
- <providers>
- <clear/>
- <add
- name="AspNetSqlMembershipProvider"
- type="System.Web.Security.SqlMembershipProvider"
- connectionStringName="LocalSqlServer"
- enablePasswordRetrieval="false"
- enablePasswordReset="true"
- requiresQuestionAndAnswer="false"
- applicationName="/"
- requiresUniqueEmail="false"
- passwordFormat="Hashed"
- maxInvalidPasswordAttempts="5"
- minRequiredPasswordLength="1"
- minRequiredNonalphanumericCharacters="0"
- passwordAttemptWindow="10"
- passwordStrengthRegularExpression=""
- />
- </providers>
- </membership>
- <authentication mode="Forms">
- <forms name="ProviderCustomStoreSession"/> <!-- named cookie prevents conflicts with other samples -->
- </authentication>
- <customErrors mode="RemoteOnly"/>
- <!-- Trust level discussion:
- Full: everything works
- High: TRACE compilation symbol must NOT be defined
- Medium/Low: doesn't work on default machine.config. ConfigurationPermission is denied (why is it needed?)
- -->
- <trust level="Full" originUrl=""/>
- </system.web>
-</configuration>
diff --git a/samples/ProviderCustomStore/op_xrds.aspx b/samples/ProviderCustomStore/op_xrds.aspx deleted file mode 100644 index 7d0ca2c..0000000 --- a/samples/ProviderCustomStore/op_xrds.aspx +++ /dev/null @@ -1,19 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" ContentType="application/xrds+xml" %><?xml version="1.0" encoding="UTF-8"?> -<%-- -This page is a required as part of the service discovery phase of the openid
-protocol (step 1). It simply renders the xml for doing service discovery of
-server.aspx using the xrds mechanism.
-This XRDS doc is discovered via the user.aspx page.
---%> -<xrds:XRDS - xmlns:xrds="xri://$xrds" - xmlns:openid="http://openid.net/xmlns/1.0" - xmlns="xri://$xrd*($v*2.0)"> - <XRD> - <Service priority="10"> - <Type>http://specs.openid.net/auth/2.0/server</Type> - <Type>http://openid.net/sreg/1.0</Type> - <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%></URI> - </Service> - </XRD> -</xrds:XRDS> diff --git a/samples/ProviderCustomStore/user.aspx b/samples/ProviderCustomStore/user.aspx deleted file mode 100644 index 033af02..0000000 --- a/samples/ProviderCustomStore/user.aspx +++ /dev/null @@ -1,17 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" %>
-
-<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId.Provider" TagPrefix="openid" %>
-<html>
-<head>
- <openid:IdentityEndpoint ID="IdentityEndpoint20" runat="server" ProviderEndpointUrl="~/Server.aspx"
- XrdsUrl="~/user_xrds.aspx" ProviderVersion="V20" />
- <!-- and for backward compatibility with OpenID 1.x RPs... -->
- <openid:IdentityEndpoint ID="IdentityEndpoint11" runat="server" ProviderEndpointUrl="~/Server.aspx"
- ProviderVersion="V11" />
-</head>
-<body>
- <p>
- OpenID identity page for <%=Request.QueryString["username"]%>
- </p>
-</body>
-</html>
diff --git a/samples/ProviderCustomStore/user_xrds.aspx b/samples/ProviderCustomStore/user_xrds.aspx deleted file mode 100644 index 4f3e446..0000000 --- a/samples/ProviderCustomStore/user_xrds.aspx +++ /dev/null @@ -1,24 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" ContentType="application/xrds+xml" %><?xml version="1.0" encoding="UTF-8"?> -<%-- -This page is a required as part of the service discovery phase of the openid
-protocol (step 1). It simply renders the xml for doing service discovery of
-server.aspx using the xrds mechanism.
-This XRDS doc is discovered via the user.aspx page.
---%> -<xrds:XRDS - xmlns:xrds="xri://$xrds" - xmlns:openid="http://openid.net/xmlns/1.0" - xmlns="xri://$xrd*($v*2.0)"> - <XRD> - <Service priority="10"> - <Type>http://specs.openid.net/auth/2.0/signon</Type> - <Type>http://openid.net/sreg/1.0</Type> - <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%></URI> - </Service> - <Service priority="20"> - <Type>http://openid.net/signon/1.0</Type> - <Type>http://openid.net/sreg/1.0</Type> - <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%></URI> - </Service> - </XRD> -</xrds:XRDS> diff --git a/samples/ProviderPortal/.gitignore b/samples/ProviderPortal/.gitignore index f4e2383..b086a60 100644 --- a/samples/ProviderPortal/.gitignore +++ b/samples/ProviderPortal/.gitignore @@ -1,4 +1,5 @@ Bin obj *.user -*Trace.txt +*.log +StyleCop.Cache diff --git a/samples/ProviderCustomStore/CustomStore.cs b/samples/ProviderPortal/Code/CustomStore.cs index 5b25ba4..de7043f 100644 --- a/samples/ProviderCustomStore/CustomStore.cs +++ b/samples/ProviderPortal/Code/CustomStore.cs @@ -6,7 +6,7 @@ using DotNetOpenId; using DotNetOpenId.RelyingParty;
using IProviderAssociationStore = DotNetOpenId.IAssociationStore<DotNetOpenId.AssociationRelyingPartyType>;
-namespace ProviderCustomStore {
+namespace ProviderPortal.Code {
/// <summary>
/// This custom store serializes all elements to demonstrate peristent and/or shared storage.
/// This is common in a web farm, for example.
@@ -18,8 +18,7 @@ namespace ProviderCustomStore { /// that using a database is possible.
/// </remarks>
public class CustomStore : IProviderAssociationStore {
- public static CustomStore Instance = new CustomStore();
- public CustomStoreDataSet dataSet = new CustomStoreDataSet();
+ static CustomStoreDataSet dataSet = new CustomStoreDataSet();
#region IAssociationStore<AssociationRelyingPartyType> Members
diff --git a/samples/ProviderCustomStore/CustomStoreDataSet.Designer.cs b/samples/ProviderPortal/Code/CustomStoreDataSet.Designer.cs index 87e5c13..6fbe114 100644 --- a/samples/ProviderCustomStore/CustomStoreDataSet.Designer.cs +++ b/samples/ProviderPortal/Code/CustomStoreDataSet.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.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -10,7 +10,7 @@ #pragma warning disable 1591
-namespace ProviderCustomStore {
+namespace ProviderPortal.Code {
/// <summary>
diff --git a/samples/ProviderCustomStore/CustomStoreDataSet.xsc b/samples/ProviderPortal/Code/CustomStoreDataSet.xsc index 551fc56..551fc56 100644 --- a/samples/ProviderCustomStore/CustomStoreDataSet.xsc +++ b/samples/ProviderPortal/Code/CustomStoreDataSet.xsc diff --git a/samples/ProviderCustomStore/CustomStoreDataSet.xsd b/samples/ProviderPortal/Code/CustomStoreDataSet.xsd index 47f68e8..47f68e8 100644 --- a/samples/ProviderCustomStore/CustomStoreDataSet.xsd +++ b/samples/ProviderPortal/Code/CustomStoreDataSet.xsd diff --git a/samples/ProviderCustomStore/CustomStoreDataSet.xss b/samples/ProviderPortal/Code/CustomStoreDataSet.xss index d097e67..d097e67 100644 --- a/samples/ProviderCustomStore/CustomStoreDataSet.xss +++ b/samples/ProviderPortal/Code/CustomStoreDataSet.xss diff --git a/samples/ProviderPortal/Code/TracePageAppender.cs b/samples/ProviderPortal/Code/TracePageAppender.cs new file mode 100644 index 0000000..ac9b523 --- /dev/null +++ b/samples/ProviderPortal/Code/TracePageAppender.cs @@ -0,0 +1,13 @@ +using System;
+using System.Collections.Generic;
+using System.Web;
+using System.IO;
+
+namespace ProviderPortal.Code {
+ public class TracePageAppender : log4net.Appender.AppenderSkeleton {
+ protected override void Append(log4net.Core.LoggingEvent loggingEvent) {
+ StringWriter sw = new StringWriter(Global.LogMessages);
+ Layout.Format(sw, loggingEvent);
+ }
+ }
+}
diff --git a/samples/ProviderPortal/Code/URLRewriter.cs b/samples/ProviderPortal/Code/URLRewriter.cs index 5a56c99..78bf53e 100644 --- a/samples/ProviderPortal/Code/URLRewriter.cs +++ b/samples/ProviderPortal/Code/URLRewriter.cs @@ -7,6 +7,7 @@ using System.Xml; // nicked from http://www.codeproject.com/aspnet/URLRewriter.asp
namespace ProviderPortal {
public class URLRewriter : IConfigurationSectionHandler {
+ public static log4net.ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected XmlNode _oRules = null;
protected URLRewriter() { }
@@ -22,7 +23,7 @@ namespace ProviderPortal { // check validity of the values
if (oUrlNode == null || string.IsNullOrEmpty(oUrlNode.InnerText)
|| oRewriteNode == null || string.IsNullOrEmpty(oRewriteNode.InnerText)) {
- Trace.TraceWarning("Invalid urlrewrites rule discovered in web.config file.");
+ Logger.Warn("Invalid urlrewrites rule discovered in web.config file.");
continue;
}
@@ -44,7 +45,7 @@ namespace ProviderPortal { string zSubst = oRewriter.GetSubstitution(HttpContext.Current.Request.Path);
if (!string.IsNullOrEmpty(zSubst)) {
- Trace.TraceInformation("Rewriting url '{0}' to '{1}' ", HttpContext.Current.Request.Path, zSubst);
+ Logger.InfoFormat("Rewriting url '{0}' to '{1}' ", HttpContext.Current.Request.Path, zSubst);
HttpContext.Current.RewritePath(zSubst);
}
}
diff --git a/samples/ProviderPortal/Code/Util.cs b/samples/ProviderPortal/Code/Util.cs index 982748c..f864972 100644 --- a/samples/ProviderPortal/Code/Util.cs +++ b/samples/ProviderPortal/Code/Util.cs @@ -19,6 +19,29 @@ public class Util { return ExtractUserName(new Uri(identifier.ToString()));
}
public static Identifier BuildIdentityUrl() {
- return new Uri(HttpContext.Current.Request.Url, "/user/" + HttpContext.Current.User.Identity.Name);
+ string username = HttpContext.Current.User.Identity.Name;
+ // be sure to normalize case the way the user's identity page does.
+ username = username.Substring(0, 1).ToUpperInvariant() + username.Substring(1).ToLowerInvariant();
+ return new Uri(HttpContext.Current.Request.Url, "/user/" + username);
+ }
+ internal static void ProcessAuthenticationChallenge(IAuthenticationRequest idrequest) {
+ if (idrequest.Immediate) {
+ if (idrequest.IsDirectedIdentity) {
+ if (HttpContext.Current.User.Identity.IsAuthenticated) {
+ idrequest.LocalIdentifier = Util.BuildIdentityUrl();
+ idrequest.IsAuthenticated = true;
+ } else {
+ idrequest.IsAuthenticated = false;
+ }
+ } else {
+ string userOwningOpenIdUrl = Util.ExtractUserName(idrequest.LocalIdentifier);
+ // NOTE: in a production provider site, you may want to only
+ // respond affirmatively if the user has already authorized this consumer
+ // to know the answer.
+ idrequest.IsAuthenticated = userOwningOpenIdUrl == HttpContext.Current.User.Identity.Name;
+ }
+ } else {
+ HttpContext.Current.Response.Redirect("~/decide.aspx", true);
+ }
}
}
diff --git a/samples/ProviderPortal/Default.aspx b/samples/ProviderPortal/Default.aspx index a418748..53ba6c4 100644 --- a/samples/ProviderPortal/Default.aspx +++ b/samples/ProviderPortal/Default.aspx @@ -1,8 +1,7 @@ -<%@ Page Language="C#" AutoEventWireup="true" %>
+<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %>
<%@ Import Namespace="DotNetOpenId.Provider" %>
<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId" TagPrefix="openid" %>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void sendAssertionButton_Click(object sender, EventArgs e) {
@@ -20,18 +19,13 @@ }
</script>
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head runat="server">
+<asp:Content runat="server" ContentPlaceHolderID="head">
<openid:XrdsPublisher runat="server" XrdsUrl="~/op_xrds.aspx" />
- <title>OpenID Provider, by DotNetOpenId</title>
-</head>
-<body>
- <form id="form1" runat="server">
- <h1>
- OpenID Provider
- </h1>
+</asp:Content>
+
+<asp:Content runat="server" ContentPlaceHolderID="Main">
<h2>
- Provided by <a href="http://dotnetopenid.googlecode.com">DotNetOpenId</a>
+ Provider
</h2>
<p>
Welcome. This site doesn't do anything more than simple authentication of users.
@@ -59,6 +53,4 @@ </LoggedInTemplate>
</asp:LoginView>
<asp:LoginStatus runat="server" />
- </form>
-</body>
-</html>
+</asp:Content>
\ No newline at end of file diff --git a/samples/ProviderPortal/Global.asax.cs b/samples/ProviderPortal/Global.asax.cs index dd17d38..091ea56 100644 --- a/samples/ProviderPortal/Global.asax.cs +++ b/samples/ProviderPortal/Global.asax.cs @@ -1,14 +1,24 @@ using System;
using System.Collections.Specialized;
-using System.Diagnostics;
using System.IO;
+using System.Text;
using System.Web;
namespace ProviderPortal {
public class Global : System.Web.HttpApplication {
- public Global() {
- // since this is a sample, and will often be used with localhost
- DotNetOpenId.UntrustedWebRequest.WhitelistHosts.Add("localhost");
+ internal static StringBuilder LogMessages = new StringBuilder();
+
+ public static log4net.ILog Logger = log4net.LogManager.GetLogger(typeof(Global));
+
+ protected void Application_Start(object sender, EventArgs e) {
+ log4net.Config.XmlConfigurator.Configure();
+ Logger.Info("Sample starting...");
+ }
+
+ protected void Application_End(object sender, EventArgs e) {
+ Logger.Info("Sample shutting down...");
+ // this would be automatic, but in partial trust scenarios it is not.
+ log4net.LogManager.Shutdown();
}
string stripQueryString(Uri uri) {
@@ -25,17 +35,17 @@ namespace ProviderPortal { * There is only one rule currenty defined. It rewrites urls like: user/john ->user.aspx?username=john
*/
// System.Diagnostics.Debugger.Launch();
- Trace.TraceInformation("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url));
+ Logger.DebugFormat("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url));
if (Request.QueryString.Count > 0)
- Trace.TraceInformation("Querystring follows: \n{0}", ToString(Request.QueryString));
+ Logger.DebugFormat("Querystring follows: \n{0}", ToString(Request.QueryString));
if (Request.Form.Count > 0)
- Trace.TraceInformation("Posted form follows: \n{0}", ToString(Request.Form));
+ Logger.DebugFormat("Posted form follows: \n{0}", ToString(Request.Form));
URLRewriter.Process();
}
protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
- Trace.TraceInformation("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT");
+ Logger.DebugFormat("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT");
}
@@ -43,7 +53,7 @@ namespace ProviderPortal { }
protected void Application_Error(Object sender, EventArgs e) {
- Trace.TraceError("An unhandled exception was raised. Details follow: {0}",
+ Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}",
HttpContext.Current.Server.GetLastError());
}
diff --git a/samples/ProviderPortal/ProfileFields.ascx.cs b/samples/ProviderPortal/ProfileFields.ascx.cs index f898227..00f1834 100644 --- a/samples/ProviderPortal/ProfileFields.ascx.cs +++ b/samples/ProviderPortal/ProfileFields.ascx.cs @@ -97,31 +97,32 @@ public partial class ProfileFields : System.Web.UI.UserControl { }
}
- public ClaimsResponse OpenIdProfileFields {
- get {
- ClaimsResponse fields = new ClaimsResponse();
- fields.BirthDate = DateOfBirth;
- fields.Country = countryDropdownList.SelectedValue;
- fields.Email = emailTextBox.Text;
- fields.FullName = fullnameTextBox.Text;
- fields.Gender = Gender;
- fields.Language = languageDropdownList.SelectedValue;
- fields.Nickname = nicknameTextBox.Text;
- fields.PostalCode = postcodeTextBox.Text;
- fields.TimeZone = timezoneDropdownList.SelectedValue;
- return fields;
- }
- set {
- DateOfBirth = value.BirthDate;
- countryDropdownList.SelectedValue = value.Country;
- emailTextBox.Text = value.Email;
- fullnameTextBox.Text = value.FullName;
- Gender = value.Gender;
- languageDropdownList.SelectedValue = value.Language;
- nicknameTextBox.Text = value.Nickname;
- postcodeTextBox.Text = value.PostalCode;
- timezoneDropdownList.SelectedValue = value.TimeZone;
- }
+ public ClaimsResponse GetOpenIdProfileFields(ClaimsRequest request) {
+ if (request == null) throw new ArgumentNullException("request");
+ ClaimsResponse fields = request.CreateResponse();
+ fields.BirthDate = DateOfBirth;
+ fields.Country = countryDropdownList.SelectedValue;
+ fields.Email = emailTextBox.Text;
+ fields.FullName = fullnameTextBox.Text;
+ fields.Gender = Gender;
+ fields.Language = languageDropdownList.SelectedValue;
+ fields.Nickname = nicknameTextBox.Text;
+ fields.PostalCode = postcodeTextBox.Text;
+ fields.TimeZone = timezoneDropdownList.SelectedValue;
+ return fields;
+ }
+
+ public void SetOpenIdProfileFields(ClaimsResponse value) {
+ if (value == null) throw new ArgumentNullException("value");
+ DateOfBirth = value.BirthDate;
+ countryDropdownList.SelectedValue = value.Country;
+ emailTextBox.Text = value.Email;
+ fullnameTextBox.Text = value.FullName;
+ Gender = value.Gender;
+ languageDropdownList.SelectedValue = value.Language;
+ nicknameTextBox.Text = value.Nickname;
+ postcodeTextBox.Text = value.PostalCode;
+ timezoneDropdownList.SelectedValue = value.TimeZone;
}
}
diff --git a/samples/ProviderPortal/Provider.ashx b/samples/ProviderPortal/Provider.ashx new file mode 100644 index 0000000..27475cc --- /dev/null +++ b/samples/ProviderPortal/Provider.ashx @@ -0,0 +1 @@ +<%@ WebHandler Language="C#" CodeBehind="Provider.ashx.cs" Class="ProviderPortal.Provider" %>
diff --git a/samples/ProviderPortal/Provider.ashx.cs b/samples/ProviderPortal/Provider.ashx.cs new file mode 100644 index 0000000..ca1cc05 --- /dev/null +++ b/samples/ProviderPortal/Provider.ashx.cs @@ -0,0 +1,56 @@ +using System.Web;
+using System.Web.SessionState;
+using DotNetOpenId.Provider;
+
+namespace ProviderPortal {
+ /// <summary>
+ /// A fast OpenID message handler that responds to OpenID messages
+ /// directed at the Provider.
+ /// </summary>
+ /// <remarks>
+ /// This performs the same function as server.aspx, which uses the ProviderEndpoint
+ /// control to reduce the amount of source code in the web site. A typical Provider
+ /// site will have EITHER this .ashx handler OR the .aspx page -- NOT both.
+ /// </remarks>
+ public class Provider : IHttpHandler, IRequiresSessionState {
+ public void ProcessRequest(HttpContext context) {
+ OpenIdProvider provider = new OpenIdProvider();
+ if (provider.Request != null) {
+ // Some OpenID requests are automatable and can be responded to immediately.
+ if (!provider.Request.IsResponseReady) {
+ // But authentication requests cannot be responded to until something on
+ // this site decides whether to approve or disapprove the authentication.
+ var idrequest = (IAuthenticationRequest)provider.Request;
+ // We store the authentication request in the user's session so that
+ // redirects and user prompts can appear and eventually some page can decide
+ // to respond to the OpenID authentication request either affirmatively or
+ // negatively.
+ ProviderEndpoint.PendingAuthenticationRequest = idrequest;
+ // We delegate that approval process to our utility method that we share
+ // with our other Provider sample page server.aspx.
+ Util.ProcessAuthenticationChallenge(idrequest);
+ // As part of authentication approval, the user may need to authenticate
+ // to this Provider and/or decide whether to allow the requesting RP site
+ // to log this user in. If any UI needs to be presented to the user,
+ // the previous call to ProcessAuthenticationChallenge MAY not return
+ // due to a redirect to some ASPX page.
+ } else {
+ // Some other automatable OpenID request is coming down, so clear
+ // any previously session stored authentication request that might be
+ // stored for this user.
+ ProviderEndpoint.PendingAuthenticationRequest = null;
+ }
+ // Whether this was an automated message or an authentication message,
+ // if there is a response ready to send back immediately, do so.
+ if (provider.Request.IsResponseReady) {
+ provider.Request.Response.Send();
+ ProviderEndpoint.PendingAuthenticationRequest = null;
+ }
+ }
+ }
+
+ public bool IsReusable {
+ get { return true; }
+ }
+ }
+}
diff --git a/samples/ProviderPortal/ProviderPortal.csproj b/samples/ProviderPortal/ProviderPortal.csproj index 25e9946..835d92d 100644 --- a/samples/ProviderPortal/ProviderPortal.csproj +++ b/samples/ProviderPortal/ProviderPortal.csproj @@ -2,7 +2,7 @@ <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2A59DE0A-B76A-4B42-9A33-04D34548353D}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
@@ -17,7 +17,7 @@ <DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
- <DefineConstants>TRACE;DEBUG</DefineConstants>
+ <DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@@ -30,6 +30,10 @@ <WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\log4net.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
@@ -54,7 +58,14 @@ <Content Include="user_xrds.aspx" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Code\CustomStore.cs" />
+ <Compile Include="Code\CustomStoreDataSet.Designer.cs">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ </Compile>
<Compile Include="Code\ReadOnlyXmlMembershipProvider.cs" />
+ <Compile Include="Code\TracePageAppender.cs" />
<Compile Include="Code\URLRewriter.cs" />
<Compile Include="Code\Util.cs" />
<Compile Include="decide.aspx.cs">
@@ -82,6 +93,9 @@ <DependentUpon>ProfileFields.ascx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Provider.ashx.cs">
+ <DependentUpon>Provider.ashx</DependentUpon>
+ </Compile>
<Compile Include="server.aspx.cs">
<DependentUpon>server.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -89,6 +103,13 @@ <Compile Include="server.aspx.designer.cs">
<DependentUpon>server.aspx</DependentUpon>
</Compile>
+ <Compile Include="TracePage.aspx.cs">
+ <DependentUpon>TracePage.aspx</DependentUpon>
+ <SubType>ASPXCodeBehind</SubType>
+ </Compile>
+ <Compile Include="TracePage.aspx.designer.cs">
+ <DependentUpon>TracePage.aspx</DependentUpon>
+ </Compile>
<Compile Include="user.aspx.cs">
<DependentUpon>user.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -104,6 +125,27 @@ <Private>True</Private>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Content Include="favicon.ico" />
+ <Content Include="images\dotnetopenid_tiny.gif" />
+ <Content Include="Site.Master" />
+ <Content Include="styles.css" />
+ <Content Include="TracePage.aspx" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Code\CustomStoreDataSet.xsc">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ </None>
+ <None Include="Code\CustomStoreDataSet.xsd">
+ <Generator>MSDataSetGenerator</Generator>
+ <LastGenOutput>CustomStoreDataSet.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </None>
+ <None Include="Code\CustomStoreDataSet.xss">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ </None>
+ <Content Include="Provider.ashx" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -124,6 +166,9 @@ <IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
+ <UseCustomServer>False</UseCustomServer>
+ <CustomServerUrl>
+ </CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
diff --git a/samples/ProviderPortal/Site.Master b/samples/ProviderPortal/Site.Master new file mode 100644 index 0000000..df23ee5 --- /dev/null +++ b/samples/ProviderPortal/Site.Master @@ -0,0 +1,20 @@ +<%@ Master Language="C#" AutoEventWireup="true" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head id="Head1" runat="server">
+ <title>OpenID Provider, by DotNetOpenId</title>
+ <link href="/styles.css" rel="stylesheet" type="text/css" />
+ <asp:ContentPlaceHolder ID="head" runat="server" />
+</head>
+<body>
+ <form id="form1" runat="server">
+ <div><a href="http://dotnetopenid.googlecode.com">
+ <img runat="server" src="~/images/dotnetopenid_tiny.gif" title="Jump to the project web site."
+ alt="DotNetOpenId" border='0' /></a> </div>
+ <div>
+ <asp:ContentPlaceHolder ID="Main" runat="server" />
+ </div>
+ </form>
+</body>
+</html>
diff --git a/samples/ProviderPortal/TracePage.aspx b/samples/ProviderPortal/TracePage.aspx new file mode 100644 index 0000000..34eff79 --- /dev/null +++ b/samples/ProviderPortal/TracePage.aspx @@ -0,0 +1,16 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TracePage.aspx.cs" Inherits="ProviderPortal.TracePage" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+ <title></title>
+</head>
+<body>
+ <form id="form1" runat="server">
+ <p align="right">
+ <asp:Button runat="server" Text="Clear log" ID="clearLogButton" OnClick="clearLogButton_Click" />
+ </p>
+ <pre><asp:PlaceHolder runat="server" ID="placeHolder1" /></pre>
+ </form>
+</body>
+</html>
diff --git a/samples/ProviderPortal/TracePage.aspx.cs b/samples/ProviderPortal/TracePage.aspx.cs new file mode 100644 index 0000000..6360289 --- /dev/null +++ b/samples/ProviderPortal/TracePage.aspx.cs @@ -0,0 +1,19 @@ +using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace ProviderPortal {
+ public partial class TracePage : System.Web.UI.Page {
+ protected void Page_Load(object sender, EventArgs e) {
+ placeHolder1.Controls.Add(new Label { Text = Global.LogMessages.ToString() });
+ }
+
+ protected void clearLogButton_Click(object sender, EventArgs e) {
+ Global.LogMessages.Length = 0;
+ // clear the page immediately, and allow for F5 without a Postback warning.
+ Response.Redirect(Request.Url.AbsoluteUri);
+ }
+ }
+}
\ No newline at end of file diff --git a/samples/ProviderPortal/TracePage.aspx.designer.cs b/samples/ProviderPortal/TracePage.aspx.designer.cs new file mode 100644 index 0000000..34daa82 --- /dev/null +++ b/samples/ProviderPortal/TracePage.aspx.designer.cs @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.3053
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace ProviderPortal {
+
+
+ public partial class TracePage {
+
+ /// <summary>
+ /// form1 control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.HtmlControls.HtmlForm form1;
+
+ /// <summary>
+ /// clearLogButton 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.Button clearLogButton;
+
+ /// <summary>
+ /// placeHolder1 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.PlaceHolder placeHolder1;
+ }
+}
diff --git a/samples/ProviderPortal/Web.config b/samples/ProviderPortal/Web.config index daf5394..1c4649e 100644 --- a/samples/ProviderPortal/Web.config +++ b/samples/ProviderPortal/Web.config @@ -9,19 +9,37 @@ -->
<configuration>
<configSections>
- <section name="urlrewrites" type="ProviderPortal.URLRewriter"/>
+ <section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <section name="urlrewrites" type="ProviderPortal.URLRewriter" requirePermission="false"/>
+ <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" requirePermission="false" />
+ <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>
</configSections>
- <system.diagnostics>
- <switches>
- <add name="OpenID" value="4"/>
- </switches>
- <trace autoflush="true" indentsize="4">
- <listeners>
- <add name="fileLogger" type="System.Diagnostics.TextWriterTraceListener"
- initializeData="openidServerTrace.txt"/>
- </listeners>
- </trace>
- </system.diagnostics>
+
+ <!-- this is an optional configuration section where aspects of dotnetopenid can be customized -->
+ <dotNetOpenId>
+ <provider>
+ <!-- Uncomment the following to activate the sample custom store. -->
+ <!--<store type="ProviderPortal.Code.CustomStore, ProviderPortal" />-->
+ </provider>
+ <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>
+
<connectionStrings/>
<!--
Original version created by Richard Birkby (2002-02-22, http://www.codeproject.com/aspnet/URLRewriter.asp)
@@ -61,9 +79,9 @@ <!-- Trust level discussion:
Full: everything works
High: TRACE compilation symbol must NOT be defined
- Medium/Low: doesn't work on default machine.config. ConfigurationPermission is denied (why is it needed?)
+ Medium/Low: doesn't work on default machine.config, because WebPermission.Connect is denied.
-->
- <trust level="Full" originUrl=""/>
+ <trust level="High" originUrl=""/>
</system.web>
<location path="decide.aspx">
<system.web>
@@ -72,4 +90,34 @@ </authorization>
</system.web>
</location>
+
+ <!-- log4net is a 3rd party (free) logger library that dotnetopenid will use if present but does not require. -->
+ <log4net>
+ <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
+ <file value="Provider.log" />
+ <appendToFile value="true" />
+ <rollingStyle value="Size" />
+ <maxSizeRollBackups value="10" />
+ <maximumFileSize value="100KB" />
+ <staticLogFileName value="true" />
+ <layout type="log4net.Layout.PatternLayout">
+ <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" />
+ </layout>
+ </appender>
+ <appender name="TracePageAppender" type="ProviderPortal.Code.TracePageAppender, ProviderPortal">
+ <layout type="log4net.Layout.PatternLayout">
+ <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" />
+ </layout>
+ </appender>
+ <!-- Setup the root category, add the appenders and set the default level -->
+ <root>
+ <level value="INFO" />
+ <!--<appender-ref ref="RollingFileAppender" />-->
+ <appender-ref ref="TracePageAppender" />
+ </root>
+ <!-- Specify the level for some specific categories -->
+ <logger name="DotNetOpenId">
+ <level value="ALL" />
+ </logger>
+ </log4net>
</configuration>
diff --git a/samples/ProviderPortal/decide.aspx b/samples/ProviderPortal/decide.aspx index 31851ee..bd3f817 100644 --- a/samples/ProviderPortal/decide.aspx +++ b/samples/ProviderPortal/decide.aspx @@ -1,12 +1,7 @@ -<%@ Page Language="C#" AutoEventWireup="true" Inherits="decide" CodeBehind="decide.aspx.cs" %>
+<%@ Page Language="C#" AutoEventWireup="true" Inherits="decide" CodeBehind="decide.aspx.cs" MasterPageFile="~/Site.Master" %>
<%@ Register Src="ProfileFields.ascx" TagName="ProfileFields" TagPrefix="uc1" %>
-<html>
-<head>
- <title>Approve OpenID request?</title>
-</head>
-<body>
- <form id="Form1" runat="server">
+<asp:Content runat="server" ContentPlaceHolderID="Main">
<p>
A site has asked to authenticate that you own the identifier below. You should
only do this if you wish to log in to the site given by the Realm.</p>
@@ -36,6 +31,4 @@ <uc1:ProfileFields ID="profileFields" runat="server" Visible="false" />
<asp:Button ID="yes_button" OnClick="Yes_Click" Text=" yes " runat="Server" />
<asp:Button ID="no_button" OnClick="No_Click" Text=" no " runat="Server" />
- </form>
-</body>
-</html>
+</asp:Content>
\ No newline at end of file diff --git a/samples/ProviderPortal/decide.aspx.cs b/samples/ProviderPortal/decide.aspx.cs index 882c320..2c563a6 100644 --- a/samples/ProviderPortal/decide.aspx.cs +++ b/samples/ProviderPortal/decide.aspx.cs @@ -4,6 +4,7 @@ using System.Web.Security; using System.Web.UI;
using DotNetOpenId.Extensions.SimpleRegistration;
using DotNetOpenId.Provider;
+using DotNetOpenId.Extensions.ProviderAuthenticationPolicy;
/// <summary>
/// Page for giving the user the option to continue or cancel out of authentication with a consumer.
@@ -23,16 +24,16 @@ public partial class decide : Page { realmLabel.Text = ProviderEndpoint.PendingAuthenticationRequest.Realm.ToString();
// check that the logged in user is the same as the user requesting authentication to the consumer. If not, then log them out.
- if (User.Identity.Name == Util.ExtractUserName(ProviderEndpoint.PendingAuthenticationRequest.LocalIdentifier)) {
+ if (String.Equals(User.Identity.Name, Util.ExtractUserName(ProviderEndpoint.PendingAuthenticationRequest.LocalIdentifier), StringComparison.OrdinalIgnoreCase)) {
// if simple registration fields were used, then prompt the user for them
var requestedFields = ProviderEndpoint.PendingAuthenticationRequest.GetExtension<ClaimsRequest>();
if (requestedFields != null) {
this.profileFields.Visible = true;
this.profileFields.SetRequiredFieldsFromRequest(requestedFields);
if (!IsPostBack) {
- this.profileFields.OpenIdProfileFields = new ClaimsResponse() {
- Email = Membership.GetUser().Email,
- };
+ var sregResponse = requestedFields.CreateResponse();
+ sregResponse.Email = Membership.GetUser().Email;
+ this.profileFields.SetOpenIdProfileFields(sregResponse);
}
}
} else {
@@ -42,8 +43,21 @@ public partial class decide : Page { }
protected void Yes_Click(Object sender, EventArgs e) {
+ var sregRequest = ProviderEndpoint.PendingAuthenticationRequest.GetExtension<ClaimsRequest>();
+ ClaimsResponse sregResponse = null;
+ if (sregRequest != null) {
+ sregResponse = profileFields.GetOpenIdProfileFields(sregRequest);
+ ProviderEndpoint.PendingAuthenticationRequest.AddResponseExtension(sregResponse);
+ }
+ var papeRequest = ProviderEndpoint.PendingAuthenticationRequest.GetExtension<PolicyRequest>();
+ PolicyResponse papeResponse = null;
+ if (papeRequest != null) {
+ papeResponse = new PolicyResponse();
+ papeResponse.NistAssuranceLevel = NistAssuranceLevel.InsufficientForLevel1;
+ ProviderEndpoint.PendingAuthenticationRequest.AddResponseExtension(papeResponse);
+ }
+
ProviderEndpoint.PendingAuthenticationRequest.IsAuthenticated = true;
- ProviderEndpoint.PendingAuthenticationRequest.AddResponseExtension(profileFields.OpenIdProfileFields);
Debug.Assert(ProviderEndpoint.PendingAuthenticationRequest.IsResponseReady);
ProviderEndpoint.PendingAuthenticationRequest.Response.Send();
ProviderEndpoint.PendingAuthenticationRequest = null;
diff --git a/samples/ProviderPortal/decide.aspx.designer.cs b/samples/ProviderPortal/decide.aspx.designer.cs index 46a5f6f..4b26c69 100644 --- a/samples/ProviderPortal/decide.aspx.designer.cs +++ b/samples/ProviderPortal/decide.aspx.designer.cs @@ -13,15 +13,6 @@ public partial class decide {
/// <summary>
- /// Form1 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.HtmlControls.HtmlForm Form1;
-
- /// <summary>
/// relyingPartyVerificationResultLabel control.
/// </summary>
/// <remarks>
diff --git a/samples/ProviderPortal/favicon.ico b/samples/ProviderPortal/favicon.ico Binary files differnew file mode 100644 index 0000000..beb3cb5 --- /dev/null +++ b/samples/ProviderPortal/favicon.ico diff --git a/samples/ProviderPortal/images/dotnetopenid_tiny.gif b/samples/ProviderPortal/images/dotnetopenid_tiny.gif Binary files differnew file mode 100644 index 0000000..c4ed4f5 --- /dev/null +++ b/samples/ProviderPortal/images/dotnetopenid_tiny.gif diff --git a/samples/ProviderPortal/login.aspx b/samples/ProviderPortal/login.aspx index 9b37600..e8bf67b 100644 --- a/samples/ProviderPortal/login.aspx +++ b/samples/ProviderPortal/login.aspx @@ -1,14 +1,5 @@ -<%@ Page Language="C#" AutoEventWireup="true" Inherits="login" CodeBehind="login.aspx.cs" %>
-
-<html>
-<head>
- <title>Login</title>
-</head>
-<body>
- <form id="Form1" runat="server">
- <h1>
- OpenID Provider Login
- </h1>
+<%@ Page Language="C#" AutoEventWireup="true" Inherits="login" CodeBehind="login.aspx.cs" MasterPageFile="~/Site.Master" %>
+<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main">
<p>
Usernames are defined in the App_Data\Users.xml file.
</p>
@@ -23,6 +14,4 @@ <tr><td>bob3</td><td>test</td></tr>
<tr><td>bob4</td><td>test</td></tr>
</table>
- </form>
-</body>
-</html>
+</asp:Content>
\ No newline at end of file diff --git a/samples/ProviderPortal/login.aspx.designer.cs b/samples/ProviderPortal/login.aspx.designer.cs index e498e6a..0a6a122 100644 --- a/samples/ProviderPortal/login.aspx.designer.cs +++ b/samples/ProviderPortal/login.aspx.designer.cs @@ -13,15 +13,6 @@ public partial class login {
/// <summary>
- /// Form1 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.HtmlControls.HtmlForm Form1;
-
- /// <summary>
/// login1 control.
/// </summary>
/// <remarks>
diff --git a/samples/ProviderPortal/op_xrds.aspx b/samples/ProviderPortal/op_xrds.aspx index 7d0ca2c..b906bfe 100644 --- a/samples/ProviderPortal/op_xrds.aspx +++ b/samples/ProviderPortal/op_xrds.aspx @@ -12,7 +12,7 @@ This XRDS doc is discovered via the user.aspx page. <XRD> <Service priority="10"> <Type>http://specs.openid.net/auth/2.0/server</Type> - <Type>http://openid.net/sreg/1.0</Type> + <Type>http://openid.net/extensions/sreg/1.1</Type> <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%></URI> </Service> </XRD> diff --git a/samples/ProviderPortal/server.aspx b/samples/ProviderPortal/server.aspx index 318df4a..e67a7ba 100644 --- a/samples/ProviderPortal/server.aspx +++ b/samples/ProviderPortal/server.aspx @@ -7,6 +7,13 @@ </head>
<body>
<form runat='server'>
+ <%-- This page provides an example of how to use the ProviderEndpoint control on an ASPX page
+ to host an OpenID Provider. Alternatively for greater performance an .ashx file can be used.
+ See Provider.ashx for an example. A typical web site will NOT use both .ashx and .aspx
+ provider endpoints.
+ This server.aspx page is the default provider endpoint to use. To switch to the .ashx handler,
+ change the user_xrds.aspx and op_xrds.aspx files to point to provider.ashx instead of server.aspx.
+ --%>
<openid:ProviderEndpoint runat="server" OnAuthenticationChallenge="provider_AuthenticationChallenge" />
<p>
<asp:Label ID="serverEndpointUrl" runat="server" EnableViewState="false" />
diff --git a/samples/ProviderPortal/server.aspx.cs b/samples/ProviderPortal/server.aspx.cs index 8589f40..fbc9a6c 100644 --- a/samples/ProviderPortal/server.aspx.cs +++ b/samples/ProviderPortal/server.aspx.cs @@ -10,24 +10,6 @@ public partial class server : System.Web.UI.Page { serverEndpointUrl.Text = Request.Url.ToString();
}
protected void provider_AuthenticationChallenge(object sender, AuthenticationChallengeEventArgs e) {
- var idrequest = e.Request;
- if (idrequest.Immediate) {
- if (idrequest.IsDirectedIdentity) {
- if (User.Identity.IsAuthenticated) {
- idrequest.LocalIdentifier = Util.BuildIdentityUrl();
- idrequest.IsAuthenticated = true;
- } else {
- idrequest.IsAuthenticated = false;
- }
- } else {
- string userOwningOpenIdUrl = Util.ExtractUserName(idrequest.LocalIdentifier);
- // NOTE: in a production provider site, you may want to only
- // respond affirmatively if the user has already authorized this consumer
- // to know the answer.
- idrequest.IsAuthenticated = userOwningOpenIdUrl == User.Identity.Name;
- }
- } else {
- Response.Redirect("~/decide.aspx", true); // This ends processing on this page.
- }
+ Util.ProcessAuthenticationChallenge(e.Request);
}
}
\ No newline at end of file diff --git a/samples/ProviderPortal/server.aspx.designer.cs b/samples/ProviderPortal/server.aspx.designer.cs index 16dd628..90203b1 100644 --- a/samples/ProviderPortal/server.aspx.designer.cs +++ b/samples/ProviderPortal/server.aspx.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.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
diff --git a/samples/ProviderPortal/styles.css b/samples/ProviderPortal/styles.css new file mode 100644 index 0000000..62605db --- /dev/null +++ b/samples/ProviderPortal/styles.css @@ -0,0 +1,10 @@ +h2
+{
+ font-style: italic;
+}
+
+body
+{
+ font-family: Cambria, Arial, Times New Roman;
+ font-size: 12pt;
+}
\ No newline at end of file diff --git a/samples/ProviderPortal/user.aspx b/samples/ProviderPortal/user.aspx index 581e30f..fc3716f 100644 --- a/samples/ProviderPortal/user.aspx +++ b/samples/ProviderPortal/user.aspx @@ -1,18 +1,17 @@ -<%@ Page Language="C#" AutoEventWireup="true" Inherits="user" CodeBehind="user.aspx.cs" %>
+<%@ Page Language="C#" AutoEventWireup="true" Inherits="user" CodeBehind="user.aspx.cs" MasterPageFile="~/Site.Master" %>
<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId.Provider" TagPrefix="openid" %>
-<html>
-<head>
+<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="head">
<openid:IdentityEndpoint ID="IdentityEndpoint20" runat="server" ProviderEndpointUrl="~/Server.aspx"
- XrdsUrl="~/user_xrds.aspx" ProviderVersion="V20" />
+ XrdsUrl="~/user_xrds.aspx" ProviderVersion="V20"
+ AutoNormalizeRequest="true" OnNormalizeUri="IdentityEndpoint20_NormalizeUri" />
<!-- and for backward compatibility with OpenID 1.x RPs... -->
<openid:IdentityEndpoint ID="IdentityEndpoint11" runat="server" ProviderEndpointUrl="~/Server.aspx"
ProviderVersion="V11" />
-</head>
-<body>
+</asp:Content>
+<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main">
<p>
OpenID identity page for
<asp:Label runat="server" ID="usernameLabel" EnableViewState="false" />
</p>
-</body>
-</html>
+</asp:Content>
\ No newline at end of file diff --git a/samples/ProviderPortal/user.aspx.cs b/samples/ProviderPortal/user.aspx.cs index 5400200..744cae5 100644 --- a/samples/ProviderPortal/user.aspx.cs +++ b/samples/ProviderPortal/user.aspx.cs @@ -1,5 +1,5 @@ using System;
-using System.Configuration;
+using DotNetOpenId.Provider;
/// <summary>
/// This page is a required as part of the service discovery phase of the openid protocol (step 1).
@@ -18,4 +18,15 @@ public partial class user : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {
usernameLabel.Text = Request.QueryString["username"];
}
+
+ protected void IdentityEndpoint20_NormalizeUri(object sender, IdentityEndpointNormalizationEventArgs e) {
+ // This sample Provider has a custom policy for normalizing URIs, which is that the whole
+ // path of the URI be lowercase except for the first letter of the username.
+ UriBuilder normalized = new UriBuilder(e.UserSuppliedIdentifier);
+ string username = Request.QueryString["username"].TrimEnd('/').ToLowerInvariant();
+ username = username.Substring(0, 1).ToUpperInvariant() + username.Substring(1);
+ normalized.Path = "/user/" + username;
+ normalized.Scheme = "http"; // for a real Provider, this should be HTTPS if supported.
+ e.NormalizedIdentifier = normalized.Uri;
+ }
}
diff --git a/samples/ProviderPortal/user_xrds.aspx b/samples/ProviderPortal/user_xrds.aspx index 4f3e446..56b1244 100644 --- a/samples/ProviderPortal/user_xrds.aspx +++ b/samples/ProviderPortal/user_xrds.aspx @@ -12,12 +12,12 @@ This XRDS doc is discovered via the user.aspx page. <XRD> <Service priority="10"> <Type>http://specs.openid.net/auth/2.0/signon</Type> - <Type>http://openid.net/sreg/1.0</Type> + <Type>http://openid.net/extensions/sreg/1.1</Type> <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%></URI> </Service> <Service priority="20"> <Type>http://openid.net/signon/1.0</Type> - <Type>http://openid.net/sreg/1.0</Type> + <Type>http://openid.net/extensions/sreg/1.1</Type> <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%></URI> </Service> </XRD> diff --git a/samples/RelyingPartyCustomStore/.gitignore b/samples/RelyingPartyCustomStore/.gitignore deleted file mode 100644 index 0986274..0000000 --- a/samples/RelyingPartyCustomStore/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -Bin -obj -*Trace.txt -*.user diff --git a/samples/RelyingPartyCustomStore/Default.aspx b/samples/RelyingPartyCustomStore/Default.aspx deleted file mode 100644 index 445b3a9..0000000 --- a/samples/RelyingPartyCustomStore/Default.aspx +++ /dev/null @@ -1,30 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" %>
-
-<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId" TagPrefix="openid" %>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head id="Head1" runat="server">
- <title>OpenID Relying Party, by DotNetOpenId</title>
- <openid:XrdsPublisher runat="server" XrdsUrl="~/xrds.aspx" />
-</head>
-<body>
- <form id="form1" runat="server">
- <h1>
- OpenID Relying Party, with custom store
- </h1>
- <h2>
- Provided by <a href="http://dotnetopenid.googlecode.com">DotNetOpenId</a>
- </h2>
- <p>
- This sample implements a custom store for associations and nonces, which can be useful
- when deploying a relying party site on a web farm.
- </p>
- <p>
- Visit the
- <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/MembersOnly/Default.aspx"
- Text="Members Only" />
- area. (This will trigger a login demo).
- </p>
- </form>
-</body>
-</html>
diff --git a/samples/RelyingPartyCustomStore/Global.asax b/samples/RelyingPartyCustomStore/Global.asax deleted file mode 100644 index a00a077..0000000 --- a/samples/RelyingPartyCustomStore/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="RelyingPartyCustomStore.Global" Language="C#" %>
diff --git a/samples/RelyingPartyCustomStore/Global.asax.cs b/samples/RelyingPartyCustomStore/Global.asax.cs deleted file mode 100644 index b8b7593..0000000 --- a/samples/RelyingPartyCustomStore/Global.asax.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System;
-using System.Collections;
-using System.Configuration;
-using System.Data;
-using System.Web;
-using System.Web.Security;
-using System.Web.SessionState;
-
-namespace RelyingPartyCustomStore {
- public class Global : System.Web.HttpApplication {
- public Global() {
- // since this is a sample, and will often be used with localhost
- DotNetOpenId.UntrustedWebRequest.WhitelistHosts.Add("localhost");
- }
- }
-}
\ No newline at end of file diff --git a/samples/RelyingPartyCustomStore/MembersOnly/Default.aspx b/samples/RelyingPartyCustomStore/MembersOnly/Default.aspx deleted file mode 100644 index ae974cc..0000000 --- a/samples/RelyingPartyCustomStore/MembersOnly/Default.aspx +++ /dev/null @@ -1,21 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" %>
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head runat="server">
- <title>Welcome OpenID User!</title>
-</head>
-<body>
- <form id="form1" runat="server">
- <h1>
- Members Only Area
- </h1>
- <p>
- Congratulations, <b>
- <asp:LoginName ID="LoginName1" runat="server" />
- </b>. You have completed the OpenID login process.
- </p>
- <asp:LoginStatus ID="LoginStatus1" runat="server" />
- </form>
-</body>
-</html>
diff --git a/samples/RelyingPartyCustomStore/MembersOnly/Web.config b/samples/RelyingPartyCustomStore/MembersOnly/Web.config deleted file mode 100644 index 7fbfa59..0000000 --- a/samples/RelyingPartyCustomStore/MembersOnly/Web.config +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0"?>
-<!--
- Note: As an alternative to hand editing this file you can use the
- web admin tool to configure settings for your application. Use
- the Website->Asp.Net Configuration option in Visual Studio.
- A full list of settings and comments can be found in
- machine.config.comments usually located in
- \Windows\Microsoft.Net\Framework\v2.x\Config
--->
-<configuration>
- <appSettings/>
- <connectionStrings/>
- <system.web>
- <authorization>
- <deny users="?"/>
- </authorization>
- </system.web>
-</configuration>
diff --git a/samples/RelyingPartyCustomStore/Properties/AssemblyInfo.cs b/samples/RelyingPartyCustomStore/Properties/AssemblyInfo.cs deleted file mode 100644 index 7ff8c9b..0000000 --- a/samples/RelyingPartyCustomStore/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("RelyingPartyCustomStore")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("RelyingPartyCustomStore")]
-[assembly: AssemblyCopyright("Copyright © 2008")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/samples/RelyingPartyCustomStore/RelyingPartyCustomStore.csproj b/samples/RelyingPartyCustomStore/RelyingPartyCustomStore.csproj deleted file mode 100644 index 2519ec1..0000000 --- a/samples/RelyingPartyCustomStore/RelyingPartyCustomStore.csproj +++ /dev/null @@ -1,116 +0,0 @@ -<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{DB54DC19-BA56-4C22-A8A0-C49289EA4F53}</ProjectGuid>
- <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>RelyingPartyCustomStore</RootNamespace>
- <AssemblyName>RelyingPartyCustomStore</AssemblyName>
- <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Data" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Web" />
- <Reference Include="System.Xml" />
- <Reference Include="System.Configuration" />
- <Reference Include="System.Web.Services" />
- <Reference Include="System.EnterpriseServices" />
- <Reference Include="System.Web.Mobile" />
- </ItemGroup>
- <ItemGroup>
- <Content Include="Default.aspx" />
- <Content Include="login.aspx" />
- <Content Include="MembersOnly\Default.aspx" />
- <Content Include="Web.config" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="CustomStore.cs" />
- <Compile Include="CustomStoreDataSet.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
- </Compile>
- <Compile Include="Global.asax.cs">
- <DependentUpon>Global.asax</DependentUpon>
- </Compile>
- <Compile Include="login.aspx.cs">
- <DependentUpon>login.aspx</DependentUpon>
- <SubType>ASPXCodeBehind</SubType>
- </Compile>
- <Compile Include="login.aspx.designer.cs">
- <DependentUpon>login.aspx</DependentUpon>
- </Compile>
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\src\DotNetOpenId\DotNetOpenId.csproj">
- <Project>{5D6EDC86-F5B2-4786-8376-4E7C24C63D39}</Project>
- <Name>DotNetOpenId</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <Content Include="Global.asax" />
- <Content Include="MembersOnly\Web.config" />
- </ItemGroup>
- <ItemGroup>
- <None Include="CustomStoreDataSet.xsc">
- <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
- </None>
- <None Include="CustomStoreDataSet.xsd">
- <SubType>Designer</SubType>
- <Generator>MSDataSetGenerator</Generator>
- <LastGenOutput>CustomStoreDataSet.Designer.cs</LastGenOutput>
- </None>
- <None Include="CustomStoreDataSet.xss">
- <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
- </None>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
- <ProjectExtensions>
- <VisualStudio>
- <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
- <WebProjectProperties>
- <UseIIS>False</UseIIS>
- <AutoAssignPort>True</AutoAssignPort>
- <DevelopmentServerPort>6945</DevelopmentServerPort>
- <DevelopmentServerVPath>/</DevelopmentServerVPath>
- <IISUrl>
- </IISUrl>
- <NTLMAuthentication>False</NTLMAuthentication>
- <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
- </WebProjectProperties>
- </FlavorProperties>
- </VisualStudio>
- </ProjectExtensions>
-</Project>
\ No newline at end of file diff --git a/samples/RelyingPartyCustomStore/Web.config b/samples/RelyingPartyCustomStore/Web.config deleted file mode 100644 index d5574f5..0000000 --- a/samples/RelyingPartyCustomStore/Web.config +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0"?>
-<configuration>
- <system.web>
- <compilation debug="true"/>
- <customErrors mode="RemoteOnly"/>
- <authentication mode="Forms">
- <forms name="RelyingPartyCustomStoreSession"/> <!-- named cookie prevents conflicts with other samples -->
- </authentication>
- <trace enabled="false" writeToDiagnosticsTrace="true" />
- <!-- Trust level discussion:
- Full: everything works
- High: TRACE compilation symbol must NOT be defined
- Medium/Low: doesn't work on default machine.config, because WebPermission.Connect is denied.
- -->
- <trust level="Full" originUrl=""/>
- </system.web>
- <system.diagnostics>
- <switches>
- <!-- Disabled tracing because it breaks WebResource.axd, which downloads the OpenID logo. -->
- <!--<add name="OpenID" value="4"/>-->
- </switches>
- <trace autoflush="true" indentsize="4">
- <listeners>
- <add name="fileLogger" type="System.Diagnostics.TextWriterTraceListener"
- initializeData="openidConsumerTrace.txt" traceOutputOptions="None"/>
- </listeners>
- </trace>
- </system.diagnostics>
-</configuration>
diff --git a/samples/RelyingPartyCustomStore/login.aspx b/samples/RelyingPartyCustomStore/login.aspx deleted file mode 100644 index d04ec0a..0000000 --- a/samples/RelyingPartyCustomStore/login.aspx +++ /dev/null @@ -1,24 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="login.aspx.cs" Inherits="login" ValidateRequest="false" %>
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <title>Login</title>
-</head>
-<body>
- <form id="Form1" runat="server">
- <h2>
- Login Page
- </h2>
- <asp:Label ID="Label1" runat="server" Text="OpenID Login" />
- <asp:TextBox ID="openIdBox" runat="server" />
- <asp:Button ID="loginButton" runat="server" Text="Login"
- onclick="loginButton_Click" />
- <br />
- <asp:Label ID="loginFailedLabel" runat="server" EnableViewState="False" Text="Login failed"
- Visible="False" />
- <asp:Label ID="loginCanceledLabel" runat="server" EnableViewState="False" Text="Login canceled"
- Visible="False" />
- </form>
-</body>
-</html>
diff --git a/samples/RelyingPartyCustomStore/login.aspx.cs b/samples/RelyingPartyCustomStore/login.aspx.cs deleted file mode 100644 index f7b1088..0000000 --- a/samples/RelyingPartyCustomStore/login.aspx.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System;
-using System.Web.UI;
-using DotNetOpenId.RelyingParty;
-using System.Web.Security;
-using RelyingPartyCustomStore;
-
-public partial class login : System.Web.UI.Page {
- protected void Page_Load(object sender, EventArgs e) {
- openIdBox.Focus();
-
- OpenIdRelyingParty rp = new OpenIdRelyingParty(CustomStore.Instance, Request.Url,
- Request.HttpMethod == "GET" ? Request.QueryString : Request.Form);
- if (rp.Response != null) {
- switch (rp.Response.Status) {
- case AuthenticationStatus.Authenticated:
- FormsAuthentication.RedirectFromLoginPage(rp.Response.ClaimedIdentifier, false);
- break;
- case AuthenticationStatus.Canceled:
- loginCanceledLabel.Visible = true;
- break;
- case AuthenticationStatus.Failed:
- loginFailedLabel.Visible = true;
- break;
- }
- }
- }
-
- protected void loginButton_Click(object sender, EventArgs e) {
- OpenIdRelyingParty rp = new OpenIdRelyingParty(CustomStore.Instance, Request.Url,
- Request.HttpMethod == "GET" ? Request.QueryString : Request.Form);
- rp.CreateRequest(openIdBox.Text).RedirectToProvider();
- }
-}
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"/>
diff --git a/samples/RelyingPartyPortal/.gitignore b/samples/RelyingPartyPortal/.gitignore index 0986274..b086a60 100644 --- a/samples/RelyingPartyPortal/.gitignore +++ b/samples/RelyingPartyPortal/.gitignore @@ -1,4 +1,5 @@ Bin obj -*Trace.txt *.user +*.log +StyleCop.Cache diff --git a/samples/RelyingPartyCustomStore/CustomStore.cs b/samples/RelyingPartyPortal/Code/CustomStore.cs index b0e3700..0083152 100644 --- a/samples/RelyingPartyCustomStore/CustomStore.cs +++ b/samples/RelyingPartyPortal/Code/CustomStore.cs @@ -5,7 +5,7 @@ using System.Security.Cryptography; using DotNetOpenId;
using DotNetOpenId.RelyingParty;
-namespace RelyingPartyCustomStore {
+namespace ConsumerPortal.Code {
/// <summary>
/// This custom store serializes all elements to demonstrate peristent and/or shared storage.
/// This is common in a web farm, for example.
@@ -17,8 +17,7 @@ namespace RelyingPartyCustomStore { /// that using a database is possible.
/// </remarks>
public class CustomStore : IRelyingPartyApplicationStore {
- public static CustomStore Instance = new CustomStore();
- public CustomStoreDataSet dataSet = new CustomStoreDataSet();
+ static CustomStoreDataSet dataSet = new CustomStoreDataSet();
#region IAssociationStore<Uri> Members
@@ -66,7 +65,7 @@ namespace RelyingPartyCustomStore { #region INonceStore Members
- byte[] secretSigningKey;
+ static byte[] secretSigningKey;
public byte[] SecretSigningKey {
get {
if (secretSigningKey == null) {
@@ -75,7 +74,7 @@ namespace RelyingPartyCustomStore { // initialize in a local variable before setting in field for thread safety.
byte[] auth_key = new byte[64];
new RNGCryptoServiceProvider().GetBytes(auth_key);
- this.secretSigningKey = auth_key;
+ CustomStore.secretSigningKey = auth_key;
}
}
}
@@ -115,6 +114,5 @@ namespace RelyingPartyCustomStore { for (int i = view.Count - 1; i >= 0; i--)
view.Delete(i);
}
-
}
}
diff --git a/samples/RelyingPartyCustomStore/CustomStoreDataSet.Designer.cs b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.Designer.cs index b757e71..5b7c03e 100644 --- a/samples/RelyingPartyCustomStore/CustomStoreDataSet.Designer.cs +++ b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.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.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -10,7 +10,7 @@ #pragma warning disable 1591
-namespace RelyingPartyCustomStore {
+namespace ConsumerPortal.Code {
/// <summary>
diff --git a/samples/RelyingPartyPortal/Code/CustomStoreDataSet.cs b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.cs new file mode 100644 index 0000000..d53f870 --- /dev/null +++ b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.cs @@ -0,0 +1,6 @@ +namespace ConsumerPortal.Code {
+
+
+ public partial class CustomStoreDataSet {
+ }
+}
diff --git a/samples/RelyingPartyCustomStore/CustomStoreDataSet.xsc b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.xsc index 551fc56..551fc56 100644 --- a/samples/RelyingPartyCustomStore/CustomStoreDataSet.xsc +++ b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.xsc diff --git a/samples/RelyingPartyCustomStore/CustomStoreDataSet.xsd b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.xsd index 76b77aa..76b77aa 100644 --- a/samples/RelyingPartyCustomStore/CustomStoreDataSet.xsd +++ b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.xsd diff --git a/samples/RelyingPartyCustomStore/CustomStoreDataSet.xss b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.xss index fbe7113..fbe7113 100644 --- a/samples/RelyingPartyCustomStore/CustomStoreDataSet.xss +++ b/samples/RelyingPartyPortal/Code/CustomStoreDataSet.xss diff --git a/samples/RelyingPartyPortal/Code/State.cs b/samples/RelyingPartyPortal/Code/State.cs index 65e676c..141115f 100644 --- a/samples/RelyingPartyPortal/Code/State.cs +++ b/samples/RelyingPartyPortal/Code/State.cs @@ -1,34 +1,27 @@ -using System;
-using System.Data;
-using System.Configuration;
using System.Web;
-using System.Web.Security;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using System.Web.UI.WebControls.WebParts;
-using System.Web.UI.HtmlControls;
using DotNetOpenId.Extensions.SimpleRegistration;
+using System.Collections.Generic;
+using DotNetOpenId.Extensions.ProviderAuthenticationPolicy;
/// <summary>
-/// Summary description for State
+/// Strong-typed bag of session state.
/// </summary>
-public class State
-{
- public State()
- {
- }
-
- public static ClaimsResponse ProfileFields
- {
- get
- {
- if (HttpContext.Current .Session["ProfileFields"] == null)
- {
- HttpContext.Current .Session["ProfileFields"] = new ClaimsResponse();
- }
- return (ClaimsResponse)HttpContext.Current .Session["ProfileFields"];
- }
- set { HttpContext.Current .Session["ProfileFields"] = value; }
- }
-
+public class State {
+ public static void Clear() {
+ ProfileFields = null;
+ FriendlyLoginName = null;
+ PapePolicies = null;
+ }
+ public static ClaimsResponse ProfileFields {
+ get { return HttpContext.Current.Session["ProfileFields"] as ClaimsResponse; }
+ set { HttpContext.Current.Session["ProfileFields"] = value; }
+ }
+ public static string FriendlyLoginName {
+ get { return HttpContext.Current.Session["FriendlyUsername"] as string; }
+ set { HttpContext.Current.Session["FriendlyUsername"] = value; }
+ }
+ public static PolicyResponse PapePolicies {
+ get { return HttpContext.Current.Session["PapePolicies"] as PolicyResponse; }
+ set { HttpContext.Current.Session["PapePolicies"] = value; }
+ }
}
diff --git a/samples/RelyingPartyPortal/Code/TracePageAppender.cs b/samples/RelyingPartyPortal/Code/TracePageAppender.cs new file mode 100644 index 0000000..c10770b --- /dev/null +++ b/samples/RelyingPartyPortal/Code/TracePageAppender.cs @@ -0,0 +1,13 @@ +using System;
+using System.Collections.Generic;
+using System.Web;
+using System.IO;
+
+namespace ConsumerPortal.Code {
+ public class TracePageAppender : log4net.Appender.AppenderSkeleton {
+ protected override void Append(log4net.Core.LoggingEvent loggingEvent) {
+ StringWriter sw = new StringWriter(Global.LogMessages);
+ Layout.Format(sw, loggingEvent);
+ }
+ }
+}
diff --git a/samples/RelyingPartyPortal/Default.aspx b/samples/RelyingPartyPortal/Default.aspx index b303c12..bdb9b27 100644 --- a/samples/RelyingPartyPortal/Default.aspx +++ b/samples/RelyingPartyPortal/Default.aspx @@ -1,26 +1,13 @@ -<%@ Page Language="C#" AutoEventWireup="true" %>
+<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %>
<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId" TagPrefix="openid" %>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head runat="server">
- <title>OpenID Relying Party, by DotNetOpenId</title>
- <openid:XrdsPublisher runat="server" XrdsUrl="~/xrds.aspx" />
-</head>
-<body>
- <form id="form1" runat="server">
- <h1>
- OpenID Relying Party
- </h1>
- <h2>
- Provided by <a href="http://dotnetopenid.googlecode.com">DotNetOpenId</a>
- </h2>
- <p>
- Visit the
- <asp:HyperLink runat="server" NavigateUrl="~/MembersOnly/Default.aspx" Text="Members Only" />
- area. (This will trigger a login demo).
- </p>
- <asp:LoginStatus runat="server" />
- </form>
-</body>
-</html>
+<asp:Content runat="server" ContentPlaceHolderID="head">
+ <openid:XrdsPublisher ID="XrdsPublisher1" runat="server" XrdsUrl="~/xrds.aspx" />
+</asp:Content>
+<asp:Content runat="server" ContentPlaceHolderID="main">
+ <h2>Relying Party </h2>
+ <p>Visit the
+ <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/MembersOnly/Default.aspx"
+ Text="Members Only" />
+ area. (This will trigger a login demo). </p>
+</asp:Content>
diff --git a/samples/RelyingPartyPortal/Global.asax.cs b/samples/RelyingPartyPortal/Global.asax.cs index 56636a5..eb61da9 100644 --- a/samples/RelyingPartyPortal/Global.asax.cs +++ b/samples/RelyingPartyPortal/Global.asax.cs @@ -1,14 +1,24 @@ using System;
using System.Collections.Specialized;
-using System.Diagnostics;
using System.IO;
+using System.Text;
using System.Web;
namespace ConsumerPortal {
public class Global : System.Web.HttpApplication {
- public Global() {
- // since this is a sample, and will often be used with localhost
- DotNetOpenId.UntrustedWebRequest.WhitelistHosts.Add("localhost");
+ internal static StringBuilder LogMessages = new StringBuilder();
+
+ public static log4net.ILog Logger = log4net.LogManager.GetLogger(typeof(Global));
+
+ protected void Application_Start(object sender, EventArgs e) {
+ log4net.Config.XmlConfigurator.Configure();
+ Logger.Info("Sample starting...");
+ }
+
+ protected void Application_End(object sender, EventArgs e) {
+ Logger.Info("Sample shutting down...");
+ // this would be automatic, but in partial trust scenarios it is not.
+ log4net.LogManager.Shutdown();
}
string stripQueryString(Uri uri) {
@@ -19,22 +29,22 @@ namespace ConsumerPortal { protected void Application_BeginRequest(Object sender, EventArgs e) {
// System.Diagnostics.Debugger.Launch();
- Trace.TraceInformation("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url));
+ Logger.DebugFormat("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url));
if (Request.QueryString.Count > 0)
- Trace.TraceInformation("Querystring follows: \n{0}", ToString(Request.QueryString));
+ Logger.DebugFormat("Querystring follows: \n{0}", ToString(Request.QueryString));
if (Request.Form.Count > 0)
- Trace.TraceInformation("Posted form follows: \n{0}", ToString(Request.Form));
+ Logger.DebugFormat("Posted form follows: \n{0}", ToString(Request.Form));
}
protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
- Trace.TraceInformation("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT");
+ Logger.DebugFormat("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT");
}
protected void Application_EndRequest(Object sender, EventArgs e) {
}
protected void Application_Error(Object sender, EventArgs e) {
- Trace.TraceError("An unhandled exception was raised. Details follow: {0}",
+ Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}",
HttpContext.Current.Server.GetLastError());
}
diff --git a/samples/RelyingPartyPortal/MembersOnly/Default.aspx b/samples/RelyingPartyPortal/MembersOnly/Default.aspx index 4f384cd..fe87b37 100644 --- a/samples/RelyingPartyPortal/MembersOnly/Default.aspx +++ b/samples/RelyingPartyPortal/MembersOnly/Default.aspx @@ -1,22 +1,27 @@ -<%@ Page Language="C#" AutoEventWireup="true" %>
+<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head runat="server">
- <title>Welcome OpenID User!</title>
-</head>
-<body>
- <form id="form1" runat="server">
- <h1>
+<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main">
+ <h2>
Members Only Area
- </h1>
+ </h2>
<p>
- Congratulations, <b>
- <asp:LoginName ID="LoginName1" runat="server" />
- </b>. You have completed the OpenID login process.
+ Congratulations, <b><asp:LoginName ID="LoginName1" runat="server" /></b>.
+ You have completed the OpenID login process.
</p>
- <asp:LoginStatus ID="LoginStatus1" runat="server" />
+<% if (State.PapePolicies != null) { %>
+ <p>A PAPE extension was included in the authentication with this content: </p>
+ <ul>
+ <% if (State.PapePolicies.NistAssuranceLevel != null) {%>
+ <li>Nist: <%=HttpUtility.HtmlEncode(State.PapePolicies.NistAssuranceLevel.Value.ToString())%></li>
+ <% }
+ foreach (string policy in State.PapePolicies.ActualPolicies) { %>
+ <li><%=HttpUtility.HtmlEncode(policy) %></li>
+ <% } %>
+ </ul>
+<% } %>
+
+<% if (State.ProfileFields != null) { %>
<p>
In addition to authenticating you, your OpenID Provider may
have told us something about you using the
@@ -96,6 +101,5 @@ </td>
</tr>
</table>
- </form>
-</body>
-</html>
+<% } %>
+</asp:Content> diff --git a/samples/RelyingPartyPortal/PrivacyPolicy.aspx b/samples/RelyingPartyPortal/PrivacyPolicy.aspx index 10e4a0f..3bc12fe 100644 --- a/samples/RelyingPartyPortal/PrivacyPolicy.aspx +++ b/samples/RelyingPartyPortal/PrivacyPolicy.aspx @@ -1,15 +1,7 @@ -<%@ Page Language="C#" AutoEventWireup="true" %>
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head runat="server">
- <title>Privacy Policy</title>
-</head>
-<body>
- <form id="form1" runat="server">
+<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %>
+<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main">
+ <h2>Privacy Policy</h2>
<p>
Some privacy policy would go here.
</p>
- </form>
-</body>
-</html>
+</asp:Content>
\ No newline at end of file diff --git a/samples/RelyingPartyPortal/RelyingPartyPortal.csproj b/samples/RelyingPartyPortal/RelyingPartyPortal.csproj index 925c633..99f36f9 100644 --- a/samples/RelyingPartyPortal/RelyingPartyPortal.csproj +++ b/samples/RelyingPartyPortal/RelyingPartyPortal.csproj @@ -2,7 +2,7 @@ <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{51BCD5E9-E17A-4FB2-BAC8-C156DD7A1CA4}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
@@ -17,7 +17,7 @@ <DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@@ -30,6 +30,10 @@ <WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\log4net.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
@@ -50,7 +54,25 @@ <Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="ajaxlogin.aspx.cs">
+ <DependentUpon>ajaxlogin.aspx</DependentUpon>
+ <SubType>ASPXCodeBehind</SubType>
+ </Compile>
+ <Compile Include="ajaxlogin.aspx.designer.cs">
+ <DependentUpon>ajaxlogin.aspx</DependentUpon>
+ </Compile>
+ <Compile Include="Code\CustomStore.cs" />
+ <Compile Include="Code\CustomStoreDataSet.cs">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="Code\CustomStoreDataSet.Designer.cs">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ </Compile>
<Compile Include="Code\State.cs" />
+ <Compile Include="Code\TracePageAppender.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
@@ -61,6 +83,13 @@ <Compile Include="login.aspx.designer.cs">
<DependentUpon>login.aspx</DependentUpon>
</Compile>
+ <Compile Include="loginProgrammatic.aspx.cs">
+ <DependentUpon>loginProgrammatic.aspx</DependentUpon>
+ <SubType>ASPXCodeBehind</SubType>
+ </Compile>
+ <Compile Include="loginProgrammatic.aspx.designer.cs">
+ <DependentUpon>loginProgrammatic.aspx</DependentUpon>
+ </Compile>
<Compile Include="m\Login.aspx.cs">
<DependentUpon>Login.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -69,6 +98,13 @@ <DependentUpon>Login.aspx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TracePage.aspx.cs">
+ <DependentUpon>TracePage.aspx</DependentUpon>
+ <SubType>ASPXCodeBehind</SubType>
+ </Compile>
+ <Compile Include="TracePage.aspx.designer.cs">
+ <DependentUpon>TracePage.aspx</DependentUpon>
+ </Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\DotNetOpenId\DotNetOpenId.csproj">
@@ -81,9 +117,32 @@ <Content Include="xrds.aspx" />
</ItemGroup>
<ItemGroup>
+ <Content Include="images\dotnetopenid_tiny.gif" />
+ <Content Include="loginProgrammatic.aspx" />
<Content Include="MembersOnly\Default.aspx" />
<Content Include="MembersOnly\Web.config" />
<Content Include="m\Login.aspx" />
+ <Content Include="styles.css" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="ajaxlogin.aspx" />
+ <EmbeddedResource Include="images\attention.png" />
+ <Content Include="images\openid_login.gif" />
+ <Content Include="Site.Master" />
+ <Content Include="TracePage.aspx" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Code\CustomStoreDataSet.xsc">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ </None>
+ <None Include="Code\CustomStoreDataSet.xsd">
+ <Generator>MSDataSetGenerator</Generator>
+ <LastGenOutput>CustomStoreDataSet.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </None>
+ <None Include="Code\CustomStoreDataSet.xss">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ </None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
@@ -105,6 +164,9 @@ <IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
+ <UseCustomServer>False</UseCustomServer>
+ <CustomServerUrl>
+ </CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
diff --git a/samples/RelyingPartyPortal/Site.Master b/samples/RelyingPartyPortal/Site.Master new file mode 100644 index 0000000..bbb7bc3 --- /dev/null +++ b/samples/RelyingPartyPortal/Site.Master @@ -0,0 +1,39 @@ +<%@ Master Language="C#" AutoEventWireup="true" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<script runat="server">
+ protected void Page_Load(object sender, EventArgs e) {
+ friendlyUsername.Text = State.FriendlyLoginName;
+ }
+
+ protected void LoginStatus1_LoggedOut(object sender, EventArgs e) {
+ State.Clear();
+ }
+</script>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+ <title>OpenID Relying Party, by DotNetOpenId</title>
+ <link href="styles.css" rel="stylesheet" type="text/css" />
+ <asp:ContentPlaceHolder ID="head" runat="server" />
+</head>
+<body>
+ <form id="form1" runat="server">
+ <span style="float: right">
+ <asp:Image runat="server" ID="openIdUsernameImage" ImageUrl="~/images/openid_login.gif"
+ EnableViewState="false" />
+ <asp:Label runat="server" ID="friendlyUsername" Text="" EnableViewState="false" />
+ <asp:LoginStatus ID="LoginStatus1" runat="server" OnLoggedOut="LoginStatus1_LoggedOut" />
+ </span>
+ <div>
+ <a href="http://dotnetopenid.googlecode.com">
+ <img runat="server" src="~/images/dotnetopenid_tiny.gif" title="Jump to the project web site."
+ alt="DotNetOpenId" border='0' /></a>
+ </div>
+ <div>
+ <asp:ContentPlaceHolder ID="Main" runat="server" />
+ </div>
+ </form>
+</body>
+</html>
diff --git a/samples/RelyingPartyPortal/TracePage.aspx b/samples/RelyingPartyPortal/TracePage.aspx new file mode 100644 index 0000000..f9d9a56 --- /dev/null +++ b/samples/RelyingPartyPortal/TracePage.aspx @@ -0,0 +1,16 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TracePage.aspx.cs" Inherits="ConsumerPortal.TracePage" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+ <title></title>
+</head>
+<body>
+ <form id="form1" runat="server">
+ <p align="right">
+ <asp:Button runat="server" Text="Clear log" ID="clearLogButton" OnClick="clearLogButton_Click" />
+ </p>
+ <pre><asp:PlaceHolder runat="server" ID="placeHolder1" /></pre>
+ </form>
+</body>
+</html>
diff --git a/samples/RelyingPartyPortal/TracePage.aspx.cs b/samples/RelyingPartyPortal/TracePage.aspx.cs new file mode 100644 index 0000000..0f5b36a --- /dev/null +++ b/samples/RelyingPartyPortal/TracePage.aspx.cs @@ -0,0 +1,19 @@ +using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace ConsumerPortal {
+ public partial class TracePage : System.Web.UI.Page {
+ protected void Page_Load(object sender, EventArgs e) {
+ placeHolder1.Controls.Add(new Label { Text = Global.LogMessages.ToString() });
+ }
+
+ protected void clearLogButton_Click(object sender, EventArgs e) {
+ Global.LogMessages.Length = 0;
+ // clear the page immediately, and allow for F5 without a Postback warning.
+ Response.Redirect(Request.Url.AbsoluteUri);
+ }
+ }
+}
diff --git a/samples/RelyingPartyPortal/TracePage.aspx.designer.cs b/samples/RelyingPartyPortal/TracePage.aspx.designer.cs new file mode 100644 index 0000000..8a2ec37 --- /dev/null +++ b/samples/RelyingPartyPortal/TracePage.aspx.designer.cs @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.3053
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace ConsumerPortal {
+
+
+ public partial class TracePage {
+
+ /// <summary>
+ /// form1 control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.HtmlControls.HtmlForm form1;
+
+ /// <summary>
+ /// clearLogButton 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.Button clearLogButton;
+
+ /// <summary>
+ /// placeHolder1 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.PlaceHolder placeHolder1;
+ }
+}
diff --git a/samples/RelyingPartyPortal/Web.config b/samples/RelyingPartyPortal/Web.config index 551cb53..a601644 100644 --- a/samples/RelyingPartyPortal/Web.config +++ b/samples/RelyingPartyPortal/Web.config @@ -1,5 +1,37 @@ <?xml version="1.0"?>
<configuration>
+ <configSections>
+ <section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" requirePermission="false" />
+ <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>
+ </configSections>
+
+ <!-- this is an optional configuration section where aspects of dotnetopenid can be customized -->
+ <dotNetOpenId>
+ <relyingParty>
+ <security requireSsl="false" />
+ <!-- Uncomment the following to activate the sample custom store. -->
+ <!--<store type="ConsumerPortal.Code.CustomStore, ConsumerPortal" />-->
+ </relyingParty>
+ <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>
+
<system.web>
<!--<sessionState cookieless="true" />-->
<compilation debug="true"/>
@@ -13,17 +45,37 @@ High: TRACE compilation symbol must NOT be defined
Medium/Low: doesn't work on default machine.config, because WebPermission.Connect is denied.
-->
- <trust level="Full" originUrl=""/>
+ <trust level="High" originUrl=""/>
</system.web>
- <system.diagnostics>
- <switches>
- <add name="OpenID" value="4"/>
- </switches>
- <trace autoflush="true" indentsize="4">
- <listeners>
- <add name="fileLogger" type="System.Diagnostics.TextWriterTraceListener"
- initializeData="openidConsumerTrace.txt" traceOutputOptions="None"/>
- </listeners>
- </trace>
- </system.diagnostics>
+
+ <!-- log4net is a 3rd party (free) logger library that dotnetopenid will use if present but does not require. -->
+ <log4net>
+ <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
+ <file value="RelyingParty.log" />
+ <appendToFile value="true" />
+ <rollingStyle value="Size" />
+ <maxSizeRollBackups value="10" />
+ <maximumFileSize value="100KB" />
+ <staticLogFileName value="true" />
+ <layout type="log4net.Layout.PatternLayout">
+ <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" />
+ </layout>
+ </appender>
+ <appender name="TracePageAppender" type="ConsumerPortal.Code.TracePageAppender, ConsumerPortal">
+ <layout type="log4net.Layout.PatternLayout">
+ <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" />
+ </layout>
+ </appender>
+ <!-- Setup the root category, add the appenders and set the default level -->
+ <root>
+ <level value="INFO" />
+ <!--<appender-ref ref="RollingFileAppender" />-->
+ <appender-ref ref="TracePageAppender" />
+ </root>
+ <!-- Specify the level for some specific categories -->
+ <logger name="DotNetOpenId">
+ <level value="ALL" />
+ </logger>
+ </log4net>
+
</configuration>
diff --git a/samples/RelyingPartyPortal/ajaxlogin.aspx b/samples/RelyingPartyPortal/ajaxlogin.aspx new file mode 100644 index 0000000..27064f2 --- /dev/null +++ b/samples/RelyingPartyPortal/ajaxlogin.aspx @@ -0,0 +1,91 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ajaxlogin.aspx.cs" Inherits="ConsumerPortal.ajaxlogin"
+ ValidateRequest="false" MasterPageFile="~/Site.Master" %>
+
+<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId.RelyingParty" TagPrefix="openid" %>
+<asp:Content runat="server" ContentPlaceHolderID="head">
+<style type="text/css">
+.textbox
+{
+ width: 200px;
+}
+.openidtextbox
+{
+ width: 185px;
+}
+td
+{
+ vertical-align: top;
+}
+</style>
+</asp:Content>
+
+<asp:Content runat="server" ContentPlaceHolderID="Main">
+<script type="text/javascript">
+ function onauthenticated(sender) {
+ var emailBox = document.getElementById('<%= emailAddressBox.ClientID %>');
+ emailBox.disabled = false;
+ emailBox.title = null; // remove tooltip describing why the box was disabled.
+ // the sreg response may not always be included.
+ if (sender.sreg) {
+ // and the email field may not always be included in the sreg response.
+ if (sender.sreg.email) { emailBox.value = sender.sreg.email; }
+ }
+ }
+</script>
+
+ <asp:MultiView runat="server" ID="multiView" ActiveViewIndex='0'>
+ <asp:View runat="server" ID="commentSubmission">
+ <table>
+ <tr>
+ <td>
+ OpenID
+ </td>
+ <td>
+ <openid:OpenIdAjaxTextBox ID="OpenIdAjaxTextBox1" runat="server" CssClass="openidtextbox"
+ OnLoggingIn="OpenIdAjaxTextBox1_LoggingIn"
+ OnLoggedIn="OpenIdAjaxTextBox1_LoggedIn"
+ OnClientAssertionReceived="onauthenticated(sender)"
+ OnUnconfirmedPositiveAssertion="OpenIdAjaxTextBox1_UnconfirmedPositiveAssertion" />
+ <asp:RequiredFieldValidator ID="openidRequiredValidator" runat="server"
+ ControlToValidate="OpenIdAjaxTextBox1" ValidationGroup="openidVG"
+ ErrorMessage="The OpenID field is required." SetFocusOnError="True">
+ <asp:Image runat="server" ImageUrl="~/images/attention.png" ToolTip="This is a required field" />
+ </asp:RequiredFieldValidator>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Email
+ </td>
+ <td>
+ <asp:TextBox runat="server" ID="emailAddressBox" Enabled="false" CssClass="textbox" ToolTip="This field will be enabled after you log in with your OpenID." />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Comments
+ </td>
+ <td>
+ <asp:TextBox runat="server" ID="commentsBox" TextMode="MultiLine" Rows="5" CssClass="textbox" />
+ </td>
+ </tr>
+ <tr>
+ <td />
+ <td>
+ <asp:Button runat="server" Text="Submit" ID="submitButton" OnClick="submitButton_Click" />
+ </td>
+ </tr>
+ </table>
+ </asp:View>
+ <asp:View runat="server" ID="commentSubmitted">
+ <p>Congratulations,
+ <asp:Label runat="server" ID="emailLabel" />! Your comment was received (and discarded...
+ this is just a demo after all).</p>
+ <asp:LinkButton runat="server" Text="Go back and change something in the comment"
+ OnClick="editComment_Click" />
+ </asp:View>
+ <asp:View runat="server" ID="commentFailed">
+ <p>Your comment submission failed.</p>
+ </asp:View>
+ </asp:MultiView>
+</asp:Content>
diff --git a/samples/RelyingPartyPortal/ajaxlogin.aspx.cs b/samples/RelyingPartyPortal/ajaxlogin.aspx.cs new file mode 100644 index 0000000..6fac846 --- /dev/null +++ b/samples/RelyingPartyPortal/ajaxlogin.aspx.cs @@ -0,0 +1,54 @@ +using System;
+using System.Web.UI.WebControls;
+using DotNetOpenId.Extensions.SimpleRegistration;
+using DotNetOpenId.RelyingParty;
+
+namespace ConsumerPortal {
+ public partial class ajaxlogin : System.Web.UI.Page {
+ protected void Page_Load(object sender, EventArgs e) {
+ if (!IsPostBack) {
+ OpenIdAjaxTextBox1.Focus();
+ }
+ }
+
+ protected void OpenIdAjaxTextBox1_LoggingIn(object sender, OpenIdEventArgs e) {
+ e.Request.AddExtension(new ClaimsRequest {
+ Email = DemandLevel.Request,
+ });
+ }
+
+ protected void OpenIdAjaxTextBox1_LoggedIn(object sender, OpenIdEventArgs e) {
+ Label label = ((Label)commentSubmitted.FindControl("emailLabel"));
+ label.Text = e.Response.FriendlyIdentifierForDisplay;
+
+ // We COULD get the sreg extension response here for the email, but since we let the user
+ // potentially change the email in the HTML form, we'll use that instead.
+ //var claims = OpenIdAjaxTextBox1.AuthenticationResponse.GetExtension<ClaimsResponse>();
+ if (emailAddressBox.Text.Length > 0) {
+ label.Text += " (" + emailAddressBox.Text + ")";
+ }
+ }
+
+ protected void submitButton_Click(object sender, EventArgs e) {
+ if (!Page.IsValid) return;
+ if (OpenIdAjaxTextBox1.AuthenticationResponse != null) {
+ if (OpenIdAjaxTextBox1.AuthenticationResponse.Status == AuthenticationStatus.Authenticated) {
+ // Save comment here!
+ multiView.ActiveViewIndex = 1;
+ } else {
+ multiView.ActiveViewIndex = 2;
+ }
+ }
+ }
+
+ protected void editComment_Click(object sender, EventArgs e) {
+ multiView.ActiveViewIndex = 0;
+ }
+
+ protected void OpenIdAjaxTextBox1_UnconfirmedPositiveAssertion(object sender, OpenIdEventArgs e) {
+ // This is where we register extensions that we want to have available in javascript
+ // on the browser.
+ OpenIdAjaxTextBox1.RegisterClientScriptExtension<ClaimsResponse>("sreg");
+ }
+ }
+}
diff --git a/samples/RelyingPartyPortal/ajaxlogin.aspx.designer.cs b/samples/RelyingPartyPortal/ajaxlogin.aspx.designer.cs new file mode 100644 index 0000000..7b6ddf0 --- /dev/null +++ b/samples/RelyingPartyPortal/ajaxlogin.aspx.designer.cs @@ -0,0 +1,106 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.3053
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace ConsumerPortal {
+
+
+ public partial class ajaxlogin {
+
+ /// <summary>
+ /// multiView 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.MultiView multiView;
+
+ /// <summary>
+ /// commentSubmission 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.View commentSubmission;
+
+ /// <summary>
+ /// OpenIdAjaxTextBox1 control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::DotNetOpenId.RelyingParty.OpenIdAjaxTextBox OpenIdAjaxTextBox1;
+
+ /// <summary>
+ /// openidRequiredValidator 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.RequiredFieldValidator openidRequiredValidator;
+
+ /// <summary>
+ /// emailAddressBox 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.TextBox emailAddressBox;
+
+ /// <summary>
+ /// commentsBox 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.TextBox commentsBox;
+
+ /// <summary>
+ /// submitButton 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.Button submitButton;
+
+ /// <summary>
+ /// commentSubmitted 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.View commentSubmitted;
+
+ /// <summary>
+ /// emailLabel 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.Label emailLabel;
+
+ /// <summary>
+ /// commentFailed 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.View commentFailed;
+ }
+}
diff --git a/samples/RelyingPartyPortal/images/attention.png b/samples/RelyingPartyPortal/images/attention.png Binary files differnew file mode 100644 index 0000000..8003700 --- /dev/null +++ b/samples/RelyingPartyPortal/images/attention.png diff --git a/samples/RelyingPartyPortal/images/dotnetopenid_tiny.gif b/samples/RelyingPartyPortal/images/dotnetopenid_tiny.gif Binary files differnew file mode 100644 index 0000000..c4ed4f5 --- /dev/null +++ b/samples/RelyingPartyPortal/images/dotnetopenid_tiny.gif diff --git a/samples/RelyingPartyPortal/images/openid_login.gif b/samples/RelyingPartyPortal/images/openid_login.gif Binary files differnew file mode 100644 index 0000000..cde836c --- /dev/null +++ b/samples/RelyingPartyPortal/images/openid_login.gif diff --git a/samples/RelyingPartyPortal/login.aspx b/samples/RelyingPartyPortal/login.aspx index 8fbf6e5..ba1579a 100644 --- a/samples/RelyingPartyPortal/login.aspx +++ b/samples/RelyingPartyPortal/login.aspx @@ -1,28 +1,32 @@ -<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="login.aspx.cs" Inherits="login" ValidateRequest="false" %>
+<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="login.aspx.cs" Inherits="login"
+ ValidateRequest="false" MasterPageFile="~/Site.Master" %>
<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId.RelyingParty" TagPrefix="cc1" %>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <title>Login</title>
-</head>
-<body>
- <form id="Form1" runat="server">
- <h2>
- Login Page </h2>
+<asp:Content runat="server" ContentPlaceHolderID="Main">
+ <h2>Login Page </h2>
<cc1:OpenIdLogin ID="OpenIdLogin1" runat="server" CssClass="openid_login" RequestCountry="Request"
RequestEmail="Request" RequestGender="Require" RequestPostalCode="Require" RequestTimeZone="Require"
- RememberMeVisible="True" PolicyUrl="~/PrivacyPolicy.aspx" TabIndex="1" OnLoggedIn="OpenIdLogin1_LoggedIn"
+ RememberMeVisible="True" PolicyUrl="~/PrivacyPolicy.aspx" TabIndex="1"
+ OnLoggedIn="OpenIdLogin1_LoggedIn" OnLoggingIn="OpenIdLogin1_LoggingIn"
OnCanceled="OpenIdLogin1_Canceled" OnFailed="OpenIdLogin1_Failed" OnSetupRequired="OpenIdLogin1_SetupRequired" />
- <asp:CheckBox ID="immediateCheckBox" runat="server" Text="Immediate mode" />
+ <fieldset title="Knobs">
+ <asp:CheckBox ID="requireSslCheckBox" runat="server"
+ Text="RequireSsl (high security) mode"
+ oncheckedchanged="requireSslCheckBox_CheckedChanged" /><br />
+ <asp:CheckBox ID="immediateCheckBox" runat="server" Text="Immediate mode" /><br />
+ <asp:CheckBoxList runat="server" ID="papePolicies">
+ <asp:ListItem Text="Request phishing resistant authentication" Value="http://schemas.openid.net/pape/policies/2007/06/phishing-resistant" />
+ <asp:ListItem Text="Request multi-factor authentication" Value="http://schemas.openid.net/pape/policies/2007/06/multi-factor" />
+ <asp:ListItem Text="Request physical multi-factor authentication" Value="http://schemas.openid.net/pape/policies/2007/06/multi-factor-physical" />
+ </asp:CheckBoxList>
+ </fieldset>
<br />
<asp:Label ID="loginFailedLabel" runat="server" EnableViewState="False" Text="Login failed"
Visible="False" />
<asp:Label ID="loginCanceledLabel" runat="server" EnableViewState="False" Text="Login canceled"
Visible="False" />
<p>
- <asp:ImageButton runat="server" ImageUrl="~/images/yahoo.png" ID="yahooLoginButton" OnClick="yahooLoginButton_Click" />
+ <asp:ImageButton runat="server" ImageUrl="~/images/yahoo.png" ID="yahooLoginButton"
+ OnClick="yahooLoginButton_Click" />
</p>
- </form>
-</body>
-</html>
+</asp:Content>
diff --git a/samples/RelyingPartyPortal/login.aspx.cs b/samples/RelyingPartyPortal/login.aspx.cs index a3c062d..a987a4c 100644 --- a/samples/RelyingPartyPortal/login.aspx.cs +++ b/samples/RelyingPartyPortal/login.aspx.cs @@ -1,11 +1,22 @@ using System;
+using System.Collections.Generic;
using System.Web.UI;
+using System.Web.UI.WebControls;
+using DotNetOpenId.Extensions.ProviderAuthenticationPolicy;
+using DotNetOpenId.Extensions.SimpleRegistration;
using DotNetOpenId.RelyingParty;
public partial class login : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
OpenIdLogin1.Focus();
- OpenIdLogin1.ImmediateMode = immediateCheckBox.Checked;
+ }
+
+ protected void requireSslCheckBox_CheckedChanged(object sender, EventArgs e) {
+ this.OpenIdLogin1.RequireSsl = this.requireSslCheckBox.Checked;
+ }
+
+ protected void OpenIdLogin1_LoggingIn(object sender, OpenIdEventArgs e) {
+ prepareRequest(e.Request);
}
/// <summary>
@@ -13,7 +24,9 @@ public partial class login : System.Web.UI.Page { /// Note, that straight after login, forms auth will redirect the user to their original page. So this page may never be rendererd.
/// </summary>
protected void OpenIdLogin1_LoggedIn(object sender, OpenIdEventArgs e) {
- State.ProfileFields = e.ProfileFields;
+ State.FriendlyLoginName = e.Response.FriendlyIdentifierForDisplay;
+ State.ProfileFields = e.Response.GetExtension<ClaimsResponse>();
+ State.PapePolicies = e.Response.GetExtension<PolicyResponse>();
}
protected void OpenIdLogin1_Failed(object sender, OpenIdEventArgs e) {
loginFailedLabel.Visible = true;
@@ -30,8 +43,32 @@ public partial class login : System.Web.UI.Page { protected void yahooLoginButton_Click(object sender, ImageClickEventArgs e) {
OpenIdRelyingParty openid = new OpenIdRelyingParty();
var req = openid.CreateRequest("yahoo.com");
+ prepareRequest(req);
req.RedirectToProvider();
// We don't listen for the response from the provider explicitly
// because the OpenIdLogin control is already doing that for us.
}
+
+ private void prepareRequest(IAuthenticationRequest request) {
+ // Setup is the default for the login control. But the user may have checked the box to override that.
+ request.Mode = immediateCheckBox.Checked ? AuthenticationRequestMode.Immediate : AuthenticationRequestMode.Setup;
+
+ // Collect the PAPE policies requested by the user.
+ List<string> policies = new List<string>();
+ foreach (ListItem item in papePolicies.Items) {
+ if (item.Selected) {
+ policies.Add(item.Value);
+ }
+ }
+
+ // Add the PAPE extension if any policy was requested.
+ if (policies.Count > 0) {
+ var pape = new PolicyRequest();
+ foreach (string policy in policies) {
+ pape.PreferredPolicies.Add(policy);
+ }
+
+ request.AddExtension(pape);
+ }
+ }
}
diff --git a/samples/RelyingPartyPortal/login.aspx.designer.cs b/samples/RelyingPartyPortal/login.aspx.designer.cs index 3220bfa..8c888ca 100644 --- a/samples/RelyingPartyPortal/login.aspx.designer.cs +++ b/samples/RelyingPartyPortal/login.aspx.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.
@@ -13,22 +13,22 @@ public partial class login {
/// <summary>
- /// Form1 control.
+ /// OpenIdLogin1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
- protected global::System.Web.UI.HtmlControls.HtmlForm Form1;
+ protected global::DotNetOpenId.RelyingParty.OpenIdLogin OpenIdLogin1;
/// <summary>
- /// OpenIdLogin1 control.
+ /// requireSslCheckBox control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
- protected global::DotNetOpenId.RelyingParty.OpenIdLogin OpenIdLogin1;
+ protected global::System.Web.UI.WebControls.CheckBox requireSslCheckBox;
/// <summary>
/// immediateCheckBox control.
@@ -40,6 +40,15 @@ public partial class login { protected global::System.Web.UI.WebControls.CheckBox immediateCheckBox;
/// <summary>
+ /// papePolicies 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.CheckBoxList papePolicies;
+
+ /// <summary>
/// loginFailedLabel control.
/// </summary>
/// <remarks>
diff --git a/samples/RelyingPartyPortal/loginProgrammatic.aspx b/samples/RelyingPartyPortal/loginProgrammatic.aspx new file mode 100644 index 0000000..c65edb1 --- /dev/null +++ b/samples/RelyingPartyPortal/loginProgrammatic.aspx @@ -0,0 +1,15 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="loginProgrammatic.aspx.cs"
+ Inherits="loginProgrammatic" MasterPageFile="~/Site.Master" %>
+<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main">
+ <h2>Login Page </h2>
+ <asp:Label ID="Label1" runat="server" Text="OpenID Login" />
+ <asp:TextBox ID="openIdBox" runat="server" />
+ <asp:Button ID="loginButton" runat="server" Text="Login" OnClick="loginButton_Click" />
+ <asp:CustomValidator runat="server" ID="openidValidator" ErrorMessage="Invalid OpenID Identifier"
+ ControlToValidate="openIdBox" EnableViewState="false" OnServerValidate="openidValidator_ServerValidate" />
+ <br />
+ <asp:Label ID="loginFailedLabel" runat="server" EnableViewState="False" Text="Login failed"
+ Visible="False" />
+ <asp:Label ID="loginCanceledLabel" runat="server" EnableViewState="False" Text="Login canceled"
+ Visible="False" />
+</asp:Content>
\ No newline at end of file diff --git a/samples/RelyingPartyPortal/loginProgrammatic.aspx.cs b/samples/RelyingPartyPortal/loginProgrammatic.aspx.cs new file mode 100644 index 0000000..39a6f9b --- /dev/null +++ b/samples/RelyingPartyPortal/loginProgrammatic.aspx.cs @@ -0,0 +1,96 @@ +using System;
+using System.Net;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using DotNetOpenId;
+using DotNetOpenId.RelyingParty;
+
+public partial class loginProgrammatic : System.Web.UI.Page {
+ protected void openidValidator_ServerValidate(object source, ServerValidateEventArgs args) {
+ // This catches common typos that result in an invalid OpenID Identifier.
+ args.IsValid = Identifier.IsValid(args.Value);
+ }
+
+ OpenIdRelyingParty createRelyingParty() {
+ OpenIdRelyingParty openid = new OpenIdRelyingParty();
+ int minsha, maxsha, minversion;
+ if (int.TryParse(Request.QueryString["minsha"], out minsha)) {
+ openid.Settings.MinimumHashBitLength = minsha;
+ }
+ if (int.TryParse(Request.QueryString["maxsha"], out maxsha)) {
+ openid.Settings.MaximumHashBitLength = maxsha;
+ }
+ if (int.TryParse(Request.QueryString["minversion"], out minversion)) {
+ switch (minversion) {
+ case 1: openid.Settings.MinimumRequiredOpenIdVersion = ProtocolVersion.V10; break;
+ case 2: openid.Settings.MinimumRequiredOpenIdVersion = ProtocolVersion.V20; break;
+ default: throw new ArgumentOutOfRangeException("minversion");
+ }
+ }
+ return openid;
+ }
+
+ protected void loginButton_Click(object sender, EventArgs e) {
+ if (!Page.IsValid) return; // don't login if custom validation failed.
+ OpenIdRelyingParty openid = createRelyingParty();
+ try {
+ IAuthenticationRequest request = openid.CreateRequest(openIdBox.Text);
+ // This is where you would add any OpenID extensions you wanted
+ // to include in the authentication request.
+ // request.AddExtension(someExtensionRequestInstance);
+
+ // Send your visitor to their Provider for authentication.
+ request.RedirectToProvider();
+ } catch (OpenIdException ex) {
+ // The user probably entered an Identifier that
+ // was not a valid OpenID endpoint.
+ openidValidator.Text = ex.Message;
+ openidValidator.IsValid = false;
+ } catch (WebException ex) {
+ // The user probably entered an Identifier that
+ // was not a valid OpenID endpoint.
+ openidValidator.Text = ex.Message;
+ openidValidator.IsValid = false;
+ }
+ }
+
+ protected void Page_Load(object sender, EventArgs e) {
+ openIdBox.Focus();
+ // For debugging/testing, we allow remote clearing of all associations...
+ // NOT a good idea on a production site.
+ if (Request.QueryString["clearAssociations"] == "1") {
+ Application.Remove("DotNetOpenId.RelyingParty.RelyingParty.AssociationStore");
+ // Force a redirect now to prevent the user from logging in while associations
+ // are constantly being cleared.
+ UriBuilder builder = new UriBuilder(Request.Url);
+ builder.Query = null;
+ Response.Redirect(builder.Uri.AbsoluteUri);
+ }
+
+ OpenIdRelyingParty openid = createRelyingParty();
+ if (openid.Response != null) {
+ switch (openid.Response.Status) {
+ case AuthenticationStatus.Authenticated:
+ // This is where you would look for any OpenID extension responses included
+ // in the authentication assertion.
+ // var extension = openid.Response.GetExtension<SomeExtensionResponseType>();
+
+ // Use FormsAuthentication to tell ASP.NET that the user is now logged in,
+ // with the OpenID Claimed Identifier as their username.
+ FormsAuthentication.RedirectFromLoginPage(openid.Response.ClaimedIdentifier, false);
+ break;
+ case AuthenticationStatus.Canceled:
+ loginCanceledLabel.Visible = true;
+ break;
+ case AuthenticationStatus.Failed:
+ loginFailedLabel.Visible = true;
+ break;
+ // We don't need to handle SetupRequired because we're not setting
+ // IAuthenticationRequest.Mode to immediate mode.
+ //case AuthenticationStatus.SetupRequired:
+ // break;
+ }
+ }
+ }
+}
diff --git a/samples/RelyingPartyCustomStore/login.aspx.designer.cs b/samples/RelyingPartyPortal/loginProgrammatic.aspx.designer.cs index b5a6e1f..536a6d2 100644 --- a/samples/RelyingPartyCustomStore/login.aspx.designer.cs +++ b/samples/RelyingPartyPortal/loginProgrammatic.aspx.designer.cs @@ -10,43 +10,43 @@ -public partial class login {
+public partial class loginProgrammatic {
/// <summary>
- /// Form1 control.
+ /// Label1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
- protected global::System.Web.UI.HtmlControls.HtmlForm Form1;
+ protected global::System.Web.UI.WebControls.Label Label1;
/// <summary>
- /// Label1 control.
+ /// openIdBox 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.Label Label1;
+ protected global::System.Web.UI.WebControls.TextBox openIdBox;
/// <summary>
- /// openIdBox control.
+ /// loginButton 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.TextBox openIdBox;
+ protected global::System.Web.UI.WebControls.Button loginButton;
/// <summary>
- /// loginButton control.
+ /// openidValidator 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.Button loginButton;
+ protected global::System.Web.UI.WebControls.CustomValidator openidValidator;
/// <summary>
/// loginFailedLabel control.
diff --git a/samples/RelyingPartyPortal/logout.aspx b/samples/RelyingPartyPortal/logout.aspx index ce4fdf8..40b655c 100644 --- a/samples/RelyingPartyPortal/logout.aspx +++ b/samples/RelyingPartyPortal/logout.aspx @@ -3,9 +3,11 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
-protected void Page_Load(object sender, EventArgs e)
-{
- System.Web.Security.FormsAuthentication.SignOut();
- Response.Redirect("~/");
-}
+ protected void Page_Load(object sender, EventArgs e) {
+ State.FriendlyLoginName = null;
+ State.ProfileFields = null;
+ System.Web.Security.FormsAuthentication.SignOut();
+ Response.Redirect("~/");
+ }
</script>
+
diff --git a/samples/RelyingPartyPortal/styles.css b/samples/RelyingPartyPortal/styles.css new file mode 100644 index 0000000..62605db --- /dev/null +++ b/samples/RelyingPartyPortal/styles.css @@ -0,0 +1,10 @@ +h2
+{
+ font-style: italic;
+}
+
+body
+{
+ font-family: Cambria, Arial, Times New Roman;
+ font-size: 12pt;
+}
\ No newline at end of file diff --git a/samples/RelyingPartyPortal/xrds.aspx b/samples/RelyingPartyPortal/xrds.aspx index 266240c..e79fd8c 100644 --- a/samples/RelyingPartyPortal/xrds.aspx +++ b/samples/RelyingPartyPortal/xrds.aspx @@ -15,6 +15,8 @@ is default.aspx. <Type>http://specs.openid.net/auth/2.0/return_to</Type>
<%-- Every page with an OpenID login should be listed here. --%>
<URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/login.aspx"))%></URI> + <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/loginProgrammatic.aspx"))%></URI> + <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/ajaxlogin.aspx"))%></URI> </Service> </XRD> </xrds:XRDS> |