diff options
49 files changed, 2963 insertions, 2 deletions
@@ -5,6 +5,7 @@ <SolutionPath>$(ProjectRoot)\src\$(ProductName).sln</SolutionPath> <ILMergeOutputAssemblyDirectory>$(OutputPath)\unified\</ILMergeOutputAssemblyDirectory> <ILMergeOutputAssembly>$(ILMergeOutputAssemblyDirectory)\$(ProductName).dll</ILMergeOutputAssembly> + <StarterKitsLayoutPath>$(ProjectRoot)\obj\$(Configuration)\starterkits\</StarterKitsLayoutPath> </PropertyGroup> <Import Project="$(ProjectRoot)\tools\$(ProductName).Versioning.targets"/> @@ -16,6 +17,7 @@ <ItemGroup> <SampleProjects Include="$(ProjectRoot)\samples\**\*.csproj" /> <SampleSites Include="OAuthConsumer;OAuthServiceProvider;InfoCardRelyingParty" /> + <StarterKits Include="$(ProjectRoot)\starterkits\**\*.csproj" /> <ILMergeInputAssemblies Include="$(OutputPath)\$(ProductName).dll; $(ProjectRoot)\lib\Microsoft.Contracts.dll; "/> <DelaySignedAssemblies Include="$(ILMergeOutputAssembly); @@ -34,6 +36,7 @@ $(ProjectRoot)\doc\api; $(DropsRoot); $(ProjectRoot)\src\PrecompiledWeb; + $(StarterKitsLayoutPath); " /> <DirtyDirectories Include="@(SampleDirectories->'%(FullPath)\bin')" /> <DirtyDirectories Include="@(SampleDirectories->'%(FullPath)\obj')" /> @@ -133,6 +136,57 @@ WorkingDirectory="$(ToolsDirectory)" /> </Target> + <Target Name="BuildStarterKitsLayout" DependsOnTargets="BuildUnifiedProduct;ReSignDelaySignedAssemblies"> + <ItemGroup> + <StarterKitsSource Include="$(ProjectRoot)\starterkits\**\*" + Exclude=" + $(ProjectRoot)\starterkits\**\*.sln.cache; + $(ProjectRoot)\starterkits\**\*.suo; + $(ProjectRoot)\starterkits\**\*.gitignore; + $(ProjectRoot)\starterkits\**\*.log*; + $(ProjectRoot)\starterkits\**\*~; + $(ProjectRoot)\starterkits\**\Settings.StyleCop; + $(ProjectRoot)\starterkits\**\*.user; + $(ProjectRoot)\starterkits\**\obj\**; + $(ProjectRoot)\starterkits\**\bin\DotNetOpenAuth.dll; + $(ProjectRoot)\starterkits\**\bin\DotNetOpenAuth.pdb; + $(ProjectRoot)\starterkits\**\bin\Microsoft.Contracts.dll; + $(ProjectRoot)\starterkits\**\*.ldf; + $(ProjectRoot)\starterkits\**\*.mdf; + "/> + <StarterKitsLayout Include="@(StarterKitsSource->'$(StarterKitsLayoutPath)%(RecursiveDir)%(FileName)%(Extension)')"/> + + <!-- Include the template icon --> + <StarterKitsSource Include="@(StarterKits->'$(ProjectRoot)\doc\logo\dotnetopenid.ico')" /> + <StarterKitsLayout Include="@(StarterKits->'$(StarterKitsLayoutPath)%(RecursiveDir)__TemplateIcon.ico')" /> + + <!-- Include the unified, signed version of the library --> + <StarterKitsSource Include="@(StarterKits->'$(ILMergeOutputAssembly)')" /> + <StarterKitsSource Include="@(StarterKits->'$(ILMergeOutputAssemblyDirectory)\$(ProductName).pdb')" /> + <StarterKitsSource Include="@(StarterKits->'$(OutputPath)\$(ProductName).Contracts.dll')" /> + <StarterKitsLayout Include="@(StarterKits->'$(StarterKitsLayoutPath)%(RecursiveDir)bin\$(ProductName).dll')" /> + <StarterKitsLayout Include="@(StarterKits->'$(StarterKitsLayoutPath)%(RecursiveDir)bin\$(ProductName).pdb')" /> + <StarterKitsLayout Include="@(StarterKits->'$(StarterKitsLayoutPath)%(RecursiveDir)bin\$(ProductName).Contracts.dll')" /> + </ItemGroup> + <MSBuild Projects="@(StarterKits)" /> + <RemoveDir Directories="$(StarterKitsLayoutPath)" Condition="'$(NoClean)' != 'true'" /> + <Copy SourceFiles="@(StarterKitsSource)" DestinationFiles="@(StarterKitsLayout)" SkipUnchangedFiles="true" /> + </Target> + + <Target Name="BuildStarterKits" DependsOnTargets="BuildStarterKitsLayout"> + <PropertyGroup> + <WebFormsRelyingPartyZipFile>$(StarterKitsLayoutPath)\WebFormsRelyingParty.zip</WebFormsRelyingPartyZipFile> + </PropertyGroup> + <ItemGroup> + <WebFormsRelyingPartyStarterKitLayout Include="$(StarterKitsLayoutPath)\WebFormsRelyingParty\**\*" /> + </ItemGroup> + <Delete Files="$(WebFormsRelyingPartyZipFile)" /> + <Zip + Files="@(WebFormsRelyingPartyStarterKitLayout)" + ZipFileName="$(WebFormsRelyingPartyZipFile)" + WorkingDirectory="$(StarterKitsLayoutPath)\WebFormsRelyingParty" /> + </Target> + <Target Name="Documentation" DependsOnTargets="BuildProduct;Chm" Condition="'$(NoDocumentation)' != 'true'"> </Target> @@ -153,10 +207,11 @@ </PropertyGroup> </Target> - <Target Name="DropLayout" DependsOnTargets="GetBuildVersion;_SetDropProperties;BuildUnifiedProduct;ReSignDelaySignedAssemblies;BuildSamples;Documentation"> + <Target Name="DropLayout" DependsOnTargets="GetBuildVersion;_SetDropProperties;BuildUnifiedProduct;ReSignDelaySignedAssemblies;BuildSamples;BuildStarterKits;Documentation"> <PropertyGroup> <DropBinDirectory>$(DropDirectory)\Bin</DropBinDirectory> <DropLibDirectory>$(DropDirectory)\Lib</DropLibDirectory> + <DropProjectTemplatesDirectory>$(DropDirectory)\Project Templates</DropProjectTemplatesDirectory> <DropSamplesDirectory>$(DropDirectory)\Samples</DropSamplesDirectory> <DropSpecsDirectory>$(DropDirectory)\Specs</DropSpecsDirectory> </PropertyGroup> @@ -165,6 +220,7 @@ $(DropDirectory); $(DropBinDirectory); $(DropLibDirectory); + $(DropProjectTemplatesDirectory); $(DropSamplesDirectory); $(DropSpecsDirectory); " /> @@ -187,9 +243,9 @@ <DropLibSourceFiles Include=" $(ProjectRoot)\Lib\log4net.*; " /> + <DropProjectTemplatesSourceFiles Include="$(StarterKitsLayoutPath)\*.zip" /> <DropSamplesSourceFiles Include="$(ProjectRoot)\Samples\**" Exclude=" $(ProjectRoot)\**\obj\**; - $(ProjectRoot)\**\*.user; $(ProjectRoot)\**\*.sln.cache; $(ProjectRoot)\**\*.suo; $(ProjectRoot)\**\*.user; @@ -212,6 +268,7 @@ <DropFiles Include="@(DropSourceFiles->'$(DropDirectory)\%(RecursiveDir)%(FileName)%(Extension)')"/> <DropBinFiles Include="@(DropBinSourceFiles->'$(DropBinDirectory)\%(RecursiveDir)%(FileName)%(Extension)')"/> <DropLibFiles Include="@(DropLibSourceFiles->'$(DropLibDirectory)\%(RecurisveDir)%(FileName)%(Extension)')"/> + <DropProjectTemplatesFiles Include="@(DropProjectTemplatesSourceFiles->'$(DropProjectTemplatesDirectory)\%(FileName)%(Extension)')" /> <DropSamplesFiles Include="@(DropSamplesSourceFiles->'$(DropSamplesDirectory)\%(RecursiveDir)%(FileName)%(Extension)')"/> <DropSamplesRefreshFiles Include="@(DropSamplesRefreshSourceFiles->'$(DropSamplesDirectory)\%(RecursiveDir)%(FileName).refresh')"/> <DropSpecsFiles Include="@(DropSpecsSourceFiles->'$(DropSpecsDirectory)\%(RecursiveDir)%(FileName)%(Extension)')"/> @@ -220,6 +277,7 @@ @(DropSourceFiles); @(DropBinSourceFiles); @(DropLibSourceFiles); + @(DropProjectTemplatesSourceFiles); @(DropSamplesSourceFiles); @(DropSamplesRefreshSourceFiles); @(DropDocSourceFiles); @@ -230,6 +288,7 @@ @(DropFiles); @(DropBinFiles); @(DropLibFiles); + @(DropProjectTemplatesFiles); @(DropSamplesFiles); @(DropSamplesRefreshFiles); @(DropDocFiles); diff --git a/src/DotNetOpenAuth.sln b/src/DotNetOpenAuth.sln index f8d9b8f..5f2a121 100644 --- a/src/DotNetOpenAuth.sln +++ b/src/DotNetOpenAuth.sln @@ -163,6 +163,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenIdOfflineProvider", ".. EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{E9ED920D-1F83-48C0-9A4B-09CCE505FE6D}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project Templates", "Project Templates", "{B9EB8729-4B54-4453-B089-FE6761BA3057}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebFormsRelyingParty", "..\starterkits\WebFormsRelyingParty\WebFormsRelyingParty.csproj", "{A78F8FC6-7B03-4230-BE41-761E400D6810}" +EndProject Global GlobalSection(TestCaseManagementSettings) = postSolution CategoryFile = DotNetOpenAuth.vsmdi @@ -257,6 +261,12 @@ Global {5C65603B-235F-47E6-B536-06385C60DE7F}.Debug|Any CPU.Build.0 = Debug|Any CPU {5C65603B-235F-47E6-B536-06385C60DE7F}.Release|Any CPU.ActiveCfg = Release|Any CPU {5C65603B-235F-47E6-B536-06385C60DE7F}.Release|Any CPU.Build.0 = Release|Any CPU + {A78F8FC6-7B03-4230-BE41-761E400D6810}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU + {A78F8FC6-7B03-4230-BE41-761E400D6810}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU + {A78F8FC6-7B03-4230-BE41-761E400D6810}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A78F8FC6-7B03-4230-BE41-761E400D6810}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A78F8FC6-7B03-4230-BE41-761E400D6810}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A78F8FC6-7B03-4230-BE41-761E400D6810}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -277,5 +287,6 @@ Global {9ADBE36D-9960-48F6-82E9-B4AC559E9AC3} = {1E2CBAA5-60A3-4AED-912E-541F5753CDC6} {7ADCCD5C-AC2B-4340-9410-FE3A31A48191} = {1E2CBAA5-60A3-4AED-912E-541F5753CDC6} {5C65603B-235F-47E6-B536-06385C60DE7F} = {E9ED920D-1F83-48C0-9A4B-09CCE505FE6D} + {A78F8FC6-7B03-4230-BE41-761E400D6810} = {B9EB8729-4B54-4453-B089-FE6761BA3057} EndGlobalSection EndGlobal diff --git a/starterkits/Settings.StyleCop b/starterkits/Settings.StyleCop new file mode 100644 index 0000000..f6b59ac --- /dev/null +++ b/starterkits/Settings.StyleCop @@ -0,0 +1,44 @@ +<StyleCopSettings Version="4.3"> + <Analyzers> + <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules"> + <Rules> + <Rule Name="FileMustHaveHeader"> + <RuleSettings> + <BooleanProperty Name="Enabled">False</BooleanProperty> + </RuleSettings> + </Rule> + <Rule Name="ElementsMustBeDocumented"> + <RuleSettings> + <BooleanProperty Name="Enabled">False</BooleanProperty> + </RuleSettings> + </Rule> + <Rule Name="PartialElementsMustBeDocumented"> + <RuleSettings> + <BooleanProperty Name="Enabled">False</BooleanProperty> + </RuleSettings> + </Rule> + </Rules> + <AnalyzerSettings /> + </Analyzer> + <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.MaintainabilityRules"> + <Rules> + <Rule Name="FieldsMustBePrivate"> + <RuleSettings> + <BooleanProperty Name="Enabled">False</BooleanProperty> + </RuleSettings> + </Rule> + </Rules> + <AnalyzerSettings /> + </Analyzer> + <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.NamingRules"> + <Rules> + <Rule Name="ElementMustBeginWithUpperCaseLetter"> + <RuleSettings> + <BooleanProperty Name="Enabled">False</BooleanProperty> + </RuleSettings> + </Rule> + </Rules> + <AnalyzerSettings /> + </Analyzer> + </Analyzers> +</StyleCopSettings>
\ No newline at end of file diff --git a/starterkits/WebFormsRelyingParty/Admin/Admin.Master b/starterkits/WebFormsRelyingParty/Admin/Admin.Master new file mode 100644 index 0000000..77cd461 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Admin/Admin.Master @@ -0,0 +1,7 @@ +<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Admin.master.cs" Inherits="WebFormsOpenIdRelyingParty.Admin.Admin" + MasterPageFile="~/Site.Master" %> + +<asp:Content ContentPlaceHolderID="Body" runat="server"> + <asp:ContentPlaceHolder ID="Body" runat="server"> + </asp:ContentPlaceHolder> +</asp:Content> diff --git a/starterkits/WebFormsRelyingParty/Admin/Admin.Master.cs b/starterkits/WebFormsRelyingParty/Admin/Admin.Master.cs new file mode 100644 index 0000000..496833e --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Admin/Admin.Master.cs @@ -0,0 +1,19 @@ +//----------------------------------------------------------------------- +// <copyright file="Admin.Master.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsOpenIdRelyingParty.Admin { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + + public partial class Admin : System.Web.UI.MasterPage { + protected void Page_Load(object sender, EventArgs e) { + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Admin/Admin.Master.designer.cs b/starterkits/WebFormsRelyingParty/Admin/Admin.Master.designer.cs new file mode 100644 index 0000000..9d0abf9 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Admin/Admin.Master.designer.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.3521 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WebFormsOpenIdRelyingParty.Admin { + + + public partial class Admin { + + /// <summary> + /// Body 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 Body; + } +} diff --git a/starterkits/WebFormsRelyingParty/Admin/CreateDatabase.sql b/starterkits/WebFormsRelyingParty/Admin/CreateDatabase.sql new file mode 100644 index 0000000..99ac9db --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Admin/CreateDatabase.sql @@ -0,0 +1,128 @@ +/****** Object: Table [dbo].[User] Script Date: 10/08/2009 18:10:17 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[User]( + [Id] [int] IDENTITY(1,1) NOT NULL, + [FirstName] [nvarchar](50) NULL, + [LastName] [nvarchar](50) NULL, + [EmailAddress] [nvarchar](100) NULL, + CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED +( + [Id] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO +/****** Object: Table [dbo].[Role] Script Date: 10/08/2009 18:10:17 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Role]( + [Id] [int] IDENTITY(1,1) NOT NULL, + [Name] [nvarchar](50) NOT NULL, + CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED +( + [Id] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO +/****** Object: Table [dbo].[UserRole] Script Date: 10/08/2009 18:10:17 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[UserRole]( + [UserId] [int] NOT NULL, + [RoleId] [int] NOT NULL, + CONSTRAINT [PK_UserRole] PRIMARY KEY CLUSTERED +( + [UserId] ASC, + [RoleId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO +/****** Object: Table [dbo].[AuthenticationToken] Script Date: 10/08/2009 18:10:17 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[AuthenticationToken]( + [Id] [int] IDENTITY(1,1) NOT NULL, + [UserId] [int] NOT NULL, + [OpenIdClaimedIdentifier] [nvarchar](250) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, -- very important that claimed_id comparisons be case sensitive + [OpenIdFriendlyIdentifier] [nvarchar](250) NULL, + CONSTRAINT [PK_AuthenticationToken] PRIMARY KEY CLUSTERED +( + [Id] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO +/****** Object: StoredProcedure [dbo].[AddUser] Script Date: 10/08/2009 18:10:32 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE PROCEDURE [dbo].[AddUser] + ( + @firstName nvarchar(50), + @lastName nvarchar(50), + @openid nvarchar(255), + @role nvarchar(255) + ) +AS + DECLARE + @roleid int, + @userid int + + BEGIN TRANSACTION + + INSERT INTO [dbo].[User] (FirstName, LastName) VALUES (@firstName, @lastName) + SET @userid = (SELECT @@IDENTITY) + + IF (SELECT COUNT(*) FROM dbo.Role WHERE [Name] = @role) = 0 + BEGIN + INSERT INTO dbo.Role (Name) VALUES (@role) + SET @roleid = (SELECT @@IDENTITY) + END + ELSE + BEGIN + SET @roleid = (SELECT Id FROM dbo.Role WHERE [Name] = @role) + END + + INSERT INTO dbo.UserRole (UserId, RoleId) VALUES (@userId, @roleid) + + INSERT INTO dbo.AuthenticationToken + (UserId, OpenIdClaimedIdentifier, OpenIdFriendlyIdentifier) + VALUES + (@userid, @openid, @openid) + + COMMIT TRANSACTION + + RETURN @userid +GO +/****** Object: ForeignKey [FK_UserRole_Role] Script Date: 10/08/2009 18:10:17 ******/ +ALTER TABLE [dbo].[UserRole] WITH CHECK ADD CONSTRAINT [FK_UserRole_Role] FOREIGN KEY([RoleId]) +REFERENCES [dbo].[Role] ([Id]) +ON UPDATE CASCADE +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[UserRole] CHECK CONSTRAINT [FK_UserRole_Role] +GO +/****** Object: ForeignKey [FK_UserRole_User] Script Date: 10/08/2009 18:10:17 ******/ +ALTER TABLE [dbo].[UserRole] WITH CHECK ADD CONSTRAINT [FK_UserRole_User] FOREIGN KEY([UserId]) +REFERENCES [dbo].[User] ([Id]) +ON UPDATE CASCADE +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[UserRole] CHECK CONSTRAINT [FK_UserRole_User] +GO +/****** Object: ForeignKey [FK_AuthenticationToken_User] Script Date: 10/08/2009 18:10:17 ******/ +ALTER TABLE [dbo].[AuthenticationToken] WITH CHECK ADD CONSTRAINT [FK_AuthenticationToken_User] FOREIGN KEY([UserId]) +REFERENCES [dbo].[User] ([Id]) +ON UPDATE CASCADE +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[AuthenticationToken] CHECK CONSTRAINT [FK_AuthenticationToken_User] +GO diff --git a/starterkits/WebFormsRelyingParty/Admin/Default.aspx b/starterkits/WebFormsRelyingParty/Admin/Default.aspx new file mode 100644 index 0000000..9685436 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Admin/Default.aspx @@ -0,0 +1,16 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebFormsOpenIdRelyingParty.Admin.Default" %> + +<!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"> + <div> + This is the specially-priviledged Admin area. You can only reach here if you are + a member of the Admin role. + </div> + </form> +</body> +</html> diff --git a/starterkits/WebFormsRelyingParty/Admin/Default.aspx.cs b/starterkits/WebFormsRelyingParty/Admin/Default.aspx.cs new file mode 100644 index 0000000..e1814f2 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Admin/Default.aspx.cs @@ -0,0 +1,22 @@ +//----------------------------------------------------------------------- +// <copyright file="Default.aspx.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsOpenIdRelyingParty.Admin { + using System; + using System.Collections.Generic; + using System.Configuration; + using System.Data.SqlClient; + using System.IO; + using System.Linq; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + + public partial class Default : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Admin/Default.aspx.designer.cs b/starterkits/WebFormsRelyingParty/Admin/Default.aspx.designer.cs new file mode 100644 index 0000000..45a664f --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Admin/Default.aspx.designer.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WebFormsOpenIdRelyingParty.Admin { + + + public partial class Default { + + /// <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/starterkits/WebFormsRelyingParty/Admin/Web.config b/starterkits/WebFormsRelyingParty/Admin/Web.config new file mode 100644 index 0000000..52a5faf --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Admin/Web.config @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<configuration> + <system.web> + <authorization> + <allow roles="Admin"/> + <deny users="*"/> + </authorization> + </system.web> +</configuration> diff --git a/starterkits/WebFormsRelyingParty/Code/DataRoleProvider.cs b/starterkits/WebFormsRelyingParty/Code/DataRoleProvider.cs new file mode 100644 index 0000000..a643ece --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Code/DataRoleProvider.cs @@ -0,0 +1,123 @@ +//----------------------------------------------------------------------- +// <copyright file="DataRoleProvider.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsOpenIdRelyingParty.Code { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.Security; + + public class DataRoleProvider : RoleProvider { + public override string ApplicationName { + get { throw new NotImplementedException(); } + set { throw new NotImplementedException(); } + } + + public override void AddUsersToRoles(string[] usernames, string[] roleNames) { + var users = from token in Global.DataContext.AuthenticationToken + where usernames.Contains(token.ClaimedIdentifier) + select token.User; + var roles = from role in Global.DataContext.Role + where roleNames.Contains(role.Name, StringComparer.OrdinalIgnoreCase) + select role; + foreach (User user in users) { + foreach (Role role in roles) { + user.Roles.Add(role); + } + } + } + + public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { + var users = from token in Global.DataContext.AuthenticationToken + where usernames.Contains(token.ClaimedIdentifier) + select token.User; + var roles = from role in Global.DataContext.Role + where roleNames.Contains(role.Name, StringComparer.OrdinalIgnoreCase) + select role; + foreach (User user in users) { + foreach (Role role in roles) { + user.Roles.Remove(role); + } + } + } + + public override void CreateRole(string roleName) { + Global.DataContext.AddToRole(new Role { Name = roleName }); + } + + /// <summary> + /// Removes a role from the data source for the configured applicationName. + /// </summary> + /// <param name="roleName">The name of the role to delete.</param> + /// <param name="throwOnPopulatedRole">If true, throw an exception if <paramref name="roleName"/> has one or more members and do not delete <paramref name="roleName"/>.</param> + /// <returns> + /// true if the role was successfully deleted; otherwise, false. + /// </returns> + public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) { + Role role = Global.DataContext.Role.SingleOrDefault(r => r.Name == roleName); + if (role == null) { + return false; + } + + if (throwOnPopulatedRole && role.Users.Count > 0) { + throw new InvalidOperationException(); + } + + Global.DataContext.DeleteObject(roleName); + return true; + } + + /// <summary> + /// Gets an array of user names in a role where the user name contains the specified user name to match. + /// </summary> + /// <param name="roleName">The role to search in.</param> + /// <param name="usernameToMatch">The user name to search for.</param> + /// <returns> + /// A string array containing the names of all the users where the user name matches <paramref name="usernameToMatch"/> and the user is a member of the specified role. + /// </returns> + public override string[] FindUsersInRole(string roleName, string usernameToMatch) { + return (from role in Global.DataContext.Role + where role.Name == roleName + from user in role.Users + from authTokens in user.AuthenticationTokens + where authTokens.ClaimedIdentifier == usernameToMatch + select authTokens.ClaimedIdentifier).ToArray(); + } + + public override string[] GetAllRoles() { + return Global.DataContext.Role.Select(role => role.Name).ToArray(); + } + + public override string[] GetRolesForUser(string username) { + return (from authToken in Global.DataContext.AuthenticationToken + where authToken.ClaimedIdentifier == username + from role in authToken.User.Roles + select role.Name).ToArray(); + } + + public override string[] GetUsersInRole(string roleName) { + return (from role in Global.DataContext.Role + where string.Equals(role.Name, roleName, StringComparison.OrdinalIgnoreCase) + from user in role.Users + from token in user.AuthenticationTokens + select token.ClaimedIdentifier).ToArray(); + } + + public override bool IsUserInRole(string username, string roleName) { + Role role = Global.DataContext.Role.SingleOrDefault(r => string.Equals(r.Name, roleName, StringComparison.OrdinalIgnoreCase)); + if (role != null) { + return role.Users.Any(user => user.AuthenticationTokens.Any(token => token.ClaimedIdentifier == username)); + } + + return false; + } + + public override bool RoleExists(string roleName) { + return Global.DataContext.Role.Any(role => string.Equals(role.Name, roleName, StringComparison.OrdinalIgnoreCase)); + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Default.aspx b/starterkits/WebFormsRelyingParty/Default.aspx new file mode 100644 index 0000000..6dae10c --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Default.aspx @@ -0,0 +1,8 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebFormsOpenIdRelyingParty._Default" + MasterPageFile="~/Site.Master" %> + +<asp:Content runat="server" ContentPlaceHolderID="Body"> + <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> + <asp:HyperLink ID="HyperLink1" NavigateUrl="~/Members/Default.aspx" Text="Visit the Members Only area" + runat="server" /> +</asp:Content> diff --git a/starterkits/WebFormsRelyingParty/Default.aspx.cs b/starterkits/WebFormsRelyingParty/Default.aspx.cs new file mode 100644 index 0000000..a3f3a16 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Default.aspx.cs @@ -0,0 +1,21 @@ +//----------------------------------------------------------------------- +// <copyright file="Default.aspx.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsOpenIdRelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + + public partial class _Default : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + User user = Global.LoggedInUser; + this.Label1.Text = user != null ? user.FirstName : "<not logged in>"; + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Default.aspx.designer.cs b/starterkits/WebFormsRelyingParty/Default.aspx.designer.cs new file mode 100644 index 0000000..98c13a6 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Default.aspx.designer.cs @@ -0,0 +1,34 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WebFormsOpenIdRelyingParty { + + + public partial class _Default { + + /// <summary> + /// 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.WebControls.Label Label1; + + /// <summary> + /// HyperLink1 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.HyperLink HyperLink1; + } +} diff --git a/starterkits/WebFormsRelyingParty/Global.asax b/starterkits/WebFormsRelyingParty/Global.asax new file mode 100644 index 0000000..4f00db9 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="WebFormsOpenIdRelyingParty.Global" Language="C#" %> diff --git a/starterkits/WebFormsRelyingParty/Global.asax.cs b/starterkits/WebFormsRelyingParty/Global.asax.cs new file mode 100644 index 0000000..293a59f --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Global.asax.cs @@ -0,0 +1,176 @@ +//----------------------------------------------------------------------- +// <copyright file="Global.asax.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsOpenIdRelyingParty { + using System; + using System.Data; + using System.Data.SqlClient; + using System.Linq; + using System.ServiceModel; + using System.Web; + + public class Global : System.Web.HttpApplication { + private const string DataContextKey = "DataContext"; + + private const string DataContextTransactionKey = "DataContextTransaction"; + + /// <summary> + /// The logger for this sample to use. + /// </summary> + private static log4net.ILog logger = log4net.LogManager.GetLogger("DotNetOpenAuth.ConsumerSample"); + + public static log4net.ILog Logger { + get { return logger; } + } + + public static User LoggedInUser { + get { return Global.DataContext.AuthenticationToken.Where(token => token.ClaimedIdentifier == HttpContext.Current.User.Identity.Name).Select(token => token.User).FirstOrDefault(); } + } + + public static string ApplicationPath { + get { + string path = HttpContext.Current.Request.ApplicationPath; + if (!path.EndsWith("/")) { + path += "/"; + } + + return path; + } + } + + /// <summary> + /// Gets the transaction-protected database connection for the current request. + /// </summary> + public static DatabaseEntities DataContext { + get { + DatabaseEntities dataContext = DataContextSimple; + if (dataContext == null) { + dataContext = new DatabaseEntities(); + try { + dataContext.Connection.Open(); + } catch (EntityException entityEx) { + var sqlEx = entityEx.InnerException as SqlException; + if (sqlEx != null) { + if (sqlEx.Class == 14 && sqlEx.Number == 15350) { + // Most likely the database schema hasn't been created yet. + HttpContext.Current.Response.Redirect("~/Setup.aspx"); + } + } + } + + DataContextTransactionSimple = dataContext.Connection.BeginTransaction(); + DataContextSimple = dataContext; + } + + return dataContext; + } + } + + private static DatabaseEntities DataContextSimple { + get { + if (HttpContext.Current != null) { + return HttpContext.Current.Items[DataContextKey] as DatabaseEntities; + } else if (OperationContext.Current != null) { + object data; + if (OperationContext.Current.IncomingMessageProperties.TryGetValue(DataContextKey, out data)) { + return data as DatabaseEntities; + } else { + return null; + } + } else { + throw new InvalidOperationException(); + } + } + + set { + if (HttpContext.Current != null) { + HttpContext.Current.Items[DataContextKey] = value; + } else if (OperationContext.Current != null) { + OperationContext.Current.IncomingMessageProperties[DataContextKey] = value; + } else { + throw new InvalidOperationException(); + } + } + } + + private static IDbTransaction DataContextTransactionSimple { + get { + if (HttpContext.Current != null) { + return HttpContext.Current.Items[DataContextTransactionKey] as IDbTransaction; + } else if (OperationContext.Current != null) { + object data; + if (OperationContext.Current.IncomingMessageProperties.TryGetValue(DataContextTransactionKey, out data)) { + return data as IDbTransaction; + } else { + return null; + } + } else { + throw new InvalidOperationException(); + } + } + + set { + if (HttpContext.Current != null) { + HttpContext.Current.Items[DataContextTransactionKey] = value; + } else if (OperationContext.Current != null) { + OperationContext.Current.IncomingMessageProperties[DataContextTransactionKey] = value; + } else { + throw new InvalidOperationException(); + } + } + } + + protected void Application_Start(object sender, EventArgs e) { + log4net.Config.XmlConfigurator.Configure(); + Logger.Info("Web application starting..."); + } + + protected void Session_Start(object sender, EventArgs e) { + } + + protected void Application_BeginRequest(object sender, EventArgs e) { + } + + protected void Application_EndRequest(object sender, EventArgs e) { + CommitAndCloseDatabaseIfNecessary(); + } + + protected void Application_AuthenticateRequest(object sender, EventArgs e) { + } + + protected void Application_Error(object sender, EventArgs e) { + Logger.Error("An unhandled exception occurred in ASP.NET processing: " + Server.GetLastError(), Server.GetLastError()); + if (DataContextTransactionSimple != null) { + DataContextTransactionSimple.Rollback(); + DataContextTransactionSimple.Dispose(); + } + } + + protected void Session_End(object sender, EventArgs e) { + } + + protected void Application_End(object sender, EventArgs e) { + Logger.Info("Web application shutting down..."); + + // this would be automatic, but in partial trust scenarios it is not. + log4net.LogManager.Shutdown(); + } + + private static void CommitAndCloseDatabaseIfNecessary() { + var dataContext = DataContextSimple; + if (dataContext != null) { + dataContext.SaveChanges(); + if (DataContextTransactionSimple != null) { + DataContextTransactionSimple.Commit(); + DataContextTransactionSimple.Dispose(); + } + + dataContext.Dispose(); + DataContextSimple = null; + } + } + } +}
\ No newline at end of file diff --git a/starterkits/WebFormsRelyingParty/Login.aspx b/starterkits/WebFormsRelyingParty/Login.aspx new file mode 100644 index 0000000..d4e6d69 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Login.aspx @@ -0,0 +1,47 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="WebFormsOpenIdRelyingParty.Login" + MasterPageFile="~/Site.Master" ValidateRequest="false" %> + +<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.OpenId.RelyingParty" + TagPrefix="rp" %> +<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.InfoCard" TagPrefix="ic" %> +<asp:Content runat="server" ContentPlaceHolderID="Body"> + <h2>Login</h2> + <p>Login using an account you already use:</p> + <div class="OpenIdButtons"> + <span class="OpenIdButton" onclick='clickChild(this)'><span> + <rp:OpenIdButton runat="server" ImageUrl="~/images/google.gif" Text="Login with Google" + Identifier="https://www.google.com/accounts/o8/id" PrecreateRequest="true" OnLoggedIn="openIdLogin1_LoggedIn" /> + </span></span><span class="OpenIdButton" onclick='clickChild(this)'><span> + <rp:OpenIdButton runat="server" ImageUrl="~/images/yahoo.gif" Text="Login with Yahoo!" + Identifier="https://me.yahoo.com/" PrecreateRequest="true" OnLoggedIn="openIdLogin1_LoggedIn" /> + </span></span><span class="OpenIdButton" id="InfoCardButton" style="display: none"> + <ic:InfoCardSelector ID="InfoCardSelector1" runat="server" ImageSize="Size92x64" + OnReceivedToken="InfoCardSelector1_ReceivedToken" ToolTip="Log in with your Information Card"> + <ic:ClaimType Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier" /> + </ic:InfoCardSelector> + </span> + </div> + <div class="OpenIdBox"> + <rp:OpenIdLogin runat="server" ID="openIdLogin1" RequestFullName="Request" RequestEmail="Request" + OnLoggedIn="openIdLogin1_LoggedIn" TabIndex="1" RegisterVisible="false" /> + </div> + <p>If you don't have an account with any of these services, you can <a href="https://www.myopenid.com/signup"> + create one</a> and then use it for this and many other web sites.<br /> + If you have logged into this site previously, click the same button you did last + time. </p> + + <script type="text/javascript"> + function clickChild(parent, recursion) { + if (recursion && parent.click) { + parent.click(); + } + for (var i = 0; i < parent.childNodes.length; i++) { + clickChild(parent.childNodes[i], true); + } + }; + if (document.infoCard && document.infoCard.isSupported()) { + document.getElementById('InfoCardButton').style.display = 'block'; + } + </script> + +</asp:Content> diff --git a/starterkits/WebFormsRelyingParty/Login.aspx.cs b/starterkits/WebFormsRelyingParty/Login.aspx.cs new file mode 100644 index 0000000..53c7973 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Login.aspx.cs @@ -0,0 +1,66 @@ +//----------------------------------------------------------------------- +// <copyright file="Login.aspx.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsOpenIdRelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.Security; + using System.Web.UI; + using System.Web.UI.WebControls; + using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; + using DotNetOpenAuth.OpenId.RelyingParty; + + public partial class Login : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + this.openIdLogin1.Focus(); + } + + protected void openIdLogin1_LoggedIn(object sender, OpenIdEventArgs e) { + this.LoginUser(e.ClaimedIdentifier, e.Response.FriendlyIdentifierForDisplay, e.Response.GetExtension<ClaimsResponse>()); + e.Cancel = true; // we already logged the user in + } + + protected void InfoCardSelector1_ReceivedToken(object sender, DotNetOpenAuth.InfoCard.ReceivedTokenEventArgs e) { + this.LoginUser(AuthenticationToken.SynthesizeClaimedIdentifierFromInfoCard(e.Token.UniqueId), e.Token.SiteSpecificId, null); + } + + private void LoginUser(string claimedIdentifier, string friendlyIdentifier, ClaimsResponse claims) { + // Create an account for this user if we don't already have one. + AuthenticationToken openidToken = Global.DataContext.AuthenticationToken.FirstOrDefault(token => token.ClaimedIdentifier == claimedIdentifier); + if (openidToken == null) { + // this is a user we haven't seen before. + User user = new User(); + openidToken = new AuthenticationToken { + ClaimedIdentifier = claimedIdentifier, + FriendlyIdentifier = friendlyIdentifier, + }; + user.AuthenticationTokens.Add(openidToken); + + // Gather information about the user if it's available. + if (claims != null) { + if (!string.IsNullOrEmpty(claims.Email)) { + user.EmailAddress = claims.Email; + } + if (!string.IsNullOrEmpty(claims.FullName)) { + if (claims.FullName.IndexOf(' ') > 0) { + user.FirstName = claims.FullName.Substring(0, claims.FullName.IndexOf(' ')).Trim(); + user.LastName = claims.FullName.Substring(claims.FullName.IndexOf(' ')).Trim(); + } else { + user.FirstName = claims.FullName; + } + } + } + + Global.DataContext.AddToUser(user); + } + + FormsAuthentication.RedirectFromLoginPage(openidToken.ClaimedIdentifier, false); + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Login.aspx.designer.cs b/starterkits/WebFormsRelyingParty/Login.aspx.designer.cs new file mode 100644 index 0000000..16a22da --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Login.aspx.designer.cs @@ -0,0 +1,34 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WebFormsOpenIdRelyingParty { + + + public partial class Login { + + /// <summary> + /// InfoCardSelector1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::DotNetOpenAuth.InfoCard.InfoCardSelector InfoCardSelector1; + + /// <summary> + /// openIdLogin1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::DotNetOpenAuth.OpenId.RelyingParty.OpenIdLogin openIdLogin1; + } +} diff --git a/starterkits/WebFormsRelyingParty/Logout.aspx b/starterkits/WebFormsRelyingParty/Logout.aspx new file mode 100644 index 0000000..02a939f --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Logout.aspx @@ -0,0 +1,16 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Logout.aspx.cs" Inherits="WebFormsOpenIdRelyingParty.Logout" %> + +<!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"> + <div> + + </div> + </form> +</body> +</html> diff --git a/starterkits/WebFormsRelyingParty/Logout.aspx.cs b/starterkits/WebFormsRelyingParty/Logout.aspx.cs new file mode 100644 index 0000000..86b1e30 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Logout.aspx.cs @@ -0,0 +1,11 @@ +namespace WebFormsOpenIdRelyingParty { + using System; + using System.Web.Security; + + public partial class Logout : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + FormsAuthentication.SignOut(); + Response.Redirect("~/"); + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Logout.aspx.designer.cs b/starterkits/WebFormsRelyingParty/Logout.aspx.designer.cs new file mode 100644 index 0000000..7c5cae6 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Logout.aspx.designer.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WebFormsOpenIdRelyingParty { + + + public partial class Logout { + + /// <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/starterkits/WebFormsRelyingParty/Members/AccountInfo.aspx b/starterkits/WebFormsRelyingParty/Members/AccountInfo.aspx new file mode 100644 index 0000000..cab9312 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Members/AccountInfo.aspx @@ -0,0 +1,99 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AccountInfo.aspx.cs" Inherits="WebFormsOpenIdRelyingParty.Members.AccountInfo" + MasterPageFile="~/Site.Master" ValidateRequest="false" %> + +<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.OpenId.RelyingParty" + TagPrefix="rp" %> +<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.InfoCard" TagPrefix="ic" %> +<%@ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" + Namespace="System.Web.UI.WebControls" TagPrefix="asp" %> +<asp:Content runat="server" ContentPlaceHolderID="Body"> + <asp:ScriptManager ID="ScriptManager1" runat="server" /> + <h3> + Personal information + </h3> + <asp:UpdatePanel ID="UpdatePanel1" runat="server"> + <ContentTemplate> + <table> + <tr> + <td> + First name + </td> + <td> + <asp:TextBox ID="firstNameBox" runat="server" /> + </td> + </tr> + <tr> + <td> + Last name + </td> + <td> + <asp:TextBox ID="lastNameBox" runat="server" /> + </td> + </tr> + <tr> + <td> + Email + </td> + <td> + <asp:TextBox ID="emailBox" runat="server" Columns="40" ValidationGroup="Profile" /> + <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="emailBox" + ErrorMessage="Invalid email address" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" + ValidationGroup="Profile">invalid</asp:RegularExpressionValidator> + </td> + </tr> + <tr> + <td> + </td> + <td> + <asp:Button ID="saveChanges" runat="server" Text="Save profile changes" OnClick="saveChanges_Click" + ValidationGroup="Profile" /> + <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" + DynamicLayout="true"> + <ProgressTemplate> + Saving... + </ProgressTemplate> + </asp:UpdateProgress> + </td> + </tr> + </table> + </ContentTemplate> + <Triggers> + <asp:AsyncPostBackTrigger ControlID="saveChanges" EventName="Click" /> + </Triggers> + </asp:UpdatePanel> + <h3> + OpenIDs & InfoCards</h3> + <asp:Repeater ID="Repeater1" runat="server"> + <HeaderTemplate> + <ul class="AuthTokens"> + </HeaderTemplate> + <ItemTemplate> + <li class='<%# ((bool)Eval("IsInfoCard")) ? "InfoCard" : "OpenID" %>'> + <asp:Label ID="OpenIdClaimedIdentifierLabel" runat="server" Text='<%# Eval("FriendlyIdentifier") %>' + ToolTip='<%# Eval("ClaimedIdentifier") %>' /> + <asp:Label runat="server" ForeColor="Gray" Text="(current login token)" ToolTip="To delete this token, you must log in using some other token." + Visible='<%# String.Equals((string)Eval("ClaimedIdentifier"), Page.User.Identity.Name, StringComparison.Ordinal) %>' /> + <asp:LinkButton runat="server" Text="remove" CommandName="delete" CommandArgument='<%# Eval("ClaimedIdentifier") %>' + ID="deleteOpenId" OnCommand="deleteOpenId_Command" Visible='<%# !String.Equals((string)Eval("ClaimedIdentifier"), Page.User.Identity.Name, StringComparison.Ordinal) %>' /> + </li> + </ItemTemplate> + <FooterTemplate> + </ul> + </FooterTemplate> + </asp:Repeater> + <asp:Panel ID="Panel1" runat="server" DefaultButton="addOpenId"> + <rp:OpenIdAjaxTextBox runat="server" ID="openIdBox" OnLoggedIn="openIdBox_LoggedIn" + OnLoggingIn="openIdBox_LoggingIn" /> + <asp:Button ID="addOpenId" runat="server" Text="Add Identifier" OnClick="addOpenId_Click" /> + <asp:Label ID="differentAccountLabel" runat="server" EnableViewState="False" ForeColor="Red" + Text="This identifier already belongs to a different user account." Visible="False" /> + <asp:Label ID="alreadyLinkedLabel" runat="server" EnableViewState="False" ForeColor="Red" + Text="This identifier is already linked to your account." Visible="False" /> + </asp:Panel> + <asp:Panel ID="Panel2" runat="server"> + <ic:InfoCardSelector ID="InfoCardSelector1" runat="server" ImageSize="Size92x64" + ToolTip="Log in with your Information Card" OnReceivedToken="InfoCardSelector1_ReceivedToken"> + <ic:ClaimType Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier" /> + </ic:InfoCardSelector> + </asp:Panel> +</asp:Content> diff --git a/starterkits/WebFormsRelyingParty/Members/AccountInfo.aspx.cs b/starterkits/WebFormsRelyingParty/Members/AccountInfo.aspx.cs new file mode 100644 index 0000000..22a7e71 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Members/AccountInfo.aspx.cs @@ -0,0 +1,99 @@ +//----------------------------------------------------------------------- +// <copyright file="AccountInfo.aspx.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsOpenIdRelyingParty.Members { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + using DotNetOpenAuth.InfoCard; + using DotNetOpenAuth.OpenId.RelyingParty; + + public partial class AccountInfo : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + Global.LoggedInUser.AuthenticationTokens.Load(); + Repeater1.DataSource = Global.LoggedInUser.AuthenticationTokens; + if (!IsPostBack) { + Repeater1.DataBind(); + emailBox.Text = Global.LoggedInUser.EmailAddress; + firstNameBox.Text = Global.LoggedInUser.FirstName; + lastNameBox.Text = Global.LoggedInUser.LastName; + } + + firstNameBox.Focus(); + } + + protected void openIdBox_LoggingIn(object sender, OpenIdEventArgs e) { + // Find out if this is an OpenID that is already bound to any account, + // but we can only check this for non-directed identity cases at this stage. + if (!e.IsDirectedIdentity) { + string claimedId = e.ClaimedIdentifier; + var existingToken = Global.DataContext.AuthenticationToken.FirstOrDefault(token => token.ClaimedIdentifier == claimedId); + if (existingToken != null) { + // Report the error to the user and cancel the login. + e.Cancel = true; + } + } + } + + protected void openIdBox_LoggedIn(object sender, OpenIdEventArgs e) { + this.AddIdentifier(e.ClaimedIdentifier, e.Response.FriendlyIdentifierForDisplay); + } + + protected void addOpenId_Click(object sender, EventArgs e) { + // We don't need to do anything here. The postback itself + // is enough to fire the event that gets the new openid added. + } + + protected void deleteOpenId_Command(object sender, CommandEventArgs e) { + string claimedId = (string)e.CommandArgument; + var token = Global.DataContext.AuthenticationToken.First(t => t.ClaimedIdentifier == claimedId && t.User.Id == Global.LoggedInUser.Id); + Global.DataContext.DeleteObject(token); + Global.DataContext.SaveChanges(); + this.Repeater1.DataBind(); + } + + protected void saveChanges_Click(object sender, EventArgs e) { + if (!IsValid) { + return; + } + + Global.LoggedInUser.EmailAddress = this.emailBox.Text; + Global.LoggedInUser.FirstName = this.firstNameBox.Text; + Global.LoggedInUser.LastName = this.lastNameBox.Text; + } + + protected void InfoCardSelector1_ReceivedToken(object sender, ReceivedTokenEventArgs e) { + this.AddIdentifier(AuthenticationToken.SynthesizeClaimedIdentifierFromInfoCard(e.Token.UniqueId), e.Token.SiteSpecificId); + } + + private void AddIdentifier(string claimedId, string friendlyId) { + // Check that this identifier isn't already tied to a user account. + // We do this again here in case the LoggingIn event couldn't verify + // and in case somehow the OP changed it anyway. + var existingToken = Global.DataContext.AuthenticationToken.FirstOrDefault(token => token.ClaimedIdentifier == claimedId); + if (existingToken == null) { + var token = new AuthenticationToken(); + token.ClaimedIdentifier = claimedId; + token.FriendlyIdentifier = friendlyId; + Global.LoggedInUser.AuthenticationTokens.Add(token); + Global.DataContext.SaveChanges(); + this.Repeater1.DataBind(); + + // Clear the box for the next entry + this.openIdBox.Text = string.Empty; + } else { + if (existingToken.User == Global.LoggedInUser) { + this.alreadyLinkedLabel.Visible = true; + } else { + this.differentAccountLabel.Visible = true; + } + } + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Members/AccountInfo.aspx.designer.cs b/starterkits/WebFormsRelyingParty/Members/AccountInfo.aspx.designer.cs new file mode 100644 index 0000000..d1eb8ed --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Members/AccountInfo.aspx.designer.cs @@ -0,0 +1,160 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WebFormsOpenIdRelyingParty.Members { + + + public partial class AccountInfo { + + /// <summary> + /// ScriptManager1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.ScriptManager ScriptManager1; + + /// <summary> + /// UpdatePanel1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.UpdatePanel UpdatePanel1; + + /// <summary> + /// firstNameBox 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 firstNameBox; + + /// <summary> + /// lastNameBox 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 lastNameBox; + + /// <summary> + /// emailBox 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 emailBox; + + /// <summary> + /// RegularExpressionValidator1 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.RegularExpressionValidator RegularExpressionValidator1; + + /// <summary> + /// saveChanges 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 saveChanges; + + /// <summary> + /// UpdateProgress1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.UpdateProgress UpdateProgress1; + + /// <summary> + /// Repeater1 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.Repeater Repeater1; + + /// <summary> + /// Panel1 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.Panel Panel1; + + /// <summary> + /// openIdBox control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::DotNetOpenAuth.OpenId.RelyingParty.OpenIdAjaxTextBox openIdBox; + + /// <summary> + /// addOpenId 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 addOpenId; + + /// <summary> + /// differentAccountLabel 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 differentAccountLabel; + + /// <summary> + /// alreadyLinkedLabel 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 alreadyLinkedLabel; + + /// <summary> + /// Panel2 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.Panel Panel2; + + /// <summary> + /// InfoCardSelector1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::DotNetOpenAuth.InfoCard.InfoCardSelector InfoCardSelector1; + } +} diff --git a/starterkits/WebFormsRelyingParty/Members/Default.aspx b/starterkits/WebFormsRelyingParty/Members/Default.aspx new file mode 100644 index 0000000..03707c6 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Members/Default.aspx @@ -0,0 +1,9 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebFormsOpenIdRelyingParty.Members.Default" + MasterPageFile="~/Site.Master" %> + +<asp:Content runat="server" ContentPlaceHolderID="Body"> + <h2>Members Only</h2> + <div> + You've made it to the Members Only area. + </div> +</asp:Content> diff --git a/starterkits/WebFormsRelyingParty/Members/Default.aspx.cs b/starterkits/WebFormsRelyingParty/Members/Default.aspx.cs new file mode 100644 index 0000000..3c8747d --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Members/Default.aspx.cs @@ -0,0 +1,13 @@ +namespace WebFormsOpenIdRelyingParty.Members { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + + public partial class Default : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Members/Default.aspx.designer.cs b/starterkits/WebFormsRelyingParty/Members/Default.aspx.designer.cs new file mode 100644 index 0000000..08fab2c --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Members/Default.aspx.designer.cs @@ -0,0 +1,16 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4918 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WebFormsOpenIdRelyingParty.Members { + + + public partial class Default { + } +} diff --git a/starterkits/WebFormsRelyingParty/Members/Web.config b/starterkits/WebFormsRelyingParty/Members/Web.config new file mode 100644 index 0000000..aafc323 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Members/Web.config @@ -0,0 +1,18 @@ +<?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/starterkits/WebFormsRelyingParty/Model.Designer.cs b/starterkits/WebFormsRelyingParty/Model.Designer.cs new file mode 100644 index 0000000..f34f21c --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Model.Designer.cs @@ -0,0 +1,494 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +[assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()] +[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "UserRole", "Role", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(WebFormsOpenIdRelyingParty.Role), "User", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(WebFormsOpenIdRelyingParty.User))] +[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("DatabaseModel", "UserAuthenticationToken", "User", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(WebFormsOpenIdRelyingParty.User), "AuthenticationToken", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(WebFormsOpenIdRelyingParty.AuthenticationToken))] + +// Original file name: +// Generation date: 10/8/2009 12:07:35 PM +namespace WebFormsOpenIdRelyingParty +{ + + /// <summary> + /// There are no comments for DatabaseEntities in the schema. + /// </summary> + public partial class DatabaseEntities : global::System.Data.Objects.ObjectContext + { + /// <summary> + /// Initializes a new DatabaseEntities object using the connection string found in the 'DatabaseEntities' section of the application configuration file. + /// </summary> + public DatabaseEntities() : + base("name=DatabaseEntities", "DatabaseEntities") + { + this.OnContextCreated(); + } + /// <summary> + /// Initialize a new DatabaseEntities object. + /// </summary> + public DatabaseEntities(string connectionString) : + base(connectionString, "DatabaseEntities") + { + this.OnContextCreated(); + } + /// <summary> + /// Initialize a new DatabaseEntities object. + /// </summary> + public DatabaseEntities(global::System.Data.EntityClient.EntityConnection connection) : + base(connection, "DatabaseEntities") + { + this.OnContextCreated(); + } + partial void OnContextCreated(); + /// <summary> + /// There are no comments for Role in the schema. + /// </summary> + public global::System.Data.Objects.ObjectQuery<Role> Role + { + get + { + if ((this._Role == null)) + { + this._Role = base.CreateQuery<Role>("[Role]"); + } + return this._Role; + } + } + private global::System.Data.Objects.ObjectQuery<Role> _Role; + /// <summary> + /// There are no comments for User in the schema. + /// </summary> + public global::System.Data.Objects.ObjectQuery<User> User + { + get + { + if ((this._User == null)) + { + this._User = base.CreateQuery<User>("[User]"); + } + return this._User; + } + } + private global::System.Data.Objects.ObjectQuery<User> _User; + /// <summary> + /// There are no comments for AuthenticationToken in the schema. + /// </summary> + public global::System.Data.Objects.ObjectQuery<AuthenticationToken> AuthenticationToken + { + get + { + if ((this._AuthenticationToken == null)) + { + this._AuthenticationToken = base.CreateQuery<AuthenticationToken>("[AuthenticationToken]"); + } + return this._AuthenticationToken; + } + } + private global::System.Data.Objects.ObjectQuery<AuthenticationToken> _AuthenticationToken; + /// <summary> + /// There are no comments for Role in the schema. + /// </summary> + public void AddToRole(Role role) + { + base.AddObject("Role", role); + } + /// <summary> + /// There are no comments for User in the schema. + /// </summary> + public void AddToUser(User user) + { + base.AddObject("User", user); + } + /// <summary> + /// There are no comments for AuthenticationToken in the schema. + /// </summary> + public void AddToAuthenticationToken(AuthenticationToken authenticationToken) + { + base.AddObject("AuthenticationToken", authenticationToken); + } + } + /// <summary> + /// There are no comments for DatabaseModel.AuthenticationToken in the schema. + /// </summary> + /// <KeyProperties> + /// Id + /// </KeyProperties> + [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="AuthenticationToken")] + [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] + [global::System.Serializable()] + public partial class AuthenticationToken : global::System.Data.Objects.DataClasses.EntityObject + { + /// <summary> + /// Create a new AuthenticationToken object. + /// </summary> + /// <param name="id">Initial value of Id.</param> + /// <param name="claimedIdentifier">Initial value of ClaimedIdentifier.</param> + public static AuthenticationToken CreateAuthenticationToken(int id, string claimedIdentifier) + { + AuthenticationToken authenticationToken = new AuthenticationToken(); + authenticationToken.Id = id; + authenticationToken.ClaimedIdentifier = claimedIdentifier; + return authenticationToken; + } + /// <summary> + /// There are no comments for Property Id in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public int Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this.ReportPropertyChanging("Id"); + this._Id = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("Id"); + this.OnIdChanged(); + } + } + private int _Id; + partial void OnIdChanging(int value); + partial void OnIdChanged(); + /// <summary> + /// There are no comments for Property ClaimedIdentifier in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string ClaimedIdentifier + { + get + { + return this._ClaimedIdentifier; + } + set + { + this.OnClaimedIdentifierChanging(value); + this.ReportPropertyChanging("ClaimedIdentifier"); + this._ClaimedIdentifier = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("ClaimedIdentifier"); + this.OnClaimedIdentifierChanged(); + } + } + private string _ClaimedIdentifier; + partial void OnClaimedIdentifierChanging(string value); + partial void OnClaimedIdentifierChanged(); + /// <summary> + /// There are no comments for Property FriendlyIdentifier in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string FriendlyIdentifier + { + get + { + return this._FriendlyIdentifier; + } + set + { + this.OnFriendlyIdentifierChanging(value); + this.ReportPropertyChanging("FriendlyIdentifier"); + this._FriendlyIdentifier = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); + this.ReportPropertyChanged("FriendlyIdentifier"); + this.OnFriendlyIdentifierChanged(); + } + } + private string _FriendlyIdentifier; + partial void OnFriendlyIdentifierChanging(string value); + partial void OnFriendlyIdentifierChanged(); + /// <summary> + /// There are no comments for User in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "UserAuthenticationToken", "User")] + [global::System.Xml.Serialization.XmlIgnoreAttribute()] + [global::System.Xml.Serialization.SoapIgnoreAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public User User + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.UserAuthenticationToken", "User").Value; + } + set + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.UserAuthenticationToken", "User").Value = value; + } + } + /// <summary> + /// There are no comments for User in the schema. + /// </summary> + [global::System.ComponentModel.BrowsableAttribute(false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.Data.Objects.DataClasses.EntityReference<User> UserReference + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("DatabaseModel.UserAuthenticationToken", "User"); + } + set + { + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<User>("DatabaseModel.UserAuthenticationToken", "User", value); + } + } + } + } + /// <summary> + /// There are no comments for DatabaseModel.Role in the schema. + /// </summary> + /// <KeyProperties> + /// Id + /// </KeyProperties> + [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="Role")] + [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] + [global::System.Serializable()] + public partial class Role : global::System.Data.Objects.DataClasses.EntityObject + { + /// <summary> + /// Create a new Role object. + /// </summary> + /// <param name="id">Initial value of Id.</param> + /// <param name="name">Initial value of Name.</param> + public static Role CreateRole(int id, string name) + { + Role role = new Role(); + role.Id = id; + role.Name = name; + return role; + } + /// <summary> + /// There are no comments for Property Id in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public int Id + { + get + { + return this._Id; + } + private set + { + this.OnIdChanging(value); + this.ReportPropertyChanging("Id"); + this._Id = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("Id"); + this.OnIdChanged(); + } + } + private int _Id; + partial void OnIdChanging(int value); + partial void OnIdChanged(); + /// <summary> + /// There are no comments for Property Name in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this.ReportPropertyChanging("Name"); + this._Name = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false); + this.ReportPropertyChanged("Name"); + this.OnNameChanged(); + } + } + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// <summary> + /// There are no comments for Users in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "UserRole", "User")] + [global::System.Xml.Serialization.XmlIgnoreAttribute()] + [global::System.Xml.Serialization.SoapIgnoreAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.Data.Objects.DataClasses.EntityCollection<User> Users + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<User>("DatabaseModel.UserRole", "User"); + } + set + { + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<User>("DatabaseModel.UserRole", "User", value); + } + } + } + } + /// <summary> + /// There are no comments for DatabaseModel.User in the schema. + /// </summary> + /// <KeyProperties> + /// Id + /// </KeyProperties> + [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="DatabaseModel", Name="User")] + [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] + [global::System.Serializable()] + public partial class User : global::System.Data.Objects.DataClasses.EntityObject + { + /// <summary> + /// Create a new User object. + /// </summary> + /// <param name="id">Initial value of Id.</param> + public static User CreateUser(int id) + { + User user = new User(); + user.Id = id; + return user; + } + /// <summary> + /// There are no comments for Property Id in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public int Id + { + get + { + return this._Id; + } + private set + { + this.OnIdChanging(value); + this.ReportPropertyChanging("Id"); + this._Id = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value); + this.ReportPropertyChanged("Id"); + this.OnIdChanged(); + } + } + private int _Id; + partial void OnIdChanging(int value); + partial void OnIdChanged(); + /// <summary> + /// There are no comments for Property FirstName in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string FirstName + { + get + { + return this._FirstName; + } + set + { + this.OnFirstNameChanging(value); + this.ReportPropertyChanging("FirstName"); + this._FirstName = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); + this.ReportPropertyChanged("FirstName"); + this.OnFirstNameChanged(); + } + } + private string _FirstName; + partial void OnFirstNameChanging(string value); + partial void OnFirstNameChanged(); + /// <summary> + /// There are no comments for Property LastName in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string LastName + { + get + { + return this._LastName; + } + set + { + this.OnLastNameChanging(value); + this.ReportPropertyChanging("LastName"); + this._LastName = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); + this.ReportPropertyChanged("LastName"); + this.OnLastNameChanged(); + } + } + private string _LastName; + partial void OnLastNameChanging(string value); + partial void OnLastNameChanged(); + /// <summary> + /// There are no comments for Property EmailAddress in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public string EmailAddress + { + get + { + return this._EmailAddress; + } + set + { + this.OnEmailAddressChanging(value); + this.ReportPropertyChanging("EmailAddress"); + this._EmailAddress = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true); + this.ReportPropertyChanged("EmailAddress"); + this.OnEmailAddressChanged(); + } + } + private string _EmailAddress; + partial void OnEmailAddressChanging(string value); + partial void OnEmailAddressChanged(); + /// <summary> + /// There are no comments for Roles in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "UserRole", "Role")] + [global::System.Xml.Serialization.XmlIgnoreAttribute()] + [global::System.Xml.Serialization.SoapIgnoreAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.Data.Objects.DataClasses.EntityCollection<Role> Roles + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Role>("DatabaseModel.UserRole", "Role"); + } + set + { + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Role>("DatabaseModel.UserRole", "Role", value); + } + } + } + /// <summary> + /// There are no comments for AuthenticationTokens in the schema. + /// </summary> + [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("DatabaseModel", "UserAuthenticationToken", "AuthenticationToken")] + [global::System.Xml.Serialization.XmlIgnoreAttribute()] + [global::System.Xml.Serialization.SoapIgnoreAttribute()] + [global::System.Runtime.Serialization.DataMemberAttribute()] + public global::System.Data.Objects.DataClasses.EntityCollection<AuthenticationToken> AuthenticationTokens + { + get + { + return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<AuthenticationToken>("DatabaseModel.UserAuthenticationToken", "AuthenticationToken"); + } + set + { + if ((value != null)) + { + ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<AuthenticationToken>("DatabaseModel.UserAuthenticationToken", "AuthenticationToken", value); + } + } + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Model.cs b/starterkits/WebFormsRelyingParty/Model.cs new file mode 100644 index 0000000..f471c97 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Model.cs @@ -0,0 +1,21 @@ +namespace WebFormsOpenIdRelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + + public partial class AuthenticationToken { + public bool IsInfoCard { + get { return this.ClaimedIdentifier.StartsWith(UriPrefixForInfoCard); } + } + + private static string UriPrefixForInfoCard { + get { return new Uri(HttpContext.Current.Request.Url, Global.ApplicationPath + "infocard/").AbsoluteUri; } + } + + public static string SynthesizeClaimedIdentifierFromInfoCard(string uniqueId) { + string synthesizedClaimedId = UriPrefixForInfoCard + Uri.EscapeDataString(uniqueId); + return synthesizedClaimedId; + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Model.edmx b/starterkits/WebFormsRelyingParty/Model.edmx new file mode 100644 index 0000000..c23b3df --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Model.edmx @@ -0,0 +1,225 @@ +<?xml version="1.0" encoding="utf-8"?> +<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"> + <!-- EF Runtime content --> + <edmx:Runtime> + <!-- SSDL content --> + <edmx:StorageModels> + <Schema Namespace="DatabaseModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl"> + <EntityContainer Name="DatabaseModelStoreContainer"> + <EntitySet Name="AuthenticationToken" EntityType="DatabaseModel.Store.AuthenticationToken" store:Type="Tables" Schema="dbo" /> + <EntitySet Name="Role" EntityType="DatabaseModel.Store.Role" store:Type="Tables" Schema="dbo" /> + <EntitySet Name="User" EntityType="DatabaseModel.Store.User" store:Type="Tables" Schema="dbo" /> + <EntitySet Name="UserRole" EntityType="DatabaseModel.Store.UserRole" store:Type="Tables" Schema="dbo" /> + <AssociationSet Name="FK_AuthenticationToken_User" Association="DatabaseModel.Store.FK_AuthenticationToken_User"> + <End Role="User" EntitySet="User" /> + <End Role="AuthenticationToken" EntitySet="AuthenticationToken" /> + </AssociationSet> + <AssociationSet Name="FK_UserRole_Role" Association="DatabaseModel.Store.FK_UserRole_Role"> + <End Role="Role" EntitySet="Role" /> + <End Role="UserRole" EntitySet="UserRole" /> + </AssociationSet> + <AssociationSet Name="FK_UserRole_User" Association="DatabaseModel.Store.FK_UserRole_User"> + <End Role="User" EntitySet="User" /> + <End Role="UserRole" EntitySet="UserRole" /> + </AssociationSet> + </EntityContainer> + <EntityType Name="AuthenticationToken"> + <Key> + <PropertyRef Name="Id" /> + </Key> + <Property Name="Id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /> + <Property Name="UserId" Type="int" Nullable="false" /> + <Property Name="OpenIdClaimedIdentifier" Type="nvarchar" Nullable="false" MaxLength="250" /> + <Property Name="OpenIdFriendlyIdentifier" Type="nvarchar" MaxLength="250" /> + </EntityType> + <EntityType Name="Role"> + <Key> + <PropertyRef Name="Id" /> + </Key> + <Property Name="Id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /> + <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" /> + </EntityType> + <EntityType Name="User"> + <Key> + <PropertyRef Name="Id" /> + </Key> + <Property Name="Id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" /> + <Property Name="FirstName" Type="nvarchar" MaxLength="50" /> + <Property Name="LastName" Type="nvarchar" MaxLength="50" /> + <Property Name="EmailAddress" Type="nvarchar" MaxLength="100" /> + </EntityType> + <EntityType Name="UserRole"> + <Key> + <PropertyRef Name="UserId" /> + <PropertyRef Name="RoleId" /> + </Key> + <Property Name="UserId" Type="int" Nullable="false" /> + <Property Name="RoleId" Type="int" Nullable="false" /> + </EntityType> + <Association Name="FK_AuthenticationToken_User"> + <End Role="User" Type="DatabaseModel.Store.User" Multiplicity="1"> + <OnDelete Action="Cascade" /> + </End> + <End Role="AuthenticationToken" Type="DatabaseModel.Store.AuthenticationToken" Multiplicity="*" /> + <ReferentialConstraint> + <Principal Role="User"> + <PropertyRef Name="Id" /> + </Principal> + <Dependent Role="AuthenticationToken"> + <PropertyRef Name="UserId" /> + </Dependent> + </ReferentialConstraint> + </Association> + <Association Name="FK_UserRole_Role"> + <End Role="Role" Type="DatabaseModel.Store.Role" Multiplicity="1"> + <OnDelete Action="Cascade" /> + </End> + <End Role="UserRole" Type="DatabaseModel.Store.UserRole" Multiplicity="*" /> + <ReferentialConstraint> + <Principal Role="Role"> + <PropertyRef Name="Id" /> + </Principal> + <Dependent Role="UserRole"> + <PropertyRef Name="RoleId" /> + </Dependent> + </ReferentialConstraint> + </Association> + <Association Name="FK_UserRole_User"> + <End Role="User" Type="DatabaseModel.Store.User" Multiplicity="1"> + <OnDelete Action="Cascade" /> + </End> + <End Role="UserRole" Type="DatabaseModel.Store.UserRole" Multiplicity="*" /> + <ReferentialConstraint> + <Principal Role="User"> + <PropertyRef Name="Id" /> + </Principal> + <Dependent Role="UserRole"> + <PropertyRef Name="UserId" /> + </Dependent> + </ReferentialConstraint> + </Association> + </Schema></edmx:StorageModels> + <!-- CSDL content --> + <edmx:ConceptualModels> + <Schema Namespace="DatabaseModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm"> + <EntityContainer Name="DatabaseEntities"> + <EntitySet Name="Role" EntityType="DatabaseModel.Role" /> + <EntitySet Name="User" EntityType="DatabaseModel.User" /> + <AssociationSet Name="UserRole" Association="DatabaseModel.UserRole"> + <End Role="Role" EntitySet="Role" /> + <End Role="User" EntitySet="User" /> + </AssociationSet> + <EntitySet Name="AuthenticationToken" EntityType="DatabaseModel.AuthenticationToken" /> + <AssociationSet Name="UserAuthenticationToken" Association="DatabaseModel.UserAuthenticationToken"> + <End Role="User" EntitySet="User" /> + <End Role="AuthenticationToken" EntitySet="AuthenticationToken" /></AssociationSet> + </EntityContainer> + <EntityType Name="AuthenticationToken" Abstract="false"> + <Key> + <PropertyRef Name="Id" /></Key> + <Property Name="Id" Type="Int32" Nullable="false" a:SetterAccess="Public" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" /> + <NavigationProperty Name="User" Relationship="DatabaseModel.UserAuthenticationToken" FromRole="AuthenticationToken" ToRole="User" /> + <Property Name="ClaimedIdentifier" Type="String" Nullable="false" /> + <Property Name="FriendlyIdentifier" Type="String" Nullable="true" /></EntityType> + <EntityType Name="Role"> + <Key> + <PropertyRef Name="Id" /> + </Key> + <Property Name="Id" Type="Int32" Nullable="false" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" /> + <Property Name="Name" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" /> + <NavigationProperty Name="Users" Relationship="DatabaseModel.UserRole" FromRole="Role" ToRole="User" /> + </EntityType> + <EntityType Name="User"> + <Key> + <PropertyRef Name="Id" /> + </Key> + <Property Name="Id" Type="Int32" Nullable="false" a:SetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" /> + <Property Name="FirstName" Type="String" MaxLength="50" Unicode="true" FixedLength="false" /> + <Property Name="LastName" Type="String" MaxLength="50" Unicode="true" FixedLength="false" /> + <Property Name="EmailAddress" Type="String" MaxLength="100" Unicode="true" FixedLength="false" /> + <NavigationProperty Name="Roles" Relationship="DatabaseModel.UserRole" FromRole="User" ToRole="Role" /> + <NavigationProperty Name="AuthenticationTokens" Relationship="DatabaseModel.UserAuthenticationToken" FromRole="User" ToRole="AuthenticationToken" /></EntityType> + <Association Name="UserRole"> + <End Role="Role" Type="DatabaseModel.Role" Multiplicity="*" /> + <End Role="User" Type="DatabaseModel.User" Multiplicity="*" /> + </Association> + <Association Name="UserAuthenticationToken"> + <End Type="DatabaseModel.User" Role="User" Multiplicity="1" /> + <End Type="DatabaseModel.AuthenticationToken" Role="AuthenticationToken" Multiplicity="*" /></Association></Schema> + </edmx:ConceptualModels> + <!-- C-S mapping content --> + <edmx:Mappings> + <Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS"> + <EntityContainerMapping StorageEntityContainer="DatabaseModelStoreContainer" CdmEntityContainer="DatabaseEntities"> + <EntitySetMapping Name="Role"> + <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.Role)"> + <MappingFragment StoreEntitySet="Role"> + <ScalarProperty Name="Id" ColumnName="Id" /> + <ScalarProperty Name="Name" ColumnName="Name" /> + </MappingFragment> + </EntityTypeMapping> + </EntitySetMapping> + <EntitySetMapping Name="User"> + <EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.User)"> + <MappingFragment StoreEntitySet="User"> + <ScalarProperty Name="Id" ColumnName="Id" /> + <ScalarProperty Name="FirstName" ColumnName="FirstName" /> + <ScalarProperty Name="LastName" ColumnName="LastName" /> + <ScalarProperty Name="EmailAddress" ColumnName="EmailAddress" /> + </MappingFragment> + </EntityTypeMapping> + </EntitySetMapping> + <AssociationSetMapping Name="UserRole" TypeName="DatabaseModel.UserRole" StoreEntitySet="UserRole"> + <EndProperty Name="Role"> + <ScalarProperty Name="Id" ColumnName="RoleId" /> + </EndProperty> + <EndProperty Name="User"> + <ScalarProperty Name="Id" ColumnName="UserId" /> + </EndProperty> + </AssociationSetMapping> + <EntitySetMapping Name="AuthenticationToken"><EntityTypeMapping TypeName="IsTypeOf(DatabaseModel.AuthenticationToken)"> + <MappingFragment StoreEntitySet="AuthenticationToken"> + <ScalarProperty Name="FriendlyIdentifier" ColumnName="OpenIdFriendlyIdentifier" /> + <ScalarProperty Name="ClaimedIdentifier" ColumnName="OpenIdClaimedIdentifier" /> + <ScalarProperty Name="Id" ColumnName="Id" /> + </MappingFragment> + </EntityTypeMapping> + </EntitySetMapping> + <AssociationSetMapping Name="UserAuthenticationToken" TypeName="DatabaseModel.UserAuthenticationToken" StoreEntitySet="AuthenticationToken"> + <EndProperty Name="AuthenticationToken"> + <ScalarProperty Name="Id" ColumnName="Id" /></EndProperty> + <EndProperty Name="User"> + <ScalarProperty Name="Id" ColumnName="UserId" /></EndProperty></AssociationSetMapping> + </EntityContainerMapping> + </Mapping> + </edmx:Mappings> + </edmx:Runtime> + <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) --> + <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx"> + <edmx:Connection> + <DesignerInfoPropertySet> + <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" /> + </DesignerInfoPropertySet> + </edmx:Connection> + <edmx:Options> + <DesignerInfoPropertySet> + <DesignerProperty Name="ValidateOnBuild" Value="true" /> + </DesignerInfoPropertySet> + </edmx:Options> + <!-- Diagram content (shape and connector positions) --> + <edmx:Diagrams> + <Diagram Name="Model"> + <EntityTypeShape EntityType="DatabaseModel.AuthenticationToken" Width="1.875" PointX="5.25" PointY="1.125" Height="1.4033821614583335" IsExpanded="true" /> + <EntityTypeShape EntityType="DatabaseModel.Role" Width="1.5" PointX="0.75" PointY="1.25" Height="1.5956835937500002" IsExpanded="true" /> + <EntityTypeShape EntityType="DatabaseModel.User" Width="1.75" PointX="2.875" PointY="0.875" Height="2.364889322916667" IsExpanded="true" /> + <AssociationConnector Association="DatabaseModel.UserRole" ManuallyRouted="false"> + <ConnectorPoint PointX="2.25" PointY="2.0478417968750002" /> + <ConnectorPoint PointX="2.875" PointY="2.0478417968750002" /></AssociationConnector> + <InheritanceConnector EntityType="DatabaseModel.AuthenticationToken"> + <ConnectorPoint PointX="6.5625" PointY="3.375" /> + <ConnectorPoint PointX="6.5625" PointY="2.9129850260416665" /></InheritanceConnector> + <AssociationConnector Association="DatabaseModel.UserAuthenticationToken"> + <ConnectorPoint PointX="4.625" PointY="1.8266910807291668" /> + <ConnectorPoint PointX="5.25" PointY="1.8266910807291668" /></AssociationConnector></Diagram></edmx:Diagrams> + </edmx:Designer> +</edmx:Edmx>
\ No newline at end of file diff --git a/starterkits/WebFormsRelyingParty/MyTemplate.vstemplate b/starterkits/WebFormsRelyingParty/MyTemplate.vstemplate new file mode 100644 index 0000000..4cea3f4 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/MyTemplate.vstemplate @@ -0,0 +1,83 @@ +<VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project"> + <TemplateData> + <Name>ASP.NET OpenID-InfoCard RP</Name> + <RequiredFrameworkVersion>3.5</RequiredFrameworkVersion> + <Description>An ASP.NET web forms web site that accepts OpenID and InfoCard logins</Description> + <ProjectType>CSharp</ProjectType> + <ProjectSubType>Web</ProjectSubType> + <NumberOfParentCategoriesToRollUp>2</NumberOfParentCategoriesToRollUp> + <SortOrder>1000</SortOrder> + <CreateNewFolder>true</CreateNewFolder> + <DefaultName>WebRPApplication</DefaultName> + <ProvideDefaultName>true</ProvideDefaultName> + <LocationField>Enabled</LocationField> + <EnableLocationBrowseButton>true</EnableLocationBrowseButton> + <Icon>__TemplateIcon.ico</Icon> + </TemplateData> + <TemplateContent> + <Project TargetFileName="WebFormsRelyingParty.csproj" File="WebFormsRelyingParty.csproj" ReplaceParameters="true"> + <Folder Name="Admin" TargetFolderName="Admin"> + <ProjectItem ReplaceParameters="true" TargetFileName="Admin.Master">Admin.Master</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Admin.Master.cs">Admin.Master.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Admin.Master.designer.cs">Admin.Master.designer.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="CreateDatabase.sql">CreateDatabase.sql</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Default.aspx">Default.aspx</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Default.aspx.cs">Default.aspx.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Default.aspx.designer.cs">Default.aspx.designer.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Web.config">Web.config</ProjectItem> + </Folder> + <Folder Name="App_Data" TargetFolderName="App_Data" /> + <Folder Name="bin" TargetFolderName="bin"> + <ProjectItem ReplaceParameters="false" TargetFileName="DotNetOpenAuth.dll">DotNetOpenAuth.dll</ProjectItem> + <ProjectItem ReplaceParameters="false" TargetFileName="DotNetOpenAuth.pdb">DotNetOpenAuth.pdb</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="DotNetOpenAuth.xml">DotNetOpenAuth.xml</ProjectItem> + <ProjectItem ReplaceParameters="false" TargetFileName="log4net.dll">log4net.dll</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="log4net.xml">log4net.xml</ProjectItem> + </Folder> + <Folder Name="Code" TargetFolderName="Code"> + <ProjectItem ReplaceParameters="true" TargetFileName="DataRoleProvider.cs">DataRoleProvider.cs</ProjectItem> + </Folder> + <ProjectItem ReplaceParameters="true" TargetFileName="Default.aspx">Default.aspx</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Default.aspx.cs">Default.aspx.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Default.aspx.designer.cs">Default.aspx.designer.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Global.asax">Global.asax</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Global.asax.cs">Global.asax.cs</ProjectItem> + <Folder Name="images" TargetFolderName="images"> + <ProjectItem ReplaceParameters="false" TargetFileName="google.gif">google.gif</ProjectItem> + <ProjectItem ReplaceParameters="false" TargetFileName="infocard_23x16.png">infocard_23x16.png</ProjectItem> + <ProjectItem ReplaceParameters="false" TargetFileName="openid_login.gif">openid_login.gif</ProjectItem> + <ProjectItem ReplaceParameters="false" TargetFileName="yahoo.gif">yahoo.gif</ProjectItem> + <ProjectItem ReplaceParameters="false" TargetFileName="yahoo_login.png">yahoo_login.png</ProjectItem> + </Folder> + <ProjectItem ReplaceParameters="true" TargetFileName="Login.aspx">Login.aspx</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Login.aspx.cs">Login.aspx.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Login.aspx.designer.cs">Login.aspx.designer.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Logout.aspx">Logout.aspx</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Logout.aspx.cs">Logout.aspx.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Logout.aspx.designer.cs">Logout.aspx.designer.cs</ProjectItem> + <Folder Name="Members" TargetFolderName="Members"> + <ProjectItem ReplaceParameters="true" TargetFileName="AccountInfo.aspx">AccountInfo.aspx</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="AccountInfo.aspx.cs">AccountInfo.aspx.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="AccountInfo.aspx.designer.cs">AccountInfo.aspx.designer.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Default.aspx">Default.aspx</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Default.aspx.cs">Default.aspx.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Default.aspx.designer.cs">Default.aspx.designer.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Web.config">Web.config</ProjectItem> + </Folder> + <ProjectItem ReplaceParameters="true" TargetFileName="Model.cs">Model.cs</ProjectItem> + <ProjectItem ReplaceParameters="false" TargetFileName="Model.edmx">Model.edmx</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Model.Designer.cs">Model.Designer.cs</ProjectItem> + <Folder Name="Properties" TargetFolderName="Properties"> + <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem> + </Folder> + <ProjectItem ReplaceParameters="true" TargetFileName="Setup.aspx">Setup.aspx</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Setup.aspx.cs">Setup.aspx.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Setup.aspx.designer.cs">Setup.aspx.designer.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Site.Master">Site.Master</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Site.Master.cs">Site.Master.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Site.Master.designer.cs">Site.Master.designer.cs</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Standard.css">Standard.css</ProjectItem> + <ProjectItem ReplaceParameters="true" TargetFileName="Web.config">Web.config</ProjectItem> + </Project> + </TemplateContent> +</VSTemplate>
\ No newline at end of file diff --git a/starterkits/WebFormsRelyingParty/Properties/AssemblyInfo.cs b/starterkits/WebFormsRelyingParty/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0f26ac9 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Properties/AssemblyInfo.cs @@ -0,0 +1,41 @@ +//----------------------------------------------------------------------- +// <copyright file="AssemblyInfo.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +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("WebFormsOpenIdRelyingParty")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WebFormsOpenIdRelyingParty")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[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/starterkits/WebFormsRelyingParty/Setup.aspx b/starterkits/WebFormsRelyingParty/Setup.aspx new file mode 100644 index 0000000..996a72d --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Setup.aspx @@ -0,0 +1,42 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Setup.aspx.cs" Inherits="WebFormsOpenIdRelyingParty.Setup" %> + +<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.OpenId.RelyingParty" + TagPrefix="rp" %> +<!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 RP one-time setup</title> +</head> +<body> + <form id="form1" runat="server"> + <h2> + First steps: + </h2> + <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> + <asp:View ID="View1" runat="server"> + <p> + Before you can use this site, you must create your SQL database that will store + your user accounts and add an admin account to that database. + </p> + <rp:OpenIdLogin runat="server" ButtonText="Create database" ID="openidLogin" + OnLoggingIn="openidLogin_LoggingIn" + TabIndex="1" + ButtonToolTip="Clicking this button will create the database and initialize the OpenID you specify as an admin of this web site." + RegisterText="get an OpenID" /> + <asp:Label ID="noOPIdentifierLabel" Visible="false" EnableViewState="false" ForeColor="Red" Font-Bold="true" runat="server" Text="Sorry. To help your admin account remain functional when you push this web site to production, directed identity is disabled on this page. Please use your personal claimed identifier." /> + </asp:View> + <asp:View ID="View2" runat="server"> + <p> + Your database has been successfully initialized. + </p> + <p> + <b>Remember to delete this Setup.aspx page.</b> + </p> + <p> + Visit the <a href="Default.aspx">home page</a>. + </p> + </asp:View> + </asp:MultiView> + </form> +</body> +</html> diff --git a/starterkits/WebFormsRelyingParty/Setup.aspx.cs b/starterkits/WebFormsRelyingParty/Setup.aspx.cs new file mode 100644 index 0000000..e6da59f --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Setup.aspx.cs @@ -0,0 +1,57 @@ +namespace WebFormsOpenIdRelyingParty { + using System; + using System.Collections.Generic; + using System.Globalization; + using System.IO; + using System.Linq; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.RelyingParty; + using Microsoft.SqlServer.Management.Common; + using Microsoft.SqlServer.Management.Smo; + + public partial class Setup : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + if (!Page.IsPostBack) { + openidLogin.Focus(); + } + } + + protected void openidLogin_LoggingIn(object sender, OpenIdEventArgs e) { + // We don't actually want to log in... we just want the claimed identifier. + e.Cancel = true; + if (e.IsDirectedIdentity) { + noOPIdentifierLabel.Visible = true; + } else { + this.CreateDatabase(e.ClaimedIdentifier, openidLogin.Text); + this.MultiView1.ActiveViewIndex = 1; + } + } + + private void CreateDatabase(Identifier claimedId, string friendlyId) { + const string SqlFormat = @" +CREATE DATABASE [{0}] ON (NAME='{0}', FILENAME='{0}') +GO +USE ""{0}"" +GO +{1} +EXEC [dbo].[AddUser] 'admin', 'admin', '{2}', '{3}' +GO +"; + string databasePath = HttpContext.Current.Server.MapPath("~/App_Data/Database.mdf"); + string schemaSql = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Admin/CreateDatabase.sql")); + string sql = string.Format(CultureInfo.InvariantCulture, SqlFormat, databasePath, schemaSql, claimedId, friendlyId); + + var serverConnection = new ServerConnection(".\\sqlexpress"); + try { + serverConnection.ExecuteNonQuery(sql); + var server = new Server(serverConnection); + server.DetachDatabase(databasePath, true); + } finally { + serverConnection.Disconnect(); + } + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Setup.aspx.designer.cs b/starterkits/WebFormsRelyingParty/Setup.aspx.designer.cs new file mode 100644 index 0000000..0d93871 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Setup.aspx.designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WebFormsOpenIdRelyingParty { + + + public partial class Setup { + + /// <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> + /// MultiView1 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 MultiView1; + + /// <summary> + /// View1 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 View1; + + /// <summary> + /// openidLogin control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::DotNetOpenAuth.OpenId.RelyingParty.OpenIdLogin openidLogin; + + /// <summary> + /// noOPIdentifierLabel 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 noOPIdentifierLabel; + + /// <summary> + /// View2 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 View2; + } +} diff --git a/starterkits/WebFormsRelyingParty/Site.Master b/starterkits/WebFormsRelyingParty/Site.Master new file mode 100644 index 0000000..a489150 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Site.Master @@ -0,0 +1,32 @@ +<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WebFormsOpenIdRelyingParty.Site" %> + +<%@ Import Namespace="WebFormsOpenIdRelyingParty" %> +<%@ Import Namespace="System.Linq" %> +<!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><%=Page.Title %></title> + <link href="Standard.css" rel="stylesheet" type="text/css" /> + <asp:ContentPlaceHolder ID="head" runat="server"> + </asp:ContentPlaceHolder> +</head> +<body> + <form id="form1" runat="server"> + <div style="float: right"> + <asp:LoginView runat="server"> + <LoggedInTemplate> + <%= Global.DataContext.AuthenticationToken.First(token => token.ClaimedIdentifier == Page.User.Identity.Name).FriendlyIdentifier %> + | <asp:HyperLink runat="server" NavigateUrl="~/" Text="Home" /> | <asp:HyperLink + runat="server" NavigateUrl="~/Members/AccountInfo.aspx" Text="Account" /> | + </LoggedInTemplate> + </asp:LoginView> + <asp:LoginStatus ID="LoginStatus1" runat="server" /> + </div> + <div> + <h1><asp:HyperLink runat="server" NavigateUrl="~/" Text="Adventure Works" /></h1> + <asp:ContentPlaceHolder ID="Body" runat="server"> + </asp:ContentPlaceHolder> + </div> + </form> +</body> +</html> diff --git a/starterkits/WebFormsRelyingParty/Site.Master.cs b/starterkits/WebFormsRelyingParty/Site.Master.cs new file mode 100644 index 0000000..a865893 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Site.Master.cs @@ -0,0 +1,19 @@ +//----------------------------------------------------------------------- +// <copyright file="Site.Master.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsOpenIdRelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + + public partial class Site : System.Web.UI.MasterPage { + protected void Page_Load(object sender, EventArgs e) { + } + } +} diff --git a/starterkits/WebFormsRelyingParty/Site.Master.designer.cs b/starterkits/WebFormsRelyingParty/Site.Master.designer.cs new file mode 100644 index 0000000..4f1e48a --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Site.Master.designer.cs @@ -0,0 +1,52 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4918 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WebFormsOpenIdRelyingParty { + + + public partial class Site { + + /// <summary> + /// head 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 head; + + /// <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> + /// LoginStatus1 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.LoginStatus LoginStatus1; + + /// <summary> + /// Body 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 Body; + } +} diff --git a/starterkits/WebFormsRelyingParty/Standard.css b/starterkits/WebFormsRelyingParty/Standard.css new file mode 100644 index 0000000..f0b1d8e --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Standard.css @@ -0,0 +1,67 @@ +body +{ + font-family: Cambria, Arial, Times New Roman; + font-size: 12pt; +} + +h1 a +{ + text-decoration: none; + color: Black; +} + +div.OpenIdButtons +{ + margin-bottom: 10px; +} + +div.OpenIdButtons span.OpenIdButton +{ + margin-left: 2px; + margin-right: 2px; + display: table; + float: left; + width: 92px; + height: 64px; + border: solid 1px lightgray; + text-align: center; + vertical-align: middle; + cursor: pointer; +} + +div.OpenIdButtons span.OpenIdButton span +{ + margin: 0; + padding: 0; + top: 50%; + display: table-cell; + vertical-align: middle; +} + +div.OpenIdButtons span.OpenIdButton object +{ + height: 0px; +} + +div.OpenIdButtons span.OpenIdButton div +{ + display: inline-block; + margin: 0; + padding: 0; +} + +div.OpenIdBox +{ + margin-top: 10px; + clear: left; +} + +ul.AuthTokens li.OpenID +{ + list-style-image: url(../images/openid_login.gif); +} + +ul.AuthTokens li.InfoCard +{ + list-style-image: url(../images/infocard_23x16.png); +} diff --git a/starterkits/WebFormsRelyingParty/Web.config b/starterkits/WebFormsRelyingParty/Web.config new file mode 100644 index 0000000..757a2c5 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/Web.config @@ -0,0 +1,187 @@ +<?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" /> + <section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true" /> + <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" /> + <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> + <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" /> + <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> + <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> + <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> + </sectionGroup> + </sectionGroup> + </sectionGroup> + </configSections> + <!-- 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. + It is also required to put the Uri class into RFC 3986 escaping mode, which OpenID and OAuth require. --> + <uri> + <idn enabled="All" /> + <iriParsing enabled="true" /> + </uri> + <system.net> + <defaultProxy enabled="true" /> + <settings> + <!-- This setting causes .NET to check certificate revocation lists (CRL) + before trusting HTTPS certificates. But this setting tends to not + be allowed in shared hosting environments. --> + <servicePointManager checkCertificateRevocationList="true" /> + </settings> + </system.net> + <!-- this is an optional configuration section where aspects of dotnetopenauth can be customized --> + <dotNetOpenAuth> + <openid> + <relyingParty> + <behaviors> + <!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible + with OPs that use Attribute Exchange (in various formats). --> + <add type="DotNetOpenAuth.OpenId.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth" /> + </behaviors> + </relyingParty> + </openid> + <messaging> + <untrustedWebRequest> + <whitelistHosts> + <!-- since this is a sample, and will often be used with localhost --> + <add name="localhost" /> + </whitelistHosts> + </untrustedWebRequest> + </messaging> + </dotNetOpenAuth> + <!-- 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> + <!-- Setup the root category, add the appenders and set the default level --> + <root> + <level value="WARN" /> + <appender-ref ref="RollingFileAppender" /> + </root> + <!-- Specify the level for some specific categories --> + <logger name="DotNetOpenAuth"> + <level value="WARN" /> + </logger> + </log4net> + <appSettings /> + <connectionStrings> + <add name="DatabaseEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" /> + </connectionStrings> + <system.web> + <!-- + Set compilation debug="true" to insert debugging + symbols into the compiled page. Because this + affects performance, set this value to true only + during development. + --> + <compilation debug="true"> + <assemblies> + <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> + <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> + <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> + <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <add assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> + </assemblies> + </compilation> + <!-- + The <authentication> section enables configuration + of the security authentication mode used by + ASP.NET to identify an incoming user. + --> + <authentication mode="Forms"> + <forms loginUrl="~/login.aspx" /> + </authentication> + <!-- + The <customErrors> section enables configuration + of what to do if/when an unhandled error occurs + during the execution of a request. Specifically, + it enables developers to configure html error pages + to be displayed in place of a error stack trace. + + <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> + <error statusCode="403" redirect="NoAccess.htm" /> + <error statusCode="404" redirect="FileNotFound.htm" /> + </customErrors> + --> + <pages> + <controls> + <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + </controls> + </pages> + <httpHandlers> + <remove verb="*" path="*.asmx" /> + <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" /> + </httpHandlers> + <httpModules> + <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + </httpModules> + <roleManager enabled="true" defaultProvider="Database"> + <providers> + <add name="Database" type="WebFormsOpenIdRelyingParty.Code.DataRoleProvider" /> + </providers> + </roleManager> + </system.web> + <system.codedom> + <compilers> + <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <providerOption name="CompilerVersion" value="v3.5" /> + <providerOption name="WarnAsError" value="false" /> + </compiler> + </compilers> + </system.codedom> + <!-- + The system.webServer section is required for running ASP.NET AJAX under Internet + Information Services 7.0. It is not necessary for previous version of IIS. + --> + <system.webServer> + <validation validateIntegratedModeConfiguration="false" /> + <modules> + <remove name="ScriptModule" /> + <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + </modules> + <handlers> + <remove name="WebServiceHandlerFactory-Integrated" /> + <remove name="ScriptHandlerFactory" /> + <remove name="ScriptHandlerFactoryAppServices" /> + <remove name="ScriptResource" /> + <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> + </handlers> + </system.webServer> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" /> + <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" /> + <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> + <location path="default.aspx"> + <system.web> + <authorization> + <allow users="*" /> + </authorization> + </system.web> + </location> +</configuration>
\ No newline at end of file diff --git a/starterkits/WebFormsRelyingParty/WebFormsRelyingParty.csproj b/starterkits/WebFormsRelyingParty/WebFormsRelyingParty.csproj new file mode 100644 index 0000000..a2982c1 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/WebFormsRelyingParty.csproj @@ -0,0 +1,230 @@ +<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.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{A78F8FC6-7B03-4230-BE41-761E400D6810}</ProjectGuid> + <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>WebFormsOpenIdRelyingParty</RootNamespace> + <AssemblyName>WebFormsOpenIdRelyingParty</AssemblyName> + <TargetFrameworkVersion>v3.5</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="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\log4net.dll</HintPath> + </Reference> + <Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" /> + <Reference Include="Microsoft.SqlServer.Smo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" /> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.Entity"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Runtime.Serialization"> + <RequiredTargetFramework>3.0</RequiredTargetFramework> + </Reference> + <Reference Include="System.Security" /> + <Reference Include="System.ServiceModel"> + <RequiredTargetFramework>3.0</RequiredTargetFramework> + </Reference> + <Reference Include="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\Windows\assembly\GAC_MSIL\System.Web.Entity\3.5.0.0__b77a5c561934e089\System.Web.Entity.dll</HintPath> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Web.Extensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <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="Members\AccountInfo.aspx" /> + <Content Include="Default.aspx" /> + <Content Include="Login.aspx" /> + <Content Include="Web.config" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Members\AccountInfo.aspx.cs"> + <DependentUpon>AccountInfo.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="Members\AccountInfo.aspx.designer.cs"> + <DependentUpon>AccountInfo.aspx</DependentUpon> + </Compile> + <Compile Include="Admin\Admin.Master.cs"> + <DependentUpon>Admin.Master</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="Admin\Admin.Master.designer.cs"> + <DependentUpon>Admin.Master</DependentUpon> + </Compile> + <Compile Include="Admin\Default.aspx.cs"> + <DependentUpon>Default.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="Admin\Default.aspx.designer.cs"> + <DependentUpon>Default.aspx</DependentUpon> + </Compile> + <Compile Include="Default.aspx.cs"> + <SubType>ASPXCodeBehind</SubType> + <DependentUpon>Default.aspx</DependentUpon> + </Compile> + <Compile Include="Default.aspx.designer.cs"> + <DependentUpon>Default.aspx</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="Logout.aspx.cs"> + <DependentUpon>Logout.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="Logout.aspx.designer.cs"> + <DependentUpon>Logout.aspx</DependentUpon> + </Compile> + <Compile Include="Members\Default.aspx.cs"> + <DependentUpon>Default.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="Members\Default.aspx.designer.cs"> + <DependentUpon>Default.aspx</DependentUpon> + </Compile> + <Compile Include="Model.cs" /> + <Compile Include="Model.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Model.edmx</DependentUpon> + </Compile> + <Compile Include="Properties\AssemblyInfo.cs" /> + <EntityDeploy Include="Model.edmx"> + <Generator>EntityModelCodeGenerator</Generator> + <LastGenOutput>Model.Designer.cs</LastGenOutput> + </EntityDeploy> + <Compile Include="Code\DataRoleProvider.cs"> + </Compile> + <Compile Include="Setup.aspx.cs"> + <DependentUpon>Setup.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="Setup.aspx.designer.cs"> + <DependentUpon>Setup.aspx</DependentUpon> + </Compile> + <Compile Include="Site.Master.cs"> + <DependentUpon>Site.Master</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="Site.Master.designer.cs"> + <DependentUpon>Site.Master</DependentUpon> + </Compile> + </ItemGroup> + <ItemGroup> + <Service Include="{3259AA49-8AA1-44D3-9025-A0B520596A8C}" /> + </ItemGroup> + <ItemGroup> + <Content Include="Admin\Default.aspx" /> + <Content Include="Admin\Web.config" /> + <Content Include="Global.asax" /> + <Content Include="Site.Master" /> + </ItemGroup> + <ItemGroup> + <Content Include="Admin\Admin.Master" /> + <Content Include="images\google.gif" /> + <Content Include="images\yahoo.gif" /> + <Content Include="Standard.css" /> + </ItemGroup> + <ItemGroup> + <Content Include="images\infocard_23x16.png" /> + <Content Include="images\openid_login.gif" /> + <Content Include="images\yahoo_login.png" /> + <Content Include="Logout.aspx" /> + <Content Include="Members\Default.aspx" /> + <Content Include="Members\Web.config" /> + <Content Include="Setup.aspx" /> + </ItemGroup> + <ItemGroup> + <None Include="Admin\CreateDatabase.sql" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\src\DotNetOpenAuth\DotNetOpenAuth.csproj"> + <Project>{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}</Project> + <Name>DotNetOpenAuth</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Folder Include="App_Data\" /> + </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>54189</DevelopmentServerPort> + <DevelopmentServerVPath>/</DevelopmentServerVPath> + <IISUrl> + </IISUrl> + <NTLMAuthentication>False</NTLMAuthentication> + <UseCustomServer>False</UseCustomServer> + <CustomServerUrl> + </CustomServerUrl> + <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> + </WebProjectProperties> + </FlavorProperties> + </VisualStudio> + </ProjectExtensions> +</Project>
\ No newline at end of file diff --git a/starterkits/WebFormsRelyingParty/images/google.gif b/starterkits/WebFormsRelyingParty/images/google.gif Binary files differnew file mode 100644 index 0000000..1b6cd07 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/images/google.gif diff --git a/starterkits/WebFormsRelyingParty/images/infocard_23x16.png b/starterkits/WebFormsRelyingParty/images/infocard_23x16.png Binary files differnew file mode 100644 index 0000000..9dbea9f --- /dev/null +++ b/starterkits/WebFormsRelyingParty/images/infocard_23x16.png diff --git a/starterkits/WebFormsRelyingParty/images/openid_login.gif b/starterkits/WebFormsRelyingParty/images/openid_login.gif Binary files differnew file mode 100644 index 0000000..cde836c --- /dev/null +++ b/starterkits/WebFormsRelyingParty/images/openid_login.gif diff --git a/starterkits/WebFormsRelyingParty/images/yahoo.gif b/starterkits/WebFormsRelyingParty/images/yahoo.gif Binary files differnew file mode 100644 index 0000000..42adbfa --- /dev/null +++ b/starterkits/WebFormsRelyingParty/images/yahoo.gif diff --git a/starterkits/WebFormsRelyingParty/images/yahoo_login.png b/starterkits/WebFormsRelyingParty/images/yahoo_login.png Binary files differnew file mode 100644 index 0000000..476fa64 --- /dev/null +++ b/starterkits/WebFormsRelyingParty/images/yahoo_login.png |