diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-12-26 07:04:33 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-12-26 07:04:33 -0800 |
commit | 8a677d2d2320e96e4b70e994e978804a5cc358fc (patch) | |
tree | 25353095c2f3d5bbb940d47e8f612cafcdd4aa44 | |
parent | ce37861c9507e338fc81314898b3a30888310b55 (diff) | |
parent | 72f5ee12a341eaca93075fb0f4705bec7cc84631 (diff) | |
download | DotNetOpenAuth-8a677d2d2320e96e4b70e994e978804a5cc358fc.zip DotNetOpenAuth-8a677d2d2320e96e4b70e994e978804a5cc358fc.tar.gz DotNetOpenAuth-8a677d2d2320e96e4b70e994e978804a5cc358fc.tar.bz2 |
Merge branch 'reports' into v3.3
Conflicts:
projecttemplates/WebFormsRelyingParty/Web.config
src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs
90 files changed, 1743 insertions, 541 deletions
@@ -18,3 +18,4 @@ PrecompiledWeb *.swx .dotest *.Publish.xml +*.dbproj.schemaview @@ -34,7 +34,6 @@ <DirtyDirectories Include=" $(ProjectRoot)bin; $(ProjectRoot)**\obj; - $(ProjectRoot)doc\api; $(DropsRoot); $(ProjectRoot)src\PrecompiledWeb; $(ProjectTemplatesLayoutPath); @@ -140,6 +139,9 @@ </Target> <Target Name="BuildProjectTemplates"> + <!-- Deploy the latest SQL script first, so that the class library can embed the latest version. --> + <MSBuild Projects="$(ProjectRoot)projecttemplates\RelyingPartyDatabase\RelyingPartyDatabase.dbproj" Targets="Build;Deploy" /> + <MSBuild Projects="@(ProjectTemplates)" /> </Target> @@ -168,9 +170,13 @@ or '%(Extension)' == '.Master' or '%(Extension)' == '.aspx' or '%(Extension)' == '.asax' + or '%(Extension)' == '.ashx' "> <BeforeTokens>%(RecursiveDir)</BeforeTokens> <AfterTokens>$safeprojectname$</AfterTokens> + <!-- Projects can get changed after the transform+copy operation, so don't skip copying them. --> + <SkipUnchangedFiles Condition="'%(Extension)' != '.csproj'">true</SkipUnchangedFiles> + <SkipUnchangedFiles Condition="'%(Extension)' == '.csproj'">false</SkipUnchangedFiles> </_ProjectTemplatesTransformSource> <ProjectTemplatesSource Remove="@(_ProjectTemplatesTransformSource)" /> @@ -188,6 +194,7 @@ <!-- Include the unified, signed version of the library --> <ProjectTemplateLibraries Include="$(ILMergeOutputAssembly)" /> <ProjectTemplateLibraries Include="$(ILMergeOutputAssemblyDirectory)$(ProductName).pdb" /> + <ProjectTemplateLibraries Include="$(OutputPath)$(ProductName).xml" /> <ProjectTemplateLibraries Include="$(OutputPath)$(ProductName).Contracts.dll" /> <!-- ... and log4net --> <ProjectTemplateLibraries Include="$(ProjectRoot)lib\log4net.dll" /> @@ -207,7 +214,7 @@ </Trim> <MSBuild Projects="@(ProjectTemplates)" /> <Copy SourceFiles="@(ProjectTemplatesSource)" DestinationFiles="@(ProjectTemplatesLayout)" SkipUnchangedFiles="true" /> - <CopyWithTokenSubstitution SourceFiles="@(ProjectTemplatesTransformSource)" DestinationFiles="@(ProjectTemplatesTransformLayout)" SkipUnchangedFiles="true"> + <CopyWithTokenSubstitution SourceFiles="@(ProjectTemplatesTransformSource)" DestinationFiles="@(ProjectTemplatesTransformLayout)"> <Output TaskParameter="CopiedFiles" ItemName="CopiedProjectTemplateFiles" /> </CopyWithTokenSubstitution> <Purge Directories="$(ProjectTemplatesLayoutPath)" diff --git a/doc/Configuration.htm b/doc/Configuration.htm deleted file mode 100644 index 9346c9f..0000000 --- a/doc/Configuration.htm +++ /dev/null @@ -1,167 +0,0 @@ -<!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> - <title>Web.config file configuration of DotNetOpenId</title> -<style> -#id_text_to_colorize{width:600px;height:120px} -.linenos {padding-right: 5px;background: #ccc} -.code {padding-left: 5px;} -.highlight { background: #ffffff; } -.highlight .c { color: #408080; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #008000; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ -.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #808080 } /* Generic.Output */ -.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0040D0 } /* Generic.Traceback */ -.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ -.highlight .kp { color: #008000 } /* Keyword.Pseudo */ -.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #B00040 } /* Keyword.Type */ -.highlight .m { color: #666666 } /* Literal.Number */ -.highlight .s { color: #BA2121 } /* Literal.String */ -.highlight .na { color: #7D9029 } /* Name.Attribute */ -.highlight .nb { color: #008000 } /* Name.Builtin */ -.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -.highlight .no { color: #880000 } /* Name.Constant */ -.highlight .nd { color: #AA22FF } /* Name.Decorator */ -.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #0000FF } /* Name.Function */ -.highlight .nl { color: #A0A000 } /* Name.Label */ -.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #19177C } /* Name.Variable */ -.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #666666 } /* Literal.Number.Float */ -.highlight .mh { color: #666666 } /* Literal.Number.Hex */ -.highlight .mi { color: #666666 } /* Literal.Number.Integer */ -.highlight .mo { color: #666666 } /* Literal.Number.Oct */ -.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ -.highlight .sc { color: #BA2121 } /* Literal.String.Char */ -.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ -.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ -.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -.highlight .sx { color: #008000 } /* Literal.String.Other */ -.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ -.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ -.highlight .ss { color: #19177C } /* Literal.String.Symbol */ -.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #19177C } /* Name.Variable.Class */ -.highlight .vg { color: #19177C } /* Name.Variable.Global */ -.highlight .vi { color: #19177C } /* Name.Variable.Instance */ -.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ -</style> -</head> -<body> - - <p>DotNetOpenId can be configured in some aspects inside your web project's - web.config file. To do this, add the below <sectionGroup> within the - <configSections> of your Web.config file:</p> - <div class="highlight"><pre><span class="nt"><configSections></span> - <span class="nt"><sectionGroup</span> <span class="na">name=</span><span - class="s">"dotNetOpenId"</span><span class="nt">></span> - <span class="nt"><section</span> <span class="na">name=</span><span - class="s">"relyingParty"</span> <span class="na">type=</span><span - class="s">"DotNetOpenId.Configuration.RelyingPartySection"</span> <span - class="na">requirePermission=</span><span class="s">"false"</span> <span - class="na">allowLocation=</span><span class="s">"true"</span><span - class="nt">/></span> - <span class="nt"><section</span> <span class="na">name=</span><span - class="s">"provider"</span> <span class="na">type=</span><span class="s">"DotNetOpenId.Configuration.ProviderSection"</span> <span - class="na">requirePermission=</span><span class="s">"false"</span> <span - class="na">allowLocation=</span><span class="s">"true"</span><span - class="nt">/></span> - <span class="nt"><section</span> <span class="na">name=</span><span - class="s">"untrustedWebRequest"</span> <span class="na">type=</span><span - class="s">"DotNetOpenId.Configuration.UntrustedWebRequestSection"</span> <span - class="na">requirePermission=</span><span class="s">"false"</span> <span - class="na">allowLocation=</span><span class="s">"false"</span><span - class="nt">/></span> - <span class="nt"></sectionGroup></span> -<span class="nt"></configSections></span></pre></div> - <p>If you do not already have a configSections element in your Web.config file, add - it at the very top, as the first child of the root <configuration> tag.</p> - <p>Following is an example of every possible configuration setting, where each - demonstrate value happens to be the default that would be used if it wasn't set - in the .config file. Keep in mind that every setting below is optional, so - you need only include those elements that you wish to change in your own copy of - Web.config. The <dotNetOpenId> node below should show up as a peer node to - system.web in your Web.config file.</p> - <div class="highlight"><pre><span class="nt"><dotNetOpenId></span> - <span class="nt"><relyingParty></span> - <span class="nt"><security</span> <span class="na">minimumHashBitLength=</span><span - class="s">"160"</span> <span class="na">maximumHashBitLength=</span><span - class="s">"256"</span> - <span class="na">requireSsl=</span><span class="s">"false"</span> <span - class="na">minimumRequiredOpenIdVersion=</span><span class="s">"V10"</span> <span - class="nt">/></span> - <span class="nt"><store</span> <span class="na">type=</span><span class="s">"SomeSite.CustomRPStore, SomeSite"</span> <span - class="nt">/></span> - <span class="nt"></relyingParty></span> - <span class="nt"><provider></span> - <span class="nt"><security</span> <span class="na">minimumHashBitLength=</span><span - class="s">"160"</span> <span class="na">maximumHashBitLength=</span><span - class="s">"256"</span> <span class="nt">/></span> - <span class="nt"><store</span> <span class="na">type=</span><span class="s">"SomeSite.CustomProviderStore, SomeSite"</span> <span - class="nt">/></span> - <span class="nt"></provider></span> - <span class="nt"><untrustedWebRequest</span> <span class="na">readWriteTimeout=</span><span - class="s">"00:00:00.800"</span> <span class="na">timeout=</span><span - class="s">"00:00:10"</span> <span class="na">maximumBytesToRead=</span><span - class="s">"1048576"</span> <span class="na">maximumRedirections=</span><span - class="s">"10"</span><span class="nt">></span> - <span class="nt"><whitelistHosts></span> - <span class="nt"><add</span> <span class="na">name=</span><span - class="s">"localhost"</span> <span class="nt">/></span> - <span class="nt"><add</span> <span class="na">name=</span><span - class="s">"127.0.0.1"</span> <span class="nt">/></span> - <span class="nt"></whitelistHosts></span> - <span class="nt"><whitelistHostsRegex></span> - <span class="nt"><add</span> <span class="na">name=</span><span - class="s">"^(.*\.)?goodsite.com"</span> <span class="nt">/></span> - <span class="nt"></whitelistHostsRegex></span> - <span class="nt"><blacklistHosts></span> - <span class="nt"><add</span> <span class="na">name=</span><span - class="s">"internalfinancialserver"</span> <span class="nt">/></span> - <span class="nt"><add</span> <span class="na">name=</span><span - class="s">"www.evilsite.com"</span> <span class="nt">/></span> - <span class="nt"></blacklistHosts></span> - <span class="nt"><blacklistHostsRegex></span> - <span class="nt"><add</span> <span class="na">name=</span><span - class="s">"^(.*\.)?evilsite.com"</span> <span class="nt">/></span> - <span class="nt"></blacklistHostsRegex></span> - <span class="nt"></untrustedWebRequest></span> -<span class="nt"></dotNetOpenId></span> -</pre></div> - - <p>All these configuration values are also configurable at runtime using the object - model of the library. Using the Web.config file allows changes to be made - without recompiling the web site. In the case of OpenIdRelyingParty and - OpenIdProvider, it also allows you to setup your configuration just once, in - your .config file, and have it apply to every instance of OpenIdRelyingParty or - OpenIdProvider instead of you having to set up that configuration everywhere you - instantiate these types.</p> - <p>By using the ASP.NET <location> element, you can set some configuration settings - for OpenIdRelyingParty or OpenIdProvider based on which directory or web page in - your project is instantiating them. This would allow you to, for example, - use enhanced SSL security requirements at just the administrator log in screen - while allowing non-SSL OpenIDs for ordinary users.</p> - -</body> -</html> diff --git a/doc/README.html b/doc/README.html index 7877d72..a82d848 100644 --- a/doc/README.html +++ b/doc/README.html @@ -4,8 +4,8 @@ <p>DotNetOpenAuth is a .NET library that enables OpenID, OAuth and InfoCard support to be easily added to your web and/or desktop applications. </p> <p>The project site for this library is hosted at - <a href="http://dotnetopenid.googlecode.com/"> - http://dotnetopenid.googlecode.com/</a>. Please visit that web site for + <a href="http://dotnetopenauth.net/"> + http://dotnetopenauth.net/</a>. Please visit that web site for documentation, support and maintenance releases.</p> <p>As with any library that is used for security-sensitive purposes such as authentication and authorization, you should periodically check the project web diff --git a/doc/WebFarms.htm b/doc/WebFarms.htm index 44447e7..5ae924d 100644 --- a/doc/WebFarms.htm +++ b/doc/WebFarms.htm @@ -7,21 +7,26 @@ <h3> Non-ASP.NET web servers</h3> <p> - DotNetOpenId works without being a part of an ASP.NET web site. The - ASP.NET controls may not be used in this context, but the programmatic access to - the OpenIdProvider and OpenIdRelyingParty classes will work correctly if you - call the method overloads that do not require a current ASP.NET context. - The xml doc comments indicate which methods require an ASP.NET context and which - methods may be used without one.</p> + DotNetOpenAuth works without being a part of an ASP.NET web site. The ASP.NET + controls may not be used in this context, but the programmatic access to the OpenIdProvider + and OpenIdRelyingParty classes will work correctly if you call the method overloads + that do not require a current ASP.NET context. The xml doc comments indicate + which methods require an ASP.NET context and which methods may be used without one.</p> <h3> Proxy servers</h3> <p> - If your web servers need to use proxy servers to make outbound requests, you - will need to configure your .NET AppDomain to default to the proxy server you - require so that DotNetOpenId will use it. + If your web servers need to use proxy servers to make outbound requests, you will + need to configure your .NET AppDomain to default to the proxy server you require + so that DotNetOpenAuth will use it. </p> <p> - To set the default web proxy, set the System.Net.WebRequest.DefaultWebProxy + To set the default web proxy programmatically, set the System.Net.WebRequest.DefaultWebProxy property.</p> + <p> + To use the default proxy using your web.config file, add this section:<br /> + <pre><system.net> + <defaultProxy enabled="true" /> +</system.net></pre> + </p> </body> </html> diff --git a/lib/DotNetOpenAuth.BuildTasks.dll b/lib/DotNetOpenAuth.BuildTasks.dll Binary files differindex 7ee2a0f..1958acc 100644 --- a/lib/DotNetOpenAuth.BuildTasks.dll +++ b/lib/DotNetOpenAuth.BuildTasks.dll diff --git a/lib/DotNetOpenAuth.BuildTasks.pdb b/lib/DotNetOpenAuth.BuildTasks.pdb Binary files differindex ec57153..b8fd372 100644 --- a/lib/DotNetOpenAuth.BuildTasks.pdb +++ b/lib/DotNetOpenAuth.BuildTasks.pdb diff --git a/lib/DotNetOpenAuth.BuildTasks.targets b/lib/DotNetOpenAuth.BuildTasks.targets index 27dbd10..b23542b 100644 --- a/lib/DotNetOpenAuth.BuildTasks.targets +++ b/lib/DotNetOpenAuth.BuildTasks.targets @@ -4,7 +4,7 @@ <ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..</ProjectRoot> </PropertyGroup> <ItemGroup> - <VsTemplateParameterReplaceExtensions Include=".cs;.csproj;.sql;.config;.Master;.aspx;.vb;.asax" /> + <VsTemplateParameterReplaceExtensions Include=".cs;.csproj;.sql;.config;.Master;.aspx;.vb;.asax;.ashx" /> <VsTemplateProjectItemTypes Include="Compile;EmbeddedResource;EntityDeploy;Content;None" /> </ItemGroup> diff --git a/projecttemplates/RelyingPartyDatabase/.gitignore b/projecttemplates/RelyingPartyDatabase/.gitignore new file mode 100644 index 0000000..55b665f --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/.gitignore @@ -0,0 +1,3 @@ +sql/debug +sql/release +*.dbmdl diff --git a/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlcmdvars b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlcmdvars new file mode 100644 index 0000000..705af45 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlcmdvars @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<SqlCommandVariables xmlns="urn:Microsoft.VisualStudio.Data.Schema.Project.SqlCmdVars"> + <Version>1</Version> + <Properties> + <Property> + <PropertyName>Path1</PropertyName> + <PropertyValue>WEBROOT\App_Data\</PropertyValue> + </Property> + </Properties> +</SqlCommandVariables>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyDatabase/Properties/Database.sqldeployment b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqldeployment new file mode 100644 index 0000000..c3f58f1 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqldeployment @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<DeploymentConfigurationSettings xmlns="urn:Microsoft.VisualStudio.Data.Schema.Project.DeploymentConfigurationSettings"> + <Version>1</Version> + <Properties> + <AbortOnFirstError>False</AbortOnFirstError> + <AlwaysCreateNewDatabase>False</AlwaysCreateNewDatabase> + <BlockIncrementalDeploymentIfDataLoss>True</BlockIncrementalDeploymentIfDataLoss> + <CommentOutSetVarDeclarations>True</CommentOutSetVarDeclarations> + <DeployDatabaseProperties>True</DeployDatabaseProperties> + <DeploymentCollationPreference>UseSourceModelCollation</DeploymentCollationPreference> + <DoNotUseAlterAssemblyStatementsToUpdateCLRTypes>False</DoNotUseAlterAssemblyStatementsToUpdateCLRTypes> + <GenerateDropsIfNotInProject>False</GenerateDropsIfNotInProject> + <IgnoreFileAndLogFilePath>True</IgnoreFileAndLogFilePath> + <PerformDatabaseBackup>False</PerformDatabaseBackup> + <SingleUserMode>False</SingleUserMode> + </Properties> +</DeploymentConfigurationSettings>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlpermissions b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlpermissions new file mode 100644 index 0000000..2b973b7 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlpermissions @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<Permissions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Microsoft.VisualStudio.Data.Schema.Permissions" Version="1.0"> + <!-- The examples below are provided to illustrate how permissions + are defined in the project system for Databases, Objects, + and Columns. + + GRANT Database Permissions + + <PermissionStatement Action ="GRANT"> + <Permission>CREATE TABLE</Permission> + <Grantee>User1</Grantee> + </PermissionStatement> + + GRANT Object Permission + + <PermissionStatement Action ="GRANT"> + <Permission>SELECT</Permission> + <Grantee>User1</Grantee> + <Object Name ="Table1" Schema ="User1" Type ="OBJECT"/> + </PermissionStatement> + + DENY Object Permission + + <PermissionStatement Action ="DENY"> + <Permission>DELETE</Permission> + <Grantee>User1</Grantee> + <Object Name ="Table1" Schema ="User1" Type ="OBJECT"/> + </PermissionStatement> + + GRANT Object Column Permission + + <PermissionStatement Action ="GRANT"> + <Permission>SELECT</Permission> + <Grantee>User1</Grantee> + <Object Name ="Table1" Schema ="User1" Type ="OBJECT"> + <Columns Treatment ="INCLUDE"> + <Column Name=”Col1”/> + <Column Name=”Col2”/> + <Column Name=”…”/> + </Columns> + </Object> + </PermissionStatement> + --> +</Permissions>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlsettings b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlsettings new file mode 100644 index 0000000..b7d41ee --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Properties/Database.sqlsettings @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<CatalogProperties xmlns="urn:Microsoft.VisualStudio.Data.Schema.Project.CatalogProperties"> + <Version>1</Version> + <Properties> + <AllowSnapshotIsolation>False</AllowSnapshotIsolation> + <AnsiNullDefault>False</AnsiNullDefault> + <AnsiNulls>False</AnsiNulls> + <AnsiPadding>False</AnsiPadding> + <AnsiWarnings>False</AnsiWarnings> + <ArithAbort>False</ArithAbort> + <AutoClose>True</AutoClose> + <AutoCreateStatistics>True</AutoCreateStatistics> + <AutoShrink>False</AutoShrink> + <AutoUpdateStatistics>True</AutoUpdateStatistics> + <AutoUpdateStatisticsAsynchronously>False</AutoUpdateStatisticsAsynchronously> + <ChangeTrackingRetentionPeriod>2</ChangeTrackingRetentionPeriod> + <ChangeTrackingRetentionUnit>Days</ChangeTrackingRetentionUnit> + <CloseCursorOnCommitEnabled>False</CloseCursorOnCommitEnabled> + <CompatibilityMode>90</CompatibilityMode> + <ConcatNullYieldsNull>False</ConcatNullYieldsNull> + <DatabaseAccess>MULTI_USER</DatabaseAccess> + <DatabaseChaining>False</DatabaseChaining> + <DatabaseState>ONLINE</DatabaseState> + <DateCorrelationOptimizationOn>False</DateCorrelationOptimizationOn> + <DefaultCollation>SQL_Latin1_General_CP1_CI_AS</DefaultCollation> + <DefaultCursor>GLOBAL</DefaultCursor> + <DefaultFilegroup>PRIMARY</DefaultFilegroup> + <EnableFullTextSearch>True</EnableFullTextSearch> + <IsBrokerPriorityHonored>False</IsBrokerPriorityHonored> + <IsChangeTrackingAutoCleanupOn>True</IsChangeTrackingAutoCleanupOn> + <IsChangeTrackingOn>False</IsChangeTrackingOn> + <IsEncryptionOn>False</IsEncryptionOn> + <NumericRoundAbort>False</NumericRoundAbort> + <PageVerify>CHECKSUM</PageVerify> + <Parameterization>SIMPLE</Parameterization> + <QuotedIdentifier>False</QuotedIdentifier> + <ReadCommittedSnapshot>False</ReadCommittedSnapshot> + <Recovery>SIMPLE</Recovery> + <RecursiveTriggersEnabled>False</RecursiveTriggersEnabled> + <ServiceBrokerOption>DisableBroker</ServiceBrokerOption> + <TornPageDetection>False</TornPageDetection> + <Trustworthy>False</Trustworthy> + <UpdateOptions>READ_WRITE</UpdateOptions> + <VardecimalStorageFormatOn>False</VardecimalStorageFormatOn> + </Properties> +</CatalogProperties>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj b/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj new file mode 100644 index 0000000..b791198 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj @@ -0,0 +1,289 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Name>"DatabaseProject"</Name> + <SchemaVersion>2.0</SchemaVersion> + <ProjectVersion>3.5</ProjectVersion> + <ProjectGuid>{2b4261ac-25ac-4b8d-b459-1c42b6b1401d}</ProjectGuid> + <DSP>Microsoft.Data.Schema.Sql.SqlDsp.Sql100DatabaseSchemaProvider</DSP> + <AppDesignerFolder>Properties</AppDesignerFolder> + <ShowWizard>True</ShowWizard> + <OutputType>Database</OutputType> + <RootPath> + </RootPath> + <IncludeSchemaNameInFileName>False</IncludeSchemaNameInFileName> + <ModelCollation>1033,CI</ModelCollation> + <DefaultFileStructure>BySchema</DefaultFileStructure> + <DeployToDatabaseAddToServerExplorer>False</DeployToDatabaseAddToServerExplorer> + <DeployToScript>True</DeployToScript> + <CatalogPropertiesFile>Properties\Database.sqlsettings</CatalogPropertiesFile> + <ServerPropertiesFile> + </ServerPropertiesFile> + <RootNamespace>RelyingPartyDatabase</RootNamespace> + <DefaultSchema>dbo</DefaultSchema> + <PreviousProjectVersion>3.5</PreviousProjectVersion> + <AllowServerObjects>False</AllowServerObjects> + <AllowDatabaseObjects>True</AllowDatabaseObjects> + <DeployScriptFileName>..\..\..\RelyingPartyLogic\CreateDatabase.sql</DeployScriptFileName> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> + <OutputPath>.\sql\release\</OutputPath> + <BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName> + <TargetConnectionString> + </TargetConnectionString> + <TargetDatabase>RelyingPartyDatabase</TargetDatabase> + <TreatWarningsAsErrors>False</TreatWarningsAsErrors> + <SuppressWarnings> + </SuppressWarnings> + <DeploymentConfigFile>Properties\Database.sqldeployment</DeploymentConfigFile> + <SqlCommandVariablesFile>Properties\Database.sqlcmdvars</SqlCommandVariablesFile> + <DeployToDatabase>False</DeployToDatabase> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> + <OutputPath>.\sql\debug\</OutputPath> + <BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName> + <TargetConnectionString> + </TargetConnectionString> + <TargetDatabase>RelyingPartyDatabase</TargetDatabase> + <TreatWarningsAsErrors>False</TreatWarningsAsErrors> + <SuppressWarnings> + </SuppressWarnings> + <DeploymentConfigFile>Properties\Database.sqldeployment</DeploymentConfigFile> + <SqlCommandVariablesFile>Properties\Database.sqlcmdvars</SqlCommandVariablesFile> + <DeployToDatabase>False</DeployToDatabase> + </PropertyGroup> + <!--Import the settings--> + <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets" /> + <ItemGroup> + <Folder Include="Properties\" /> + <Folder Include="Schema Objects\" /> + <Folder Include="Schema Objects\Database Level Objects\" /> + <Folder Include="Schema Objects\Database Level Objects\Assemblies\" /> + <Folder Include="Schema Objects\Database Level Objects\Database Triggers\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Asymmetric Keys\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Certificates\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Database Audit Specification\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Database Encryption Keys\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Master Keys\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Roles\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Roles\Application Roles\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Roles\Database Roles\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Schemas\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Signatures\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Symmetric Keys\" /> + <Folder Include="Schema Objects\Database Level Objects\Security\Users\" /> + <Folder Include="Schema Objects\Database Level Objects\Service Broker\" /> + <Folder Include="Schema Objects\Database Level Objects\Service Broker\Broker Priorities\" /> + <Folder Include="Schema Objects\Database Level Objects\Service Broker\Contracts\" /> + <Folder Include="Schema Objects\Database Level Objects\Service Broker\Event Notifications\" /> + <Folder Include="Schema Objects\Database Level Objects\Service Broker\Message Types\" /> + <Folder Include="Schema Objects\Database Level Objects\Service Broker\Queues\" /> + <Folder Include="Schema Objects\Database Level Objects\Service Broker\Remote Service Binding\" /> + <Folder Include="Schema Objects\Database Level Objects\Service Broker\Routes\" /> + <Folder Include="Schema Objects\Database Level Objects\Service Broker\Services\" /> + <Folder Include="Schema Objects\Database Level Objects\Storage\" /> + <Folder Include="Schema Objects\Database Level Objects\Storage\Filegroups\" /> + <Folder Include="Schema Objects\Database Level Objects\Storage\Files\" /> + <Folder Include="Schema Objects\Database Level Objects\Storage\Full Text Catalogs\" /> + <Folder Include="Schema Objects\Database Level Objects\Storage\Full Text Stoplists\" /> + <Folder Include="Schema Objects\Database Level Objects\Storage\Partition Functions\" /> + <Folder Include="Schema Objects\Database Level Objects\Storage\Partition Schemes\" /> + <Folder Include="Schema Objects\Schemas\" /> + <Folder Include="Schema Objects\Schemas\dbo\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\Defaults\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\Functions\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\Rules\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\Stored Procedures\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\Types\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\Types\User Defined Data Types\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\Types\User Defined Table Types\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\Types\User Defined Types CLR\" /> + <Folder Include="Schema Objects\Schemas\dbo\Programmability\Types\XML Schema Collections\" /> + <Folder Include="Schema Objects\Schemas\dbo\Synonyms\" /> + <Folder Include="Schema Objects\Schemas\dbo\Tables\" /> + <Folder Include="Schema Objects\Schemas\dbo\Tables\Constraints\" /> + <Folder Include="Schema Objects\Schemas\dbo\Tables\Indexes\" /> + <Folder Include="Schema Objects\Schemas\dbo\Tables\Keys\" /> + <Folder Include="Schema Objects\Schemas\dbo\Tables\Statistics\" /> + <Folder Include="Schema Objects\Schemas\dbo\Tables\Triggers\" /> + <Folder Include="Schema Objects\Schemas\dbo\Views\" /> + <Folder Include="Schema Objects\Schemas\dbo\Views\Indexes\" /> + <Folder Include="Schema Objects\Schemas\dbo\Views\Statistics\" /> + <Folder Include="Schema Objects\Schemas\dbo\Views\Triggers\" /> + <Folder Include="Scripts" /> + <Folder Include="Scripts\Pre-Deployment" /> + <Folder Include="Scripts\Post-Deployment" /> + <Folder Include="Data Generation Plans" /> + <Folder Include="Schema Comparisons" /> + </ItemGroup> + <ItemGroup> + <PropertiesFile Include="Properties\Database.sqlsettings"> + </PropertiesFile> + <PropertiesFile Include="Properties\Database.sqldeployment"> + </PropertiesFile> + <PropertiesFile Include="Properties\Database.sqlcmdvars"> + </PropertiesFile> + <Build Include="Properties\Database.sqlpermissions"> + <ModelBuilderType>Permissions</ModelBuilderType> + </Build> + <Build Include="Schema Objects\Database Level Objects\Service Broker\Routes\AutoCreatedLocal.route.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Database Level Objects\Storage\Files\Database.mdf.sqlfile.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Database Level Objects\Storage\Files\Database_log.sqlfile.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Programmability\Stored Procedures\AddUser.proc.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Programmability\Stored Procedures\ClearExpiredAssociations.proc.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Programmability\Stored Procedures\ClearExpiredNonces.proc.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\AuthenticationToken.table.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Constraints\DF_AuthenticationToken_CreatedOn.defconst.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Constraints\DF_AuthenticationToken_LastUsed.defconst.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Constraints\DF_AuthenticationToken_UsageCount.defconst.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Constraints\DF_IssuedToken_CreatedOn.defconst.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Constraints\DF_IssuedToken_IsAccessToken.defconst.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Constraints\DF_Nonce_Issued.defconst.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Constraints\DF_User_CreatedOn.defconst.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Constraints\DF_User_EmailAddressVerified.defconst.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Consumer.table.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Indexes\IX_Consumer.index.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Indexes\IX_IssuedToken.index.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Indexes\IX_Nonce_Code.index.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Indexes\IX_Nonce_Expires.index.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Indexes\IX_OpenIDAssociations.index.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\IssuedToken.table.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\FK_AuthenticationToken_User.fkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\FK_IssuedToken_Consumer.fkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\FK_IssuedToken_User.fkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\FK_UserRole_Role.fkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\FK_UserRole_User.fkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_AuthenticationToken.pkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_Consumer.pkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_IssuedToken.pkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_Nonce.pkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_OpenIDAssociations.pkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_Role.pkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_User.pkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Keys\PK_UserRole.pkey.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Log.table.sql"> + <SubType>Code</SubType> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Nonce.table.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\OpenIDAssociation.table.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\Role.table.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\User.table.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <Build Include="Schema Objects\Schemas\dbo\Tables\UserRole.table.sql"> + <SubType>Code</SubType> + <AnsiNulls>On</AnsiNulls> + <QuotedIdentifier>On</QuotedIdentifier> + </Build> + <PreDeploy Include="Scripts\Pre-Deployment\Script.PreDeployment.sql"> + <SubType>Code</SubType> + </PreDeploy> + <PostDeploy Include="Scripts\Post-Deployment\Script.PostDeployment.sql"> + <SubType>Code</SubType> + </PostDeploy> + </ItemGroup> + <ItemGroup> + <ArtifactReference Include="$(VSTSDBDirectory)\Extensions\SqlServer\2008\DBSchemas\Microsoft.SqlTypes.dbschema"> + <HintPath>..\..\..\..\..\..\Program Files\Microsoft Visual Studio 9.0\VSTSDB\Extensions\SqlServer\2008\DBSchemas\Microsoft.SqlTypes.dbschema</HintPath> + </ArtifactReference> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Database Level Objects/Service Broker/Routes/AutoCreatedLocal.route.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Database Level Objects/Service Broker/Routes/AutoCreatedLocal.route.sql new file mode 100644 index 0000000..4d731a7 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Database Level Objects/Service Broker/Routes/AutoCreatedLocal.route.sql @@ -0,0 +1,4 @@ +CREATE ROUTE [AutoCreatedLocal] + AUTHORIZATION [dbo] + WITH ADDRESS = N'LOCAL'; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Database Level Objects/Storage/Files/Database.mdf.sqlfile.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Database Level Objects/Storage/Files/Database.mdf.sqlfile.sql new file mode 100644 index 0000000..0c2e5c8 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Database Level Objects/Storage/Files/Database.mdf.sqlfile.sql @@ -0,0 +1,3 @@ +ALTER DATABASE [$(DatabaseName)] + ADD FILE (NAME = [$(Path1)$(DatabaseName).mdf], FILENAME = '$(Path1)$(DatabaseName).mdf', MAXSIZE = UNLIMITED, FILEGROWTH = 1024 KB) TO FILEGROUP [PRIMARY]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Database Level Objects/Storage/Files/Database_log.sqlfile.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Database Level Objects/Storage/Files/Database_log.sqlfile.sql new file mode 100644 index 0000000..bcd70cd --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Database Level Objects/Storage/Files/Database_log.sqlfile.sql @@ -0,0 +1,3 @@ +ALTER DATABASE [$(DatabaseName)] + ADD LOG FILE (NAME = [$(DatabaseName)_log], FILENAME = '$(Path1)$(DatabaseName)_log.LDF', MAXSIZE = 2097152 MB, FILEGROWTH = 10 %); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Programmability/Stored Procedures/AddUser.proc.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Programmability/Stored Procedures/AddUser.proc.sql new file mode 100644 index 0000000..b22b231 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Programmability/Stored Procedures/AddUser.proc.sql @@ -0,0 +1,37 @@ +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 RoleId 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 diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Programmability/Stored Procedures/ClearExpiredAssociations.proc.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Programmability/Stored Procedures/ClearExpiredAssociations.proc.sql new file mode 100644 index 0000000..6a143d0 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Programmability/Stored Procedures/ClearExpiredAssociations.proc.sql @@ -0,0 +1,5 @@ +CREATE PROCEDURE dbo.ClearExpiredAssociations +AS + +DELETE FROM dbo.OpenIDAssociation +WHERE [Expiration] < getutcdate() diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Programmability/Stored Procedures/ClearExpiredNonces.proc.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Programmability/Stored Procedures/ClearExpiredNonces.proc.sql new file mode 100644 index 0000000..3299c6c --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Programmability/Stored Procedures/ClearExpiredNonces.proc.sql @@ -0,0 +1,5 @@ +CREATE PROCEDURE dbo.ClearExpiredNonces +AS + +DELETE FROM dbo.[Nonce] +WHERE [Expires] < getutcdate() diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/AuthenticationToken.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/AuthenticationToken.table.sql new file mode 100644 index 0000000..920e36e --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/AuthenticationToken.table.sql @@ -0,0 +1,10 @@ +CREATE TABLE [dbo].[AuthenticationToken] ( + [AuthenticationTokenId] INT IDENTITY (1, 1) NOT NULL, + [UserId] INT NOT NULL, + [OpenIdClaimedIdentifier] NVARCHAR (250) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [OpenIdFriendlyIdentifier] NVARCHAR (250) NULL, + [CreatedOn] DATETIME NOT NULL, + [LastUsed] DATETIME NOT NULL, + [UsageCount] INT NOT NULL +); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_AuthenticationToken_CreatedOn.defconst.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_AuthenticationToken_CreatedOn.defconst.sql new file mode 100644 index 0000000..df7c22e --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_AuthenticationToken_CreatedOn.defconst.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [DF_AuthenticationToken_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_AuthenticationToken_LastUsed.defconst.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_AuthenticationToken_LastUsed.defconst.sql new file mode 100644 index 0000000..95f5490 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_AuthenticationToken_LastUsed.defconst.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [DF_AuthenticationToken_LastUsed] DEFAULT (getutcdate()) FOR [LastUsed]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_AuthenticationToken_UsageCount.defconst.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_AuthenticationToken_UsageCount.defconst.sql new file mode 100644 index 0000000..f7a65df --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_AuthenticationToken_UsageCount.defconst.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [DF_AuthenticationToken_UsageCount] DEFAULT ((0)) FOR [UsageCount]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_IssuedToken_CreatedOn.defconst.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_IssuedToken_CreatedOn.defconst.sql new file mode 100644 index 0000000..c60323f --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_IssuedToken_CreatedOn.defconst.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [DF_IssuedToken_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_IssuedToken_IsAccessToken.defconst.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_IssuedToken_IsAccessToken.defconst.sql new file mode 100644 index 0000000..2e9e5fd --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_IssuedToken_IsAccessToken.defconst.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [DF_IssuedToken_IsAccessToken] DEFAULT ((0)) FOR [IsAccessToken]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_Nonce_Issued.defconst.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_Nonce_Issued.defconst.sql new file mode 100644 index 0000000..84b5e52 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_Nonce_Issued.defconst.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[Nonce] + ADD CONSTRAINT [DF_Nonce_Issued] DEFAULT (getutcdate()) FOR [Issued]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_User_CreatedOn.defconst.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_User_CreatedOn.defconst.sql new file mode 100644 index 0000000..101d2c2 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_User_CreatedOn.defconst.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[User] + ADD CONSTRAINT [DF_User_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_User_EmailAddressVerified.defconst.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_User_EmailAddressVerified.defconst.sql new file mode 100644 index 0000000..04779be --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Constraints/DF_User_EmailAddressVerified.defconst.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[User] + ADD CONSTRAINT [DF_User_EmailAddressVerified] DEFAULT ((0)) FOR [EmailAddressVerified]; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Consumer.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Consumer.table.sql new file mode 100644 index 0000000..8549a78 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Consumer.table.sql @@ -0,0 +1,11 @@ +CREATE TABLE [dbo].[Consumer] ( + [ConsumerId] INT IDENTITY (1, 1) NOT NULL, + [ConsumerKey] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [ConsumerSecret] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL, + [X509Certificate] IMAGE NULL, + [Callback] NVARCHAR (2048) NULL, + [VerificationCodeFormat] INT NOT NULL, + [VerificationCodeLength] INT NOT NULL, + [Name] NVARCHAR (50) NULL +); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_Consumer.index.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_Consumer.index.sql new file mode 100644 index 0000000..149ae35 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_Consumer.index.sql @@ -0,0 +1,3 @@ +CREATE UNIQUE NONCLUSTERED INDEX [IX_Consumer] + ON [dbo].[Consumer]([ConsumerKey] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_IssuedToken.index.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_IssuedToken.index.sql new file mode 100644 index 0000000..5bc3a53 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_IssuedToken.index.sql @@ -0,0 +1,3 @@ +CREATE UNIQUE NONCLUSTERED INDEX [IX_IssuedToken] + ON [dbo].[IssuedToken]([Token] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_Nonce_Code.index.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_Nonce_Code.index.sql new file mode 100644 index 0000000..5539512 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_Nonce_Code.index.sql @@ -0,0 +1,3 @@ +CREATE UNIQUE NONCLUSTERED INDEX [IX_Nonce_Code] + ON [dbo].[Nonce]([Context] ASC, [Code] ASC, [Issued] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_Nonce_Expires.index.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_Nonce_Expires.index.sql new file mode 100644 index 0000000..23b7cc1 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_Nonce_Expires.index.sql @@ -0,0 +1,3 @@ +CREATE NONCLUSTERED INDEX [IX_Nonce_Expires] + ON [dbo].[Nonce]([Expires] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_OpenIDAssociations.index.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_OpenIDAssociations.index.sql new file mode 100644 index 0000000..c137af6 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Indexes/IX_OpenIDAssociations.index.sql @@ -0,0 +1,3 @@ +CREATE UNIQUE NONCLUSTERED INDEX [IX_OpenIDAssociations] + ON [dbo].[OpenIDAssociation]([DistinguishingFactor] ASC, [AssociationHandle] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/IssuedToken.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/IssuedToken.table.sql new file mode 100644 index 0000000..8882e93 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/IssuedToken.table.sql @@ -0,0 +1,15 @@ +CREATE TABLE [dbo].[IssuedToken] ( + [IssuedTokenId] INT IDENTITY (1, 1) NOT NULL, + [ConsumerId] INT NOT NULL, + [UserId] INT NULL, + [Token] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [TokenSecret] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [CreatedOn] DATETIME NOT NULL, + [Callback] NVARCHAR (2048) NULL, + [VerificationCode] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL, + [ConsumerVersion] VARCHAR (10) NULL, + [ExpirationDate] DATETIME NULL, + [IsAccessToken] BIT NOT NULL, + [Scope] NVARCHAR (255) NULL +); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_AuthenticationToken_User.fkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_AuthenticationToken_User.fkey.sql new file mode 100644 index 0000000..4428616 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_AuthenticationToken_User.fkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [FK_AuthenticationToken_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_IssuedToken_Consumer.fkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_IssuedToken_Consumer.fkey.sql new file mode 100644 index 0000000..a5b3dac --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_IssuedToken_Consumer.fkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [FK_IssuedToken_Consumer] FOREIGN KEY ([ConsumerId]) REFERENCES [dbo].[Consumer] ([ConsumerId]) ON DELETE CASCADE ON UPDATE CASCADE; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_IssuedToken_User.fkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_IssuedToken_User.fkey.sql new file mode 100644 index 0000000..045a694 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_IssuedToken_User.fkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [FK_IssuedToken_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_UserRole_Role.fkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_UserRole_Role.fkey.sql new file mode 100644 index 0000000..859b6f6 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_UserRole_Role.fkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[UserRole] + ADD CONSTRAINT [FK_UserRole_Role] FOREIGN KEY ([RoleId]) REFERENCES [dbo].[Role] ([RoleId]) ON DELETE CASCADE ON UPDATE CASCADE; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_UserRole_User.fkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_UserRole_User.fkey.sql new file mode 100644 index 0000000..bd0a303 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/FK_UserRole_User.fkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[UserRole] + ADD CONSTRAINT [FK_UserRole_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE; + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_AuthenticationToken.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_AuthenticationToken.pkey.sql new file mode 100644 index 0000000..21ed5f9 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_AuthenticationToken.pkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [PK_AuthenticationToken] PRIMARY KEY CLUSTERED ([AuthenticationTokenId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_Consumer.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_Consumer.pkey.sql new file mode 100644 index 0000000..edde20f --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_Consumer.pkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[Consumer] + ADD CONSTRAINT [PK_Consumer] PRIMARY KEY CLUSTERED ([ConsumerId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_IssuedToken.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_IssuedToken.pkey.sql new file mode 100644 index 0000000..e2f95ef --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_IssuedToken.pkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [PK_IssuedToken] PRIMARY KEY CLUSTERED ([IssuedTokenId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_Nonce.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_Nonce.pkey.sql new file mode 100644 index 0000000..d6faf9e --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_Nonce.pkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[Nonce] + ADD CONSTRAINT [PK_Nonce] PRIMARY KEY CLUSTERED ([NonceId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_OpenIDAssociations.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_OpenIDAssociations.pkey.sql new file mode 100644 index 0000000..cdadaf7 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_OpenIDAssociations.pkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[OpenIDAssociation] + ADD CONSTRAINT [PK_OpenIDAssociations] PRIMARY KEY CLUSTERED ([AssociationId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_Role.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_Role.pkey.sql new file mode 100644 index 0000000..62b87cd --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_Role.pkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[Role] + ADD CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED ([RoleId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_User.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_User.pkey.sql new file mode 100644 index 0000000..d44081d --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_User.pkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[User] + ADD CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([UserId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_UserRole.pkey.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_UserRole.pkey.sql new file mode 100644 index 0000000..77579c0 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Keys/PK_UserRole.pkey.sql @@ -0,0 +1,3 @@ +ALTER TABLE [dbo].[UserRole] + ADD CONSTRAINT [PK_UserRole] PRIMARY KEY CLUSTERED ([UserId] ASC, [RoleId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Log.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Log.table.sql new file mode 100644 index 0000000..84fd97a --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Log.table.sql @@ -0,0 +1,9 @@ +CREATE TABLE [dbo].[Log] ( + [Id] INT IDENTITY (1, 1) NOT NULL, + [Date] DATETIME NOT NULL, + [Thread] VARCHAR (255) NOT NULL, + [Level] VARCHAR (50) NOT NULL, + [Logger] VARCHAR (255) NOT NULL, + [Message] VARCHAR (4000) NOT NULL, + [Exception] VARCHAR (2000) NULL +) diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Nonce.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Nonce.table.sql new file mode 100644 index 0000000..bd52d69 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Nonce.table.sql @@ -0,0 +1,8 @@ +CREATE TABLE [dbo].[Nonce] ( + [NonceId] INT IDENTITY (1, 1) NOT NULL, + [Context] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [Code] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [Issued] DATETIME NOT NULL, + [Expires] DATETIME NOT NULL +); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/OpenIDAssociation.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/OpenIDAssociation.table.sql new file mode 100644 index 0000000..bbcf527 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/OpenIDAssociation.table.sql @@ -0,0 +1,9 @@ +CREATE TABLE [dbo].[OpenIDAssociation] ( + [AssociationId] INT IDENTITY (1, 1) NOT NULL, + [DistinguishingFactor] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [AssociationHandle] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [Expiration] DATETIME NOT NULL, + [PrivateData] BINARY (64) NOT NULL, + [PrivateDataLength] INT NOT NULL +); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Role.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Role.table.sql new file mode 100644 index 0000000..eb7a33c --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/Role.table.sql @@ -0,0 +1,5 @@ +CREATE TABLE [dbo].[Role] ( + [RoleId] INT IDENTITY (1, 1) NOT NULL, + [Name] NVARCHAR (50) NOT NULL +); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/User.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/User.table.sql new file mode 100644 index 0000000..2df39d6 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/User.table.sql @@ -0,0 +1,9 @@ +CREATE TABLE [dbo].[User] ( + [UserId] INT IDENTITY (1, 1) NOT NULL, + [FirstName] NVARCHAR (50) NULL, + [LastName] NVARCHAR (50) NULL, + [EmailAddress] NVARCHAR (100) NULL, + [EmailAddressVerified] BIT NOT NULL, + [CreatedOn] DATETIME NOT NULL +); + diff --git a/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/UserRole.table.sql b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/UserRole.table.sql new file mode 100644 index 0000000..fc69e2e --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Schema Objects/Schemas/dbo/Tables/UserRole.table.sql @@ -0,0 +1,5 @@ +CREATE TABLE [dbo].[UserRole] ( + [UserId] INT NOT NULL, + [RoleId] INT NOT NULL +); + diff --git a/projecttemplates/RelyingPartyDatabase/Scripts/Post-Deployment/Script.PostDeployment.sql b/projecttemplates/RelyingPartyDatabase/Scripts/Post-Deployment/Script.PostDeployment.sql new file mode 100644 index 0000000..37db4f5 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Scripts/Post-Deployment/Script.PostDeployment.sql @@ -0,0 +1,11 @@ +/* +Post-Deployment Script Template +-------------------------------------------------------------------------------------- + This file contains SQL statements that will be appended to the build script. + Use SQLCMD syntax to include a file in the post-deployment script. + Example: :r .\myfile.sql + Use SQLCMD syntax to reference a variable in the post-deployment script. + Example: :setvar TableName MyTable + SELECT * FROM [$(TableName)] +-------------------------------------------------------------------------------------- +*/
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyDatabase/Scripts/Pre-Deployment/Script.PreDeployment.sql b/projecttemplates/RelyingPartyDatabase/Scripts/Pre-Deployment/Script.PreDeployment.sql new file mode 100644 index 0000000..0c9f8d6 --- /dev/null +++ b/projecttemplates/RelyingPartyDatabase/Scripts/Pre-Deployment/Script.PreDeployment.sql @@ -0,0 +1,11 @@ +/* + Pre-Deployment Script Template +-------------------------------------------------------------------------------------- + This file contains SQL statements that will be executed before the build script. + Use SQLCMD syntax to include a file in the pre-deployment script. + Example: :r .\myfile.sql + Use SQLCMD syntax to reference a variable in the pre-deployment script. + Example: :setvar TableName MyTable + SELECT * FROM [$(TableName)] +-------------------------------------------------------------------------------------- +*/
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyLogic/CreateDatabase.sql b/projecttemplates/RelyingPartyLogic/CreateDatabase.sql index 0470448..909315f 100644 --- a/projecttemplates/RelyingPartyLogic/CreateDatabase.sql +++ b/projecttemplates/RelyingPartyLogic/CreateDatabase.sql @@ -1,213 +1,613 @@ -SET ANSI_NULLS ON +/* +Deployment script for RelyingPartyDatabase +*/ + GO -SET QUOTED_IDENTIFIER ON +SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, NUMERIC_ROUNDABORT, QUOTED_IDENTIFIER OFF; + + GO -CREATE PROCEDURE [dbo].[ClearExpiredNonces] -AS +/* +:setvar Path1 "WEBROOT\App_Data\" +:setvar DatabaseName "RelyingPartyDatabase" +:setvar DefaultDataPath "" +*/ -DELETE FROM dbo.[Nonce] -WHERE [Expires] < getutcdate() GO -SET ANSI_NULLS ON +USE [master] + GO -SET QUOTED_IDENTIFIER ON +IF (DB_ID(N'$(DatabaseName)') IS NOT NULL + AND DATABASEPROPERTYEX(N'$(DatabaseName)','Status') <> N'ONLINE') +BEGIN + RAISERROR(N'The state of the target database, %s, is not set to ONLINE. To deploy to this database, its state must be set to ONLINE.', 16, 127,N'$(DatabaseName)') WITH NOWAIT + RETURN +END + GO -CREATE PROCEDURE [dbo].[ClearExpiredAssociations] -AS +IF (DB_ID(N'$(DatabaseName)') IS NOT NULL) +BEGIN + ALTER DATABASE [$(DatabaseName)] + SET SINGLE_USER WITH ROLLBACK IMMEDIATE; + DROP DATABASE [$(DatabaseName)]; +END + +GO +PRINT N'Creating $(DatabaseName)...' +GO +CREATE DATABASE [$(DatabaseName)] + ON + PRIMARY(NAME = [$(Path1)$(DatabaseName).mdf], FILENAME = '$(Path1)$(DatabaseName).mdf', MAXSIZE = UNLIMITED, FILEGROWTH = 1024 KB) + LOG ON (NAME = [$(DatabaseName)_log], FILENAME = '$(Path1)$(DatabaseName)_log.LDF', MAXSIZE = 2097152 MB, FILEGROWTH = 10 %) COLLATE SQL_Latin1_General_CP1_CI_AS +GO +EXECUTE sp_dbcmptlevel [$(DatabaseName)], 90; + + +GO +IF EXISTS (SELECT 1 + FROM [master].[dbo].[sysdatabases] + WHERE [name] = N'$(DatabaseName)') + BEGIN + ALTER DATABASE [$(DatabaseName)] + SET ANSI_NULLS OFF, + ANSI_PADDING OFF, + ANSI_WARNINGS OFF, + ARITHABORT OFF, + CONCAT_NULL_YIELDS_NULL OFF, + NUMERIC_ROUNDABORT OFF, + QUOTED_IDENTIFIER OFF, + ANSI_NULL_DEFAULT OFF, + CURSOR_DEFAULT GLOBAL, + RECOVERY SIMPLE, + CURSOR_CLOSE_ON_COMMIT OFF, + AUTO_CREATE_STATISTICS ON, + AUTO_SHRINK OFF, + AUTO_UPDATE_STATISTICS ON, + RECURSIVE_TRIGGERS OFF + WITH ROLLBACK IMMEDIATE; + ALTER DATABASE [$(DatabaseName)] + SET AUTO_CLOSE ON + WITH ROLLBACK IMMEDIATE; + END + + +GO +IF EXISTS (SELECT 1 + FROM [master].[dbo].[sysdatabases] + WHERE [name] = N'$(DatabaseName)') + BEGIN + ALTER DATABASE [$(DatabaseName)] + SET ALLOW_SNAPSHOT_ISOLATION OFF; + END + + +GO +IF EXISTS (SELECT 1 + FROM [master].[dbo].[sysdatabases] + WHERE [name] = N'$(DatabaseName)') + BEGIN + ALTER DATABASE [$(DatabaseName)] + SET READ_COMMITTED_SNAPSHOT OFF; + END + + +GO +IF EXISTS (SELECT 1 + FROM [master].[dbo].[sysdatabases] + WHERE [name] = N'$(DatabaseName)') + BEGIN + ALTER DATABASE [$(DatabaseName)] + SET AUTO_UPDATE_STATISTICS_ASYNC OFF, + PAGE_VERIFY CHECKSUM, + DATE_CORRELATION_OPTIMIZATION OFF, + DISABLE_BROKER, + PARAMETERIZATION SIMPLE + WITH ROLLBACK IMMEDIATE; + END + + +GO +IF IS_SRVROLEMEMBER(N'sysadmin') = 1 + BEGIN + IF EXISTS (SELECT 1 + FROM [master].[dbo].[sysdatabases] + WHERE [name] = N'$(DatabaseName)') + BEGIN + EXECUTE sp_executesql N'ALTER DATABASE [$(DatabaseName)] + SET TRUSTWORTHY OFF, + DB_CHAINING OFF + WITH ROLLBACK IMMEDIATE'; + END + END +ELSE + BEGIN + PRINT N'The database settings for DB_CHAINING or TRUSTWORTHY cannot be modified. You must be a SysAdmin to apply these settings.'; + END + + +GO +IF EXISTS (SELECT 1 + FROM [master].[dbo].[sysdatabases] + WHERE [name] = N'$(DatabaseName)') + BEGIN + ALTER DATABASE [$(DatabaseName)] + SET HONOR_BROKER_PRIORITY OFF + WITH ROLLBACK IMMEDIATE; + END + + +GO +USE [$(DatabaseName)] + +GO +IF fulltextserviceproperty(N'IsFulltextInstalled') = 1 + EXECUTE sp_fulltext_database 'enable'; + + +GO + +GO +/* + Pre-Deployment Script Template +-------------------------------------------------------------------------------------- + This file contains SQL statements that will be executed before the build script. + Use SQLCMD syntax to include a file in the pre-deployment script. + Example: :r .\myfile.sql + Use SQLCMD syntax to reference a variable in the pre-deployment script. + Example: :setvar TableName MyTable + SELECT * FROM [$(TableName)] +-------------------------------------------------------------------------------------- +*/ + +GO + +GO +PRINT N'Creating dbo.AuthenticationToken...'; + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + +GO +CREATE TABLE [dbo].[AuthenticationToken] ( + [AuthenticationTokenId] INT IDENTITY (1, 1) NOT NULL, + [UserId] INT NOT NULL, + [OpenIdClaimedIdentifier] NVARCHAR (250) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [OpenIdFriendlyIdentifier] NVARCHAR (250) NULL, + [CreatedOn] DATETIME NOT NULL, + [LastUsed] DATETIME NOT NULL, + [UsageCount] INT NOT NULL +); + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + +GO +PRINT N'Creating dbo.Consumer...'; + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + +GO +CREATE TABLE [dbo].[Consumer] ( + [ConsumerId] INT IDENTITY (1, 1) NOT NULL, + [ConsumerKey] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [ConsumerSecret] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL, + [X509Certificate] IMAGE NULL, + [Callback] NVARCHAR (2048) NULL, + [VerificationCodeFormat] INT NOT NULL, + [VerificationCodeLength] INT NOT NULL, + [Name] NVARCHAR (50) NULL +); + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + +GO +PRINT N'Creating dbo.IssuedToken...'; + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + +GO +CREATE TABLE [dbo].[IssuedToken] ( + [IssuedTokenId] INT IDENTITY (1, 1) NOT NULL, + [ConsumerId] INT NOT NULL, + [UserId] INT NULL, + [Token] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [TokenSecret] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [CreatedOn] DATETIME NOT NULL, + [Callback] NVARCHAR (2048) NULL, + [VerificationCode] NVARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL, + [ConsumerVersion] VARCHAR (10) NULL, + [ExpirationDate] DATETIME NULL, + [IsAccessToken] BIT NOT NULL, + [Scope] NVARCHAR (255) NULL +); + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + +GO +PRINT N'Creating dbo.Log...'; + + +GO +CREATE TABLE [dbo].[Log] ( + [Id] INT IDENTITY (1, 1) NOT NULL, + [Date] DATETIME NOT NULL, + [Thread] VARCHAR (255) NOT NULL, + [Level] VARCHAR (50) NOT NULL, + [Logger] VARCHAR (255) NOT NULL, + [Message] VARCHAR (4000) NOT NULL, + [Exception] VARCHAR (2000) NULL +); + + +GO +PRINT N'Creating dbo.Nonce...'; + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + +GO +CREATE TABLE [dbo].[Nonce] ( + [NonceId] INT IDENTITY (1, 1) NOT NULL, + [Context] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [Code] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [Issued] DATETIME NOT NULL, + [Expires] DATETIME NOT NULL +); + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + +GO +PRINT N'Creating dbo.OpenIDAssociation...'; + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + +GO +CREATE TABLE [dbo].[OpenIDAssociation] ( + [AssociationId] INT IDENTITY (1, 1) NOT NULL, + [DistinguishingFactor] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [AssociationHandle] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, + [Expiration] DATETIME NOT NULL, + [PrivateData] BINARY (64) NOT NULL, + [PrivateDataLength] INT NOT NULL +); + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + +GO +PRINT N'Creating dbo.Role...'; + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + +GO +CREATE TABLE [dbo].[Role] ( + [RoleId] INT IDENTITY (1, 1) NOT NULL, + [Name] NVARCHAR (50) NOT NULL +); + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + +GO +PRINT N'Creating dbo.User...'; + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + +GO +CREATE TABLE [dbo].[User] ( + [UserId] INT IDENTITY (1, 1) NOT NULL, + [FirstName] NVARCHAR (50) NULL, + [LastName] NVARCHAR (50) NULL, + [EmailAddress] NVARCHAR (100) NULL, + [EmailAddressVerified] BIT NOT NULL, + [CreatedOn] DATETIME NOT NULL +); + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + +GO +PRINT N'Creating dbo.UserRole...'; + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + +GO +CREATE TABLE [dbo].[UserRole] ( + [UserId] INT NOT NULL, + [RoleId] INT NOT NULL +); + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + +GO +PRINT N'Creating dbo.Consumer.IX_Consumer...'; + + +GO +CREATE UNIQUE NONCLUSTERED INDEX [IX_Consumer] + ON [dbo].[Consumer]([ConsumerKey] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + + +GO +PRINT N'Creating dbo.IssuedToken.IX_IssuedToken...'; + + +GO +CREATE UNIQUE NONCLUSTERED INDEX [IX_IssuedToken] + ON [dbo].[IssuedToken]([Token] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + + +GO +PRINT N'Creating dbo.Nonce.IX_Nonce_Code...'; + + +GO +CREATE UNIQUE NONCLUSTERED INDEX [IX_Nonce_Code] + ON [dbo].[Nonce]([Context] ASC, [Code] ASC, [Issued] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + + +GO +PRINT N'Creating dbo.Nonce.IX_Nonce_Expires...'; + + +GO +CREATE NONCLUSTERED INDEX [IX_Nonce_Expires] + ON [dbo].[Nonce]([Expires] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + + +GO +PRINT N'Creating dbo.OpenIDAssociation.IX_OpenIDAssociations...'; + -DELETE FROM dbo.OpenIDAssociation -WHERE [Expiration] < getutcdate() GO -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO -SET ANSI_PADDING ON -GO -CREATE TABLE [dbo].[Nonce]( - [NonceId] [int] IDENTITY(1,1) NOT NULL, - [Context] [varchar](255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [Code] [varchar](255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [Issued] [datetime] NOT NULL, - [Expires] [datetime] NOT NULL, - CONSTRAINT [PK_Nonce] PRIMARY KEY CLUSTERED -( - [NonceId] 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 -SET ANSI_PADDING OFF -GO -CREATE UNIQUE NONCLUSTERED INDEX [IX_Nonce_Code] ON [dbo].[Nonce] -( - [Context] ASC, - [Code] ASC, - [Issued] ASC -)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] -GO -CREATE NONCLUSTERED INDEX [IX_Nonce_Expires] ON [dbo].[Nonce] -( - [Expires] ASC -)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] -GO -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO -SET ANSI_PADDING ON -GO -CREATE TABLE [dbo].[OpenIDAssociation]( - [AssociationId] [int] IDENTITY(1,1) NOT NULL, - [DistinguishingFactor] [varchar](255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [AssociationHandle] [varchar](255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [Expiration] [datetime] NOT NULL, - [PrivateData] [binary](64) NOT NULL, - [PrivateDataLength] [int] NOT NULL, - CONSTRAINT [PK_OpenIDAssociations] PRIMARY KEY CLUSTERED -( - [AssociationId] 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 -SET ANSI_PADDING OFF -GO -CREATE UNIQUE NONCLUSTERED INDEX [IX_OpenIDAssociations] ON [dbo].[OpenIDAssociation] -( - [DistinguishingFactor] ASC, - [AssociationHandle] ASC -)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] -GO -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO -CREATE TABLE [dbo].[Consumer]( - [ConsumerId] [int] IDENTITY(1,1) NOT NULL, - [ConsumerKey] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [ConsumerSecret] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL, - [X509Certificate] [image] NULL, - [Callback] [nvarchar](2048) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [VerificationCodeFormat] [int] NOT NULL, - [VerificationCodeLength] [int] NOT NULL, - [Name] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - CONSTRAINT [PK_Consumer] PRIMARY KEY CLUSTERED -( - [ConsumerId] ASC -)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO -CREATE UNIQUE NONCLUSTERED INDEX [IX_Consumer] ON [dbo].[Consumer] -( - [ConsumerKey] ASC -)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] -GO -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO -CREATE TABLE [dbo].[User]( - [UserId] [int] IDENTITY(1,1) NOT NULL, - [FirstName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [LastName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [EmailAddress] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [EmailAddressVerified] [bit] NOT NULL, - [CreatedOn] [datetime] NOT NULL, - CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED -( - [UserId] 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 -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO -CREATE TABLE [dbo].[Role]( - [RoleId] [int] IDENTITY(1,1) NOT NULL, - [Name] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, - CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED -( - [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 -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO -SET ANSI_PADDING ON -GO -CREATE TABLE [dbo].[IssuedToken]( - [IssuedTokenId] [int] IDENTITY(1,1) NOT NULL, - [ConsumerId] [int] NOT NULL, - [UserId] [int] NULL, - [Token] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [TokenSecret] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [CreatedOn] [datetime] NOT NULL, - [Callback] [nvarchar](2048) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [VerificationCode] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL, - [ConsumerVersion] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [ExpirationDate] [datetime] NULL, - [IsAccessToken] [bit] NOT NULL, - [Scope] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - CONSTRAINT [PK_IssuedToken] PRIMARY KEY CLUSTERED -( - [IssuedTokenId] 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 -SET ANSI_PADDING OFF -GO -CREATE UNIQUE NONCLUSTERED INDEX [IX_IssuedToken] ON [dbo].[IssuedToken] -( - [Token] ASC -)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] -GO -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 -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO -CREATE TABLE [dbo].[AuthenticationToken]( - [AuthenticationTokenId] [int] IDENTITY(1,1) NOT NULL, - [UserId] [int] NOT NULL, - [OpenIdClaimedIdentifier] [nvarchar](250) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [OpenIdFriendlyIdentifier] [nvarchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [CreatedOn] [datetime] NOT NULL, - [LastUsed] [datetime] NOT NULL, - [UsageCount] [int] NOT NULL, - CONSTRAINT [PK_AuthenticationToken] PRIMARY KEY CLUSTERED -( - [AuthenticationTokenId] 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 -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON +CREATE UNIQUE NONCLUSTERED INDEX [IX_OpenIDAssociations] + ON [dbo].[OpenIDAssociation]([DistinguishingFactor] ASC, [AssociationHandle] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); + + +GO +PRINT N'Creating dbo.DF_AuthenticationToken_CreatedOn...'; + + +GO +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [DF_AuthenticationToken_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn]; + + +GO +PRINT N'Creating dbo.DF_AuthenticationToken_LastUsed...'; + + +GO +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [DF_AuthenticationToken_LastUsed] DEFAULT (getutcdate()) FOR [LastUsed]; + + +GO +PRINT N'Creating dbo.DF_AuthenticationToken_UsageCount...'; + + +GO +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [DF_AuthenticationToken_UsageCount] DEFAULT ((0)) FOR [UsageCount]; + + +GO +PRINT N'Creating dbo.DF_IssuedToken_CreatedOn...'; + + +GO +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [DF_IssuedToken_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn]; + + +GO +PRINT N'Creating dbo.DF_IssuedToken_IsAccessToken...'; + + +GO +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [DF_IssuedToken_IsAccessToken] DEFAULT ((0)) FOR [IsAccessToken]; + + +GO +PRINT N'Creating dbo.DF_Nonce_Issued...'; + + +GO +ALTER TABLE [dbo].[Nonce] + ADD CONSTRAINT [DF_Nonce_Issued] DEFAULT (getutcdate()) FOR [Issued]; + + +GO +PRINT N'Creating dbo.DF_User_CreatedOn...'; + + +GO +ALTER TABLE [dbo].[User] + ADD CONSTRAINT [DF_User_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn]; + + +GO +PRINT N'Creating dbo.DF_User_EmailAddressVerified...'; + + +GO +ALTER TABLE [dbo].[User] + ADD CONSTRAINT [DF_User_EmailAddressVerified] DEFAULT ((0)) FOR [EmailAddressVerified]; + + +GO +PRINT N'Creating dbo.PK_AuthenticationToken...'; + + +GO +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [PK_AuthenticationToken] PRIMARY KEY CLUSTERED ([AuthenticationTokenId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + + +GO +PRINT N'Creating dbo.PK_Consumer...'; + + +GO +ALTER TABLE [dbo].[Consumer] + ADD CONSTRAINT [PK_Consumer] PRIMARY KEY CLUSTERED ([ConsumerId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + + +GO +PRINT N'Creating dbo.PK_IssuedToken...'; + + +GO +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [PK_IssuedToken] PRIMARY KEY CLUSTERED ([IssuedTokenId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + + +GO +PRINT N'Creating dbo.PK_Nonce...'; + + +GO +ALTER TABLE [dbo].[Nonce] + ADD CONSTRAINT [PK_Nonce] PRIMARY KEY CLUSTERED ([NonceId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + + +GO +PRINT N'Creating dbo.PK_OpenIDAssociations...'; + + +GO +ALTER TABLE [dbo].[OpenIDAssociation] + ADD CONSTRAINT [PK_OpenIDAssociations] PRIMARY KEY CLUSTERED ([AssociationId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + + +GO +PRINT N'Creating dbo.PK_Role...'; + + +GO +ALTER TABLE [dbo].[Role] + ADD CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED ([RoleId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + + +GO +PRINT N'Creating dbo.PK_User...'; + + +GO +ALTER TABLE [dbo].[User] + ADD CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([UserId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + + +GO +PRINT N'Creating dbo.PK_UserRole...'; + + +GO +ALTER TABLE [dbo].[UserRole] + ADD CONSTRAINT [PK_UserRole] PRIMARY KEY CLUSTERED ([UserId] ASC, [RoleId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); + + +GO +PRINT N'Creating dbo.FK_AuthenticationToken_User...'; + + +GO +ALTER TABLE [dbo].[AuthenticationToken] + ADD CONSTRAINT [FK_AuthenticationToken_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE; + + +GO +PRINT N'Creating dbo.FK_IssuedToken_Consumer...'; + + +GO +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [FK_IssuedToken_Consumer] FOREIGN KEY ([ConsumerId]) REFERENCES [dbo].[Consumer] ([ConsumerId]) ON DELETE CASCADE ON UPDATE CASCADE; + + +GO +PRINT N'Creating dbo.FK_IssuedToken_User...'; + + +GO +ALTER TABLE [dbo].[IssuedToken] + ADD CONSTRAINT [FK_IssuedToken_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE; + + +GO +PRINT N'Creating dbo.FK_UserRole_Role...'; + + +GO +ALTER TABLE [dbo].[UserRole] + ADD CONSTRAINT [FK_UserRole_Role] FOREIGN KEY ([RoleId]) REFERENCES [dbo].[Role] ([RoleId]) ON DELETE CASCADE ON UPDATE CASCADE; + + +GO +PRINT N'Creating dbo.FK_UserRole_User...'; + + +GO +ALTER TABLE [dbo].[UserRole] + ADD CONSTRAINT [FK_UserRole_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE; + + +GO +PRINT N'Creating dbo.AddUser...'; + + +GO +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + GO CREATE PROCEDURE [dbo].[AddUser] - ( - @firstName nvarchar(50), - @lastName nvarchar(50), - @openid nvarchar(255), - @role nvarchar(255) - ) +@firstName NVARCHAR (50), @lastName NVARCHAR (50), @openid NVARCHAR (255), @role NVARCHAR (255) AS - DECLARE +DECLARE @roleid int, @userid int @@ -236,55 +636,85 @@ AS COMMIT TRANSACTION RETURN @userid + + GO -ALTER TABLE [dbo].[Nonce] ADD CONSTRAINT [DF_Nonce_Issued] DEFAULT (getutcdate()) FOR [Issued] -GO -ALTER TABLE [dbo].[User] ADD CONSTRAINT [DF_User_EmailAddressVerified] DEFAULT ((0)) FOR [EmailAddressVerified] -GO -ALTER TABLE [dbo].[User] ADD CONSTRAINT [DF_User_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn] +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + GO -ALTER TABLE [dbo].[IssuedToken] ADD CONSTRAINT [DF_IssuedToken_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn] +PRINT N'Creating dbo.ClearExpiredAssociations...'; + + GO -ALTER TABLE [dbo].[IssuedToken] ADD CONSTRAINT [DF_IssuedToken_IsAccessToken] DEFAULT ((0)) FOR [IsAccessToken] +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + GO -ALTER TABLE [dbo].[AuthenticationToken] ADD CONSTRAINT [DF_AuthenticationToken_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn] +CREATE PROCEDURE [dbo].[ClearExpiredAssociations] + +AS +DELETE FROM dbo.OpenIDAssociation +WHERE [Expiration] < getutcdate() + + GO -ALTER TABLE [dbo].[AuthenticationToken] ADD CONSTRAINT [DF_AuthenticationToken_LastUsed] DEFAULT (getutcdate()) FOR [LastUsed] +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + GO -ALTER TABLE [dbo].[AuthenticationToken] ADD CONSTRAINT [DF_AuthenticationToken_UsageCount] DEFAULT ((0)) FOR [UsageCount] +PRINT N'Creating dbo.ClearExpiredNonces...'; + + GO -ALTER TABLE [dbo].[IssuedToken] WITH CHECK ADD CONSTRAINT [FK_IssuedToken_Consumer] FOREIGN KEY([ConsumerId]) -REFERENCES [dbo].[Consumer] ([ConsumerId]) -ON UPDATE CASCADE -ON DELETE CASCADE +SET ANSI_NULLS, QUOTED_IDENTIFIER ON; + + GO -ALTER TABLE [dbo].[IssuedToken] CHECK CONSTRAINT [FK_IssuedToken_Consumer] +CREATE PROCEDURE [dbo].[ClearExpiredNonces] + +AS +DELETE FROM dbo.[Nonce] +WHERE [Expires] < getutcdate() + + GO -ALTER TABLE [dbo].[IssuedToken] WITH CHECK ADD CONSTRAINT [FK_IssuedToken_User] FOREIGN KEY([UserId]) -REFERENCES [dbo].[User] ([UserId]) -ON UPDATE CASCADE -ON DELETE CASCADE +SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; + + GO -ALTER TABLE [dbo].[IssuedToken] CHECK CONSTRAINT [FK_IssuedToken_User] +PRINT N'Creating AutoCreatedLocal...'; + + GO -ALTER TABLE [dbo].[UserRole] WITH CHECK ADD CONSTRAINT [FK_UserRole_Role] FOREIGN KEY([RoleId]) -REFERENCES [dbo].[Role] ([RoleId]) -ON UPDATE CASCADE -ON DELETE CASCADE +CREATE ROUTE [AutoCreatedLocal] + AUTHORIZATION [dbo] + WITH ADDRESS = N'LOCAL'; + + GO -ALTER TABLE [dbo].[UserRole] CHECK CONSTRAINT [FK_UserRole_Role] + GO -ALTER TABLE [dbo].[UserRole] WITH CHECK ADD CONSTRAINT [FK_UserRole_User] FOREIGN KEY([UserId]) -REFERENCES [dbo].[User] ([UserId]) -ON UPDATE CASCADE -ON DELETE CASCADE +/* +Post-Deployment Script Template +-------------------------------------------------------------------------------------- + This file contains SQL statements that will be appended to the build script. + Use SQLCMD syntax to include a file in the post-deployment script. + Example: :r .\myfile.sql + Use SQLCMD syntax to reference a variable in the post-deployment script. + Example: :setvar TableName MyTable + SELECT * FROM [$(TableName)] +-------------------------------------------------------------------------------------- +*/ + GO -ALTER TABLE [dbo].[UserRole] CHECK CONSTRAINT [FK_UserRole_User] + GO -ALTER TABLE [dbo].[AuthenticationToken] WITH CHECK ADD CONSTRAINT [FK_AuthenticationToken_User] FOREIGN KEY([UserId]) -REFERENCES [dbo].[User] ([UserId]) -ON UPDATE CASCADE -ON DELETE CASCADE + GO -ALTER TABLE [dbo].[AuthenticationToken] CHECK CONSTRAINT [FK_AuthenticationToken_User] +ALTER DATABASE [$(DatabaseName)] + SET MULTI_USER + WITH ROLLBACK IMMEDIATE; + + GO diff --git a/projecttemplates/RelyingPartyLogic/Database.cs b/projecttemplates/RelyingPartyLogic/Database.cs index 3dbb493..9ef72eb 100644 --- a/projecttemplates/RelyingPartyLogic/Database.cs +++ b/projecttemplates/RelyingPartyLogic/Database.cs @@ -51,7 +51,7 @@ namespace RelyingPartyLogic { throw; } - DataContextTransactionSimple = dataContext.Connection.BeginTransaction(); + DataContextTransaction = dataContext.Connection.BeginTransaction(); DataContextSimple = dataContext; } @@ -59,14 +59,14 @@ namespace RelyingPartyLogic { } } - private static DatabaseEntities DataContextSimple { + internal static IDbTransaction DataContextTransaction { get { if (HttpContext.Current != null) { - return HttpContext.Current.Items[DataContextKey] as DatabaseEntities; + return HttpContext.Current.Items[DataContextTransactionKey] as IDbTransaction; } else if (OperationContext.Current != null) { object data; - if (OperationContext.Current.IncomingMessageProperties.TryGetValue(DataContextKey, out data)) { - return data as DatabaseEntities; + if (OperationContext.Current.IncomingMessageProperties.TryGetValue(DataContextTransactionKey, out data)) { + return data as IDbTransaction; } else { return null; } @@ -75,25 +75,25 @@ namespace RelyingPartyLogic { } } - set { + private set { if (HttpContext.Current != null) { - HttpContext.Current.Items[DataContextKey] = value; + HttpContext.Current.Items[DataContextTransactionKey] = value; } else if (OperationContext.Current != null) { - OperationContext.Current.IncomingMessageProperties[DataContextKey] = value; + OperationContext.Current.IncomingMessageProperties[DataContextTransactionKey] = value; } else { throw new InvalidOperationException(); } } } - private static IDbTransaction DataContextTransactionSimple { + private static DatabaseEntities DataContextSimple { get { if (HttpContext.Current != null) { - return HttpContext.Current.Items[DataContextTransactionKey] as IDbTransaction; + return HttpContext.Current.Items[DataContextKey] as DatabaseEntities; } else if (OperationContext.Current != null) { object data; - if (OperationContext.Current.IncomingMessageProperties.TryGetValue(DataContextTransactionKey, out data)) { - return data as IDbTransaction; + if (OperationContext.Current.IncomingMessageProperties.TryGetValue(DataContextKey, out data)) { + return data as DatabaseEntities; } else { return null; } @@ -104,9 +104,9 @@ namespace RelyingPartyLogic { set { if (HttpContext.Current != null) { - HttpContext.Current.Items[DataContextTransactionKey] = value; + HttpContext.Current.Items[DataContextKey] = value; } else if (OperationContext.Current != null) { - OperationContext.Current.IncomingMessageProperties[DataContextTransactionKey] = value; + OperationContext.Current.IncomingMessageProperties[DataContextKey] = value; } else { throw new InvalidOperationException(); } @@ -126,10 +126,10 @@ namespace RelyingPartyLogic { } protected void Application_Error(object sender, EventArgs e) { - if (DataContextTransactionSimple != null) { - DataContextTransactionSimple.Rollback(); - DataContextTransactionSimple.Dispose(); - DataContextTransactionSimple = null; + if (DataContextTransaction != null) { + DataContextTransaction.Rollback(); + DataContextTransaction.Dispose(); + DataContextTransaction = null; } } @@ -137,9 +137,9 @@ namespace RelyingPartyLogic { var dataContext = DataContextSimple; if (dataContext != null) { dataContext.SaveChanges(); - if (DataContextTransactionSimple != null) { - DataContextTransactionSimple.Commit(); - DataContextTransactionSimple.Dispose(); + if (DataContextTransaction != null) { + DataContextTransaction.Commit(); + DataContextTransaction.Dispose(); } dataContext.Dispose(); diff --git a/projecttemplates/RelyingPartyLogic/Utilities.cs b/projecttemplates/RelyingPartyLogic/Utilities.cs index fb05306..bbcfc68 100644 --- a/projecttemplates/RelyingPartyLogic/Utilities.cs +++ b/projecttemplates/RelyingPartyLogic/Utilities.cs @@ -11,6 +11,7 @@ namespace RelyingPartyLogic { using System.Data.Common; using System.Data.EntityClient; using System.Data.Objects; + using System.Data.SqlClient; using System.Globalization; using System.IO; using System.Linq; @@ -40,27 +41,57 @@ namespace RelyingPartyLogic { public static void CreateDatabase(Identifier claimedId, string friendlyId, string databaseName) { const string SqlFormat = @" -CREATE DATABASE [{0}] ON (NAME='{0}', FILENAME='{0}') +{0} GO -USE ""{0}"" -GO -{1} -EXEC [dbo].[AddUser] 'admin', 'admin', '{2}', '{3}' +EXEC [dbo].[AddUser] 'admin', 'admin', '{1}', '{2}' GO "; - string schemaSql; + var removeSnippets = new string[] { @" +IF EXISTS (SELECT 1 + FROM [master].[dbo].[sysdatabases] + WHERE [name] = N'$(DatabaseName)') + BEGIN + ALTER DATABASE [$(DatabaseName)] + SET HONOR_BROKER_PRIORITY OFF + WITH ROLLBACK IMMEDIATE; + END + + +GO", @" +PRINT N'Creating AutoCreatedLocal...'; + + +GO +CREATE ROUTE [AutoCreatedLocal] + AUTHORIZATION [dbo] + WITH ADDRESS = N'LOCAL'; + + +GO +" }; + string databasePath = HttpContext.Current.Server.MapPath("~/App_Data/" + databaseName + ".mdf"); + StringBuilder schemaSqlBuilder = new StringBuilder(); using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(DefaultNamespace + ".CreateDatabase.sql"))) { - schemaSql = sr.ReadToEnd(); + schemaSqlBuilder.Append(sr.ReadToEnd()); } - string databasePath = HttpContext.Current.Server.MapPath("~/App_Data/" + databaseName + ".mdf"); - string sql = string.Format(CultureInfo.InvariantCulture, SqlFormat, databasePath, schemaSql, claimedId, "Admin"); + foreach (string remove in removeSnippets) { + schemaSqlBuilder.Replace(remove, string.Empty); + } + schemaSqlBuilder.Replace("$(Path1)", HttpContext.Current.Server.MapPath("~/App_Data/")); + schemaSqlBuilder.Replace("WEBROOT", databasePath); + schemaSqlBuilder.Replace("$(DatabaseName)", databaseName); + + string sql = string.Format(CultureInfo.InvariantCulture, SqlFormat, schemaSqlBuilder, claimedId, "Admin"); var serverConnection = new ServerConnection(".\\sqlexpress"); try { serverConnection.ExecuteNonQuery(sql); - var server = new Server(serverConnection); - server.DetachDatabase(databasePath, true); } finally { + try { + var server = new Server(serverConnection); + server.DetachDatabase(databaseName, true); + } catch (FailedOperationException) { + } serverConnection.Disconnect(); } } @@ -79,6 +110,7 @@ GO } DbCommand cmd = connection.CreateCommand(); + cmd.Transaction = (DbTransaction)Database.DataContextTransaction; cmd.CommandText = command; cmd.CommandType = CommandType.StoredProcedure; try { diff --git a/projecttemplates/WebFormsRelyingParty/Default.aspx b/projecttemplates/WebFormsRelyingParty/Default.aspx index e470320..c58805c 100644 --- a/projecttemplates/WebFormsRelyingParty/Default.aspx +++ b/projecttemplates/WebFormsRelyingParty/Default.aspx @@ -1,5 +1,5 @@ <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebFormsRelyingParty._Default" - MasterPageFile="~/Site.Master" %> + MasterPageFile="~/Site.Master" Title="OpenID + InfoCard Relying Party template" %> <%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth" TagPrefix="dnoa" %> <asp:Content runat="server" ContentPlaceHolderID="head"> diff --git a/projecttemplates/WebFormsRelyingParty/Global.asax.cs b/projecttemplates/WebFormsRelyingParty/Global.asax.cs index cc69f0c..0d99ac9 100644 --- a/projecttemplates/WebFormsRelyingParty/Global.asax.cs +++ b/projecttemplates/WebFormsRelyingParty/Global.asax.cs @@ -14,7 +14,7 @@ namespace WebFormsRelyingParty { public class Global : System.Web.HttpApplication { /// <summary> - /// The logger for this sample to use. + /// The logger for this web site to use. /// </summary> private static log4net.ILog logger = log4net.LogManager.GetLogger("WebFormsRelyingParty"); @@ -40,7 +40,7 @@ namespace WebFormsRelyingParty { } protected void Application_Error(object sender, EventArgs e) { - Logger.Error("An unhandled exception occurred in ASP.NET processing: " + Server.GetLastError(), Server.GetLastError()); + Logger.Error("An unhandled exception occurred in ASP.NET processing for page " + HttpContext.Current.Request.Path, Server.GetLastError()); } protected void Session_End(object sender, EventArgs e) { diff --git a/projecttemplates/WebFormsRelyingParty/LoginFrame.aspx.cs b/projecttemplates/WebFormsRelyingParty/LoginFrame.aspx.cs index eee3673..07c24ae 100644 --- a/projecttemplates/WebFormsRelyingParty/LoginFrame.aspx.cs +++ b/projecttemplates/WebFormsRelyingParty/LoginFrame.aspx.cs @@ -26,6 +26,11 @@ "getTopWindowUrl", "document.getElementById('topWindowUrl').value = window.parent.location.href;"); } + + // We set the privacy policy URL here instead of in the ASPX page with the rest of the + // Simple Registration extension so that we can construct the absolute URL rather than + // hard-coding it. + this.openIdSelector.Extensions.OfType<ClaimsRequest>().Single().PolicyUrl = new Uri(Request.Url, Page.ResolveUrl("~/PrivacyPolicy.aspx")); } protected void openIdSelector_LoggedIn(object sender, OpenIdEventArgs e) { diff --git a/projecttemplates/WebFormsRelyingParty/PrivacyPolicy.aspx b/projecttemplates/WebFormsRelyingParty/PrivacyPolicy.aspx new file mode 100644 index 0000000..82be533 --- /dev/null +++ b/projecttemplates/WebFormsRelyingParty/PrivacyPolicy.aspx @@ -0,0 +1,10 @@ +<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %> + +<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Body"> + <h2> + Privacy Policy + </h2> + <p> + Some privacy policy would go here. + </p> +</asp:Content> diff --git a/projecttemplates/WebFormsRelyingParty/Site.Master b/projecttemplates/WebFormsRelyingParty/Site.Master index 3cf191e..6d74076 100644 --- a/projecttemplates/WebFormsRelyingParty/Site.Master +++ b/projecttemplates/WebFormsRelyingParty/Site.Master @@ -16,7 +16,7 @@ <asp:LoginView runat="server"> <LoggedInTemplate> <% - var authToken = Database.DataContext.AuthenticationToken.Include("User").First(token => token.ClaimedIdentifier == Page.User.Identity.Name); + var authToken = Database.DataContext.AuthenticationTokens.Include("User").First(token => token.ClaimedIdentifier == Page.User.Identity.Name); if (!string.IsNullOrEmpty(authToken.User.EmailAddress)) { Response.Write(HttpUtility.HtmlEncode(authToken.User.EmailAddress)); } else if (!string.IsNullOrEmpty(authToken.User.FirstName)) { @@ -42,17 +42,19 @@ </div> </form> -<% if (Request.Url.IsLoopback) { %> - <script type="text/javascript" src="scripts/jquery-1.3.1.js"></script> - <script type="text/javascript" src="scripts/jquery-ui-personalized-1.6rc6.js"></script> -<% } else { %> - <script type="text/javascript" language="javascript" src="http://www.google.com/jsapi"></script> - <script type="text/javascript" language="javascript"> - google.load("jquery", "1.3.2"); - google.load("jqueryui", "1.7.2"); - </script> -<% } %> +<% if (!this.Page.User.Identity.IsAuthenticated) { %> + <% if (Request.Url.IsLoopback) { %> + <script type="text/javascript" src="scripts/jquery-1.3.1.js"></script> + <script type="text/javascript" src="scripts/jquery-ui-personalized-1.6rc6.js"></script> + <% } else { %> + <script type="text/javascript" language="javascript" src="http://www.google.com/jsapi"></script> + <script type="text/javascript" language="javascript"> + google.load("jquery", "1.3.2"); + google.load("jqueryui", "1.7.2"); + </script> + <% } %> <script type="text/javascript" language="javascript" src="scripts/LoginLink.js"></script> +<% } %> </body> </html> diff --git a/projecttemplates/WebFormsRelyingParty/Web.config b/projecttemplates/WebFormsRelyingParty/Web.config index bb71c8a..1d7c29f 100644 --- a/projecttemplates/WebFormsRelyingParty/Web.config +++ b/projecttemplates/WebFormsRelyingParty/Web.config @@ -71,31 +71,76 @@ <reporting enabled="true" /> </dotNetOpenAuth> - <!-- log4net is a 3rd party (free) logger library that dotnetopenid will use if present but does not require. --> + <!-- log4net is a 3rd party (free) logger library that DotNetOpenAuth will use if present but does not require. --> <log4net> - <!--<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> - <file value="RelyingParty.log" /> - <appendToFile value="true" /> - <rollingStyle value="Size" /> - <maxSizeRollBackups value="10" /> - <maximumFileSize value="100KB" /> - <staticLogFileName value="true" /> - <layout type="log4net.Layout.PatternLayout"> - <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" /> - </layout> - </appender>--> + <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender"> + <bufferSize value="100" /> + <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <connectionString value="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\WebFormsRelyingParty.mdf;Integrated Security=True;User Instance=True" /> + <commandText value="INSERT INTO [Log] ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" /> + <parameter> + <parameterName value="@log_date" /> + <dbType value="DateTime" /> + <layout type="log4net.Layout.RawTimeStampLayout" /> + </parameter> + <parameter> + <parameterName value="@thread" /> + <dbType value="String" /> + <size value="255" /> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%thread" /> + </layout> + </parameter> + <parameter> + <parameterName value="@log_level" /> + <dbType value="String" /> + <size value="50" /> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%level" /> + </layout> + </parameter> + <parameter> + <parameterName value="@logger" /> + <dbType value="String" /> + <size value="255" /> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%logger" /> + </layout> + </parameter> + <parameter> + <parameterName value="@message" /> + <dbType value="String" /> + <size value="4000" /> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%message" /> + </layout> + </parameter> + <parameter> + <parameterName value="@exception" /> + <dbType value="String" /> + <size value="2000" /> + <layout type="log4net.Layout.ExceptionLayout" /> + </parameter> + </appender> <!-- Setup the root category, add the appenders and set the default level --> <root> <level value="WARN" /> - <appender-ref ref="RollingFileAppender" /> + <appender-ref ref="AdoNetAppender" /> </root> <!-- Specify the level for some specific categories --> <logger name="DotNetOpenAuth"> <level value="WARN" /> </logger> + <logger name="DotNetOpenAuth.OpenId"> + <level value="INFO" /> + </logger> + <logger name="DotNetOpenAuth.OAuth"> + <level value="INFO" /> + </logger> </log4net> <appSettings /> <connectionStrings> + <!-- Remember to keep this connection string in sync with the one (if any) that appears in the log4net section. --> <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|\WebFormsRelyingParty.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" /> </connectionStrings> <system.web> @@ -218,4 +263,4 @@ </authorization> </system.web> </location> -</configuration>
\ No newline at end of file +</configuration> diff --git a/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj b/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj index 6d024df..9db3c05 100644 --- a/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj +++ b/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj @@ -233,8 +233,10 @@ <Content Include="xrds.aspx" /> </ItemGroup> <ItemGroup> + <Content Include="images\verisign.gif" /> <Content Include="Members\OAuthAuthorize.aspx" /> <Content Include="OAuth.ashx" /> + <Content Include="PrivacyPolicy.aspx" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\src\DotNetOpenAuth\DotNetOpenAuth.csproj"> diff --git a/samples/OpenIdProviderMvc/Views/Shared/Xrds.aspx b/samples/OpenIdProviderMvc/Views/Shared/Xrds.aspx index 7aad102..0d73909 100644 --- a/samples/OpenIdProviderMvc/Views/Shared/Xrds.aspx +++ b/samples/OpenIdProviderMvc/Views/Shared/Xrds.aspx @@ -27,5 +27,13 @@ for all XRDS discovery. <Type>http://specs.openid.net/extensions/ui/1.0/icon</Type>--%> <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/OpenId/Provider"))%></URI> </Service> +<% if (ViewData["OPIdentifier"] == null) { %> + <Service priority="20"> + <Type>http://openid.net/signon/1.0</Type> + <Type>http://openid.net/extensions/sreg/1.1</Type> + <Type>http://axschema.org/contact/email</Type> + <URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/OpenId/Provider"))%></URI> + </Service> +<% } %> </XRD> </xrds:XRDS> diff --git a/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs b/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs index 691df20..51fcee4 100644 --- a/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs +++ b/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs @@ -81,5 +81,32 @@ namespace DotNetOpenAuth.BuildTasks { return true; } + + /// <summary> + /// Tests whether a file is up to date with respect to another, + /// based on existence, last write time and file size. + /// </summary> + /// <param name="sourcePath">The source path.</param> + /// <param name="destPath">The dest path.</param> + /// <returns><c>true</c> if the files are the same; <c>false</c> if the files are different</returns> + internal static bool FastFileEqualityCheck(string sourcePath, string destPath) { + FileInfo sourceInfo = new FileInfo(sourcePath); + FileInfo destInfo = new FileInfo(destPath); + + if (sourceInfo.Exists ^ destInfo.Exists) { + // Either the source file or the destination file is missing. + return false; + } + + if (!sourceInfo.Exists) { + // Neither file exists. + return true; + } + + // We'll say the files are the same if their modification date and length are the same. + return + sourceInfo.LastWriteTimeUtc == destInfo.LastWriteTimeUtc && + sourceInfo.Length == destInfo.Length; + } } } diff --git a/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs b/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs index 3b81978..e17d8f2 100644 --- a/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs +++ b/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs @@ -18,15 +18,6 @@ namespace DotNetOpenAuth.BuildTasks { /// </summary> public class CopyWithTokenSubstitution : Task { /// <summary> - /// Gets or sets a value indicating whether the task should - /// skip the copying of files that are unchanged between the source and destination. - /// </summary> - /// <value> - /// <c>true</c> to skip copying files where the destination files are newer than the source files; otherwise, <c>false</c> to copy all files. - /// </value> - public bool SkipUnchangedFiles { get; set; } - - /// <summary> /// Gets or sets the files to copy. /// </summary> /// <value>The files to copy.</value> @@ -65,8 +56,11 @@ namespace DotNetOpenAuth.BuildTasks { for (int i = 0; i < this.SourceFiles.Length; i++) { string sourcePath = this.SourceFiles[i].ItemSpec; string destPath = this.DestinationFiles[i].ItemSpec; + bool skipUnchangedFiles = bool.Parse(this.SourceFiles[i].GetMetadata("SkipUnchangedFiles")); - if (this.SkipUnchangedFiles && File.GetLastWriteTimeUtc(sourcePath) < File.GetLastWriteTimeUtc(destPath)) { + // We deliberably consider newer destination files to be up-to-date rather than + // requiring equality because this task modifies the destination file while copying. + if (skipUnchangedFiles && File.GetLastWriteTimeUtc(sourcePath) < File.GetLastWriteTimeUtc(destPath)) { Log.LogMessage(MessageImportance.Low, "Skipping \"{0}\" -> \"{1}\" because the destination is up to date.", sourcePath, destPath); continue; } diff --git a/src/DotNetOpenAuth.sln b/src/DotNetOpenAuth.sln index 3233865..569a7bc 100644 --- a/src/DotNetOpenAuth.sln +++ b/src/DotNetOpenAuth.sln @@ -7,6 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetOpenAuth.Test", "DotN EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{20B5E173-C3C4-49F8-BD25-E69044075B4D}" ProjectSection(SolutionItems) = preProject + ..\build.proj = ..\build.proj DotNetOpenAuth.vsmdi = DotNetOpenAuth.vsmdi ..\LICENSE.txt = ..\LICENSE.txt LocalTestRun.testrunconfig = LocalTestRun.testrunconfig @@ -169,6 +170,11 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebFormsRelyingParty", "..\projecttemplates\WebFormsRelyingParty\WebFormsRelyingParty.csproj", "{A78F8FC6-7B03-4230-BE41-761E400D6810}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelyingPartyLogic", "..\projecttemplates\RelyingPartyLogic\RelyingPartyLogic.csproj", "{17932639-1F50-48AF-B0A5-E2BF832F82CC}" + ProjectSection(ProjectDependencies) = postProject + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D} = {2B4261AC-25AC-4B8D-B459-1C42B6B1401D} + EndProjectSection +EndProject +Project("{C8D11400-126E-41CD-887F-60BD40844F9E}") = "RelyingPartyDatabase", "..\projecttemplates\RelyingPartyDatabase\RelyingPartyDatabase.dbproj", "{2B4261AC-25AC-4B8D-B459-1C42B6B1401D}" EndProject Global GlobalSection(TestCaseManagementSettings) = postSolution @@ -276,6 +282,15 @@ Global {17932639-1F50-48AF-B0A5-E2BF832F82CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {17932639-1F50-48AF-B0A5-E2BF832F82CC}.Release|Any CPU.ActiveCfg = Release|Any CPU {17932639-1F50-48AF-B0A5-E2BF832F82CC}.Release|Any CPU.Build.0 = Release|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.CodeAnalysis|Any CPU.ActiveCfg = Debug|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.CodeAnalysis|Any CPU.Build.0 = Debug|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.CodeAnalysis|Any CPU.Deploy.0 = Debug|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.Release|Any CPU.Build.0 = Release|Any CPU + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -298,5 +313,6 @@ Global {5C65603B-235F-47E6-B536-06385C60DE7F} = {E9ED920D-1F83-48C0-9A4B-09CCE505FE6D} {A78F8FC6-7B03-4230-BE41-761E400D6810} = {B9EB8729-4B54-4453-B089-FE6761BA3057} {17932639-1F50-48AF-B0A5-E2BF832F82CC} = {B9EB8729-4B54-4453-B089-FE6761BA3057} + {2B4261AC-25AC-4B8D-B459-1C42B6B1401D} = {B9EB8729-4B54-4453-B089-FE6761BA3057} EndGlobalSection EndGlobal diff --git a/src/DotNetOpenAuth/Logger.cs b/src/DotNetOpenAuth/Logger.cs index a9dbef2..48007ed 100644 --- a/src/DotNetOpenAuth/Logger.cs +++ b/src/DotNetOpenAuth/Logger.cs @@ -60,6 +60,11 @@ namespace DotNetOpenAuth { private static readonly ILog http = Create("DotNetOpenAuth.Http"); /// <summary> + /// Backing field for the <see cref="Controls"/> property. + /// </summary> + private static readonly ILog controls = Create("DotNetOpenAuth.Controls"); + + /// <summary> /// Backing field for the <see cref="OpenId"/> property. /// </summary> private static readonly ILog openId = Create("DotNetOpenAuth.OpenId"); @@ -110,6 +115,11 @@ namespace DotNetOpenAuth { internal static ILog Http { get { return http; } } /// <summary> + /// Gets the logger for events logged by ASP.NET controls. + /// </summary> + internal static ILog Controls { get { return controls; } } + + /// <summary> /// Gets the logger for high-level OpenID events. /// </summary> internal static ILog OpenId { get { return openId; } } diff --git a/src/DotNetOpenAuth/Messaging/Bindings/StandardReplayProtectionBindingElement.cs b/src/DotNetOpenAuth/Messaging/Bindings/StandardReplayProtectionBindingElement.cs index 0a7ddbd..bb56cfd 100644 --- a/src/DotNetOpenAuth/Messaging/Bindings/StandardReplayProtectionBindingElement.cs +++ b/src/DotNetOpenAuth/Messaging/Bindings/StandardReplayProtectionBindingElement.cs @@ -125,6 +125,7 @@ namespace DotNetOpenAuth.Messaging.Bindings { ErrorUtilities.VerifyProtocol(nonceMessage.Nonce.Length > 0 || this.AllowZeroLengthNonce, MessagingStrings.InvalidNonceReceived); if (!this.nonceStore.StoreNonce(nonceMessage.NonceContext, nonceMessage.Nonce, nonceMessage.UtcCreationDate)) { + Logger.OpenId.ErrorFormat("Replayed nonce detected ({0} {1}). Rejecting message.", nonceMessage.Nonce, nonceMessage.UtcCreationDate); throw new ReplayedMessageException(message); } diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs index 1c20f1d..4fa70a0 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs @@ -223,7 +223,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { yield return extension; } } else { - Logger.OpenId.WarnFormat("Extension with type URI '{0}' ignored because it is not a recognized extension.", typeUri); + Logger.OpenId.DebugFormat("Extension with type URI '{0}' ignored because it is not a recognized extension.", typeUri); } } } diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/ReturnToNonceBindingElement.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/ReturnToNonceBindingElement.cs index 9040404..817407c 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/ReturnToNonceBindingElement.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/ReturnToNonceBindingElement.cs @@ -187,6 +187,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { IReplayProtectedProtocolMessage replayResponse = response; if (!this.nonceStore.StoreNonce(replayResponse.NonceContext, nonce.RandomPartAsString, nonce.CreationDateUtc)) { + Logger.OpenId.ErrorFormat("Replayed nonce detected ({0} {1}). Rejecting message.", replayResponse.Nonce, replayResponse.UtcCreationDate); throw new ReplayedMessageException(message); } diff --git a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionsInteropHelper.cs b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionsInteropHelper.cs index cd7575e..9d3f576 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/ExtensionsInteropHelper.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/ExtensionsInteropHelper.cs @@ -47,12 +47,12 @@ namespace DotNetOpenAuth.OpenId.Extensions { var req = (RelyingParty.AuthenticationRequest)request; var sreg = req.AppliedExtensions.OfType<ClaimsRequest>().SingleOrDefault(); if (sreg == null) { - Logger.OpenId.Warn("No Simple Registration (ClaimsRequest) extension present in the request to spread to AX."); + Logger.OpenId.Debug("No Simple Registration (ClaimsRequest) extension present in the request to spread to AX."); return; } if (req.Provider.IsExtensionSupported<ClaimsRequest>()) { - Logger.OpenId.Info("Skipping generation of AX request because the Identifier advertises the Provider supports the Sreg extension."); + Logger.OpenId.Debug("Skipping generation of AX request because the Identifier advertises the Provider supports the Sreg extension."); return; } @@ -65,11 +65,11 @@ namespace DotNetOpenAuth.OpenId.Extensions { // Try to use just one AX Type URI format if we can figure out which type the OP accepts. AXAttributeFormats detectedFormat; if (TryDetectOPAttributeFormat(request, out detectedFormat)) { - Logger.OpenId.Info("Detected OP support for AX but not for Sreg. Removing Sreg extension request and using AX instead."); + Logger.OpenId.Debug("Detected OP support for AX but not for Sreg. Removing Sreg extension request and using AX instead."); attributeFormats = detectedFormat; req.Extensions.Remove(sreg); } else { - Logger.OpenId.Info("Could not determine whether OP supported Sreg or AX. Using both extensions."); + Logger.OpenId.Debug("Could not determine whether OP supported Sreg or AX. Using both extensions."); } foreach (AXAttributeFormats format in ForEachFormat(attributeFormats)) { diff --git a/src/DotNetOpenAuth/OpenId/Provider/StandardProviderApplicationStore.cs b/src/DotNetOpenAuth/OpenId/Provider/StandardProviderApplicationStore.cs index 7085e72..f33a655 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/StandardProviderApplicationStore.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/StandardProviderApplicationStore.cs @@ -122,7 +122,7 @@ namespace DotNetOpenAuth.OpenId.Provider { /// </summary> /// <param name="context">The context, or namespace, within which the <paramref name="nonce"/> must be unique.</param> /// <param name="nonce">A series of random characters.</param> - /// <param name="timestamp">The timestamp that together with the nonce string make it unique. + /// <param name="timestampUtc">The timestamp that together with the nonce string make it unique. /// The timestamp may also be used by the data store to clear out old nonces.</param> /// <returns> /// True if the nonce+timestamp (combination) was not previously in the database. @@ -135,8 +135,8 @@ namespace DotNetOpenAuth.OpenId.Provider { /// is retrieved or set using the /// <see cref="StandardExpirationBindingElement.MaximumMessageAge"/> property. /// </remarks> - public bool StoreNonce(string context, string nonce, DateTime timestamp) { - return this.nonceStore.StoreNonce(context, nonce, timestamp); + public bool StoreNonce(string context, string nonce, DateTime timestampUtc) { + return this.nonceStore.StoreNonce(context, nonce, timestampUtc); } #endregion diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs index f1851a0..a317b95 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs @@ -416,7 +416,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { var failedAssociationEndpoints = new List<ServiceEndpoint>(0); foreach (var endpoint in endpoints) { - Logger.OpenId.InfoFormat("Creating authentication request for user supplied Identifier: {0}", userSuppliedIdentifier); + Logger.OpenId.DebugFormat("Creating authentication request for user supplied Identifier: {0}", userSuppliedIdentifier); // The strategy here is to prefer endpoints with whom we can create associations. Association association = null; @@ -446,10 +446,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { if (relyingParty.SecuritySettings.RequireAssociation) { Logger.OpenId.Warn("Associations could not be formed with some Providers. Security settings require shared associations for authentication requests so these will be skipped."); } else { - Logger.OpenId.WarnFormat("Now generating requests for Provider endpoints that failed initial association attempts."); + Logger.OpenId.Debug("Now generating requests for Provider endpoints that failed initial association attempts."); foreach (var endpoint in failedAssociationEndpoints) { - Logger.OpenId.WarnFormat("Creating authentication request for user supplied Identifier: {0}", userSuppliedIdentifier); + Logger.OpenId.DebugFormat("Creating authentication request for user supplied Identifier: {0} at endpoint: {1}", userSuppliedIdentifier, endpoint.ProviderEndpoint.AbsoluteUri); // Create the auth request, but prevent it from attempting to create an association // because we've already tried. Let's not have it waste time trying again. diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs index 4249834..f646599 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs @@ -704,6 +704,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); + if (!this.Visible) { + return; + } + if (this.DownloadYahooUILibrary) { // Although we'll add the <script> tag to download the YAHOO component, // a download failure may have occurred, so protect ourselves from a diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs index 44a5b41..0254346 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs @@ -174,6 +174,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { }; this.authenticationResponse = this.RelyingParty.GetResponse(clientResponseInfo); + Logger.Controls.DebugFormat( + "The {0} control checked for an authentication response and found: {1}", + this.ID, + this.authenticationResponse.Status); this.AuthenticationProcessedAlready = false; // Save out the authentication response to viewstate so we can find it on @@ -416,10 +420,14 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Notifies the user agent via an AJAX response of a completed authentication attempt. /// </summary> protected override void ScriptClosingPopupOrIFrame() { - Logger.OpenId.InfoFormat("AJAX (iframe) callback from OP: {0}", this.Page.Request.Url); + Logger.OpenId.DebugFormat("AJAX (iframe) callback from OP: {0}", this.Page.Request.Url); string extensionsJson = null; var authResponse = RelyingPartyNonVerifying.GetResponse(); + Logger.Controls.DebugFormat( + "The {0} control checked for an authentication response from a popup window or iframe using a non-verifying RP and found: {1}", + this.ID, + authResponse.Status); if (authResponse.Status == AuthenticationStatus.Authenticated) { this.OnUnconfirmedPositiveAssertion(); // event handler will fill the clientScriptExtensions collection. var extensionsDictionary = new Dictionary<string, string>(); @@ -613,7 +621,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <param name="methodCall">The method to call on the OpenIdAjaxTextBox, including /// parameters. (i.e. "callback('arg1', 2)"). No escaping is done by this method.</param> private void CallbackUserAgentMethod(string methodCall) { - Logger.OpenId.InfoFormat("Sending Javascript callback: {0}", methodCall); + Logger.OpenId.DebugFormat("Sending Javascript callback: {0}", methodCall); Page.Response.Write(@"<html><body><script language='javascript'> var inPopup = !window.frameElement; var objSrc = inPopup ? window.opener : window.frameElement; diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs index 538e9f2..2420fd6 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs @@ -482,6 +482,16 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } /// <summary> + /// Gets a value indicating whether this control is a child control of a composite OpenID control. + /// </summary> + /// <value> + /// <c>true</c> if this instance is embedded in parent OpenID control; otherwise, <c>false</c>. + /// </value> + protected bool IsEmbeddedInParentOpenIdControl { + get { return this.ParentControls.OfType<OpenIdRelyingPartyControlBase>().Any(); } + } + + /// <summary> /// Clears any cookie set by this control to help the user on a returning visit next time. /// </summary> public static void LogOff() { @@ -608,11 +618,17 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { return; // don't do any more processing on it now } - // Only sniff for an OpenID response if it is targeted at this control. Note that - // Stateless mode causes no receiver to be indicated. + // Only sniff for an OpenID response if it is targeted at this control. + // Note that Stateless mode causes no receiver to be indicated, and + // we want to handle that, but only if there isn't a parent control that + // will be handling that. string receiver = this.Page.Request.QueryString[ReturnToReceivingControlId] ?? this.Page.Request.Form[ReturnToReceivingControlId]; - if (receiver == null || receiver == this.ClientID) { + if (receiver == this.ClientID || (receiver == null && !this.IsEmbeddedInParentOpenIdControl)) { var response = this.RelyingParty.GetResponse(); + Logger.Controls.DebugFormat( + "The {0} control checked for an authentication response and found: {1}", + this.ID, + response != null ? response.Status.ToString() : "nothing"); this.ProcessResponse(response); } } diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs index ed83412..e93383d 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs @@ -81,6 +81,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { private HiddenField positiveAssertionField; /// <summary> + /// A field to store the value to set on the <see cref="textBox"/> control after it's created. + /// </summary> + private bool downloadYuiLibrary = OpenIdAjaxTextBox.DownloadYahooUILibraryDefault; + + /// <summary> /// Initializes a new instance of the <see cref="OpenIdSelector"/> class. /// </summary> public OpenIdSelector() { @@ -121,13 +126,19 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { [Description("Whether a split button will be used for the \"log in\" when the user provides an identifier that delegates to more than one Provider.")] public bool DownloadYahooUILibrary { get { - this.EnsureChildControls(); - return this.textBox.DownloadYahooUILibrary; + return this.textBox != null ? this.textBox.DownloadYahooUILibrary : this.downloadYuiLibrary; } set { - this.EnsureChildControls(); - this.textBox.DownloadYahooUILibrary = value; + // We don't just call EnsureChildControls() and then set the property on + // this.textBox itself because (apparently) setting this property in the ASPX + // page and thus calling this EnsureID() via EnsureChildControls() this early + // results in no ID. + if (this.textBox != null) { + this.textBox.DownloadYahooUILibrary = value; + } else { + this.downloadYuiLibrary = value; + } } } @@ -171,6 +182,14 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } /// <summary> + /// Gets a value indicating whether some button in the selector will want + /// to display the <see cref="OpenIdAjaxTextBox"/> control. + /// </summary> + protected virtual bool OpenIdTextBoxVisible { + get { return this.Buttons.OfType<SelectorOpenIdButton>().Any(); } + } + + /// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> @@ -190,6 +209,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { protected override void CreateChildControls() { base.CreateChildControls(); this.EnsureID(); + ErrorUtilities.VerifyInternal(!string.IsNullOrEmpty(this.UniqueID), "Control.EnsureID() failed to give us a unique ID. Try setting an ID on the OpenIdSelector control. But please also file this bug with the project owners."); var selectorButton = this.Buttons.OfType<SelectorInfoCardButton>().FirstOrDefault(); if (selectorButton != null) { @@ -205,6 +225,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { this.textBox.ID = "openid_identifier"; this.textBox.HookFormSubmit = false; this.textBox.ShowLogOnPostBackButton = true; + this.textBox.DownloadYahooUILibrary = this.downloadYuiLibrary; this.Controls.Add(this.textBox); this.positiveAssertionField = new HiddenField(); @@ -259,6 +280,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Postback", script, true); this.PreloadDiscovery(this.Buttons.OfType<SelectorProviderButton>().Select(op => op.OPIdentifier).Where(id => id != null)); + this.textBox.Visible = this.OpenIdTextBoxVisible; } /// <summary> @@ -295,13 +317,15 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { writer.RenderEndTag(); // </ul> - writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); - writer.AddAttribute(HtmlTextWriterAttribute.Id, "OpenIDForm"); - writer.RenderBeginTag(HtmlTextWriterTag.Div); + if (this.textBox.Visible) { + writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); + writer.AddAttribute(HtmlTextWriterAttribute.Id, "OpenIDForm"); + writer.RenderBeginTag(HtmlTextWriterTag.Div); - this.textBox.RenderControl(writer); + this.textBox.RenderControl(writer); - writer.RenderEndTag(); // </div> + writer.RenderEndTag(); // </div> + } this.positiveAssertionField.RenderControl(writer); } diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js index 6271952..c58e06e 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js @@ -10,7 +10,7 @@ $(function() { var hint = $.cookie('openid_identifier') || ''; var ajaxbox = document.getElementsByName('openid_identifier')[0]; - if (hint != 'infocard') { + if (ajaxbox && hint != 'infocard') { ajaxbox.setValue(hint); } @@ -31,12 +31,18 @@ $(function() { } }); if (!matchFound) { - $('#OpenIDButton') - .removeClass('grayedOut') - .addClass('focused'); - $('#OpenIDForm').show('slow', function() { - ajaxbox.focus(); - }); + if (ajaxbox) { + $('#OpenIDButton') + .removeClass('grayedOut') + .addClass('focused'); + $('#OpenIDForm').show('slow', function() { + ajaxbox.focus(); + }); + } else { + // No OP button matched the last identifier, and there is no text box, + // so just un-gray all buttons. + ops.removeClass('grayedOut'); + } } } @@ -65,13 +71,15 @@ $(function() { } }); - ajaxbox.onStateChanged = function(state) { - if (state == "authenticated") { - showLoginSuccess('OpenIDButton', true); - } else { - showLoginSuccess('OpenIDButton', false); // hide checkmark - } - }; + if (ajaxbox) { + ajaxbox.onStateChanged = function(state) { + if (state == "authenticated") { + showLoginSuccess('OpenIDButton', true); + } else { + showLoginSuccess('OpenIDButton', false); // hide checkmark + } + }; + } function checkidSetup(identifier, timerBased) { var openid = new window.OpenIdIdentifier(identifier); @@ -88,8 +96,10 @@ $(function() { window.postLoginAssertion(respondingEndpoint.response.toString(), window.parent.location.href); } - // take over how the text box does postbacks. - ajaxbox.dnoi_internal.postback = doLogin; + if (ajaxbox) { + // take over how the text box does postbacks. + ajaxbox.dnoi_internal.postback = doLogin; + } // This FrameManager will be used for background logins for the OP buttons // and the last used identifier. It is NOT the frame manager used by the @@ -138,7 +148,7 @@ $(function() { // Don't immediately login if the user clicked OpenID and he can't see the identifier box. if ($(this)[0].id != 'OpenIDButton') { relevantUserSuppliedIdentifier = $(this)[0].id; - } else if ($('#OpenIDForm').is(':visible')) { + } else if (ajaxbox && $('#OpenIDForm').is(':visible')) { relevantUserSuppliedIdentifier = ajaxbox.value; } @@ -157,16 +167,18 @@ $(function() { $('img', this)[0].click(); } }); - $('#OpenIDButton').click(function() { - // Be careful to only try to select the text box once it is available. - if ($('#OpenIDForm').is(':hidden')) { - $('#OpenIDForm').show('slow', function() { + if (ajaxbox) { + $('#OpenIDButton').click(function() { + // Be careful to only try to select the text box once it is available. + if ($('#OpenIDForm').is(':hidden')) { + $('#OpenIDForm').show('slow', function() { + ajaxbox.focus(); + }); + } else { ajaxbox.focus(); - }); - } else { - ajaxbox.focus(); - } - }); + } + }); + } // Make popup window close on escape (the dialog style is already taken care of) $(document).keydown(function(e) { diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs index 7338b1a..7a1fbbf 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs @@ -40,6 +40,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { this.provider = new ProviderEndpointDescription(response.ProviderEndpoint, response.Version); } + // Derived types of this are responsible to log an appropriate message for themselves. + if (Logger.OpenId.IsInfoEnabled && this.GetType() == typeof(PositiveAnonymousResponse)) { + Logger.OpenId.Info("Received anonymous (identity-less) positive assertion."); + } + Reporting.RecordEventOccurrence(this, response.ProviderEndpoint.AbsoluteUri); } @@ -130,6 +135,16 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { #endregion /// <summary> + /// Gets a value indicating whether trusted callback arguments are available. + /// </summary> + /// <remarks> + /// We use this internally to avoid logging a warning during a standard snapshot creation. + /// </remarks> + internal bool TrustedCallbackArgumentsAvailable { + get { return this.response.ReturnToParametersSignatureValidated; } + } + + /// <summary> /// Gets the positive extension-only message the Relying Party received that this instance wraps. /// </summary> protected internal IndirectSignedResponse Response { diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs index e809205..0fd034c 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs @@ -37,6 +37,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { null); this.VerifyDiscoveryMatchesAssertion(relyingParty); + + Logger.OpenId.InfoFormat("Received identity assertion for {0} via {1}.", this.ClaimedIdentifier, this.Provider.Uri); } #region IAuthenticationResponse Properties diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs index 32c8af9..80b424a 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs @@ -39,8 +39,15 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { this.FriendlyIdentifierForDisplay = copyFrom.FriendlyIdentifierForDisplay; this.Status = copyFrom.Status; this.Provider = copyFrom.Provider; - this.callbackArguments = copyFrom.GetCallbackArguments(); this.untrustedCallbackArguments = copyFrom.GetUntrustedCallbackArguments(); + + // Do this special check to avoid logging a warning for trying to clone a dictionary. + var anonResponse = copyFrom as PositiveAnonymousResponse; + if (anonResponse == null || anonResponse.TrustedCallbackArgumentsAvailable) { + this.callbackArguments = copyFrom.GetCallbackArguments(); + } else { + this.callbackArguments = EmptyDictionary<string, string>.Instance; + } } #region IAuthenticationResponse Members diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/SelectorOpenIdButton.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/SelectorOpenIdButton.cs index 0b11695..15b6ca7 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/SelectorOpenIdButton.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/SelectorOpenIdButton.cs @@ -5,7 +5,9 @@ //----------------------------------------------------------------------- namespace DotNetOpenAuth.OpenId.RelyingParty { + using System.ComponentModel; using System.Diagnostics.Contracts; + using System.Drawing.Design; using System.Web.UI; using DotNetOpenAuth.Messaging; @@ -25,6 +27,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Gets or sets the path to the image to display on the button's surface. /// </summary> /// <value>The virtual path to the image.</value> + [Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))] + [UrlProperty] public string Image { get; set; } /// <summary> diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/SelectorProviderButton.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/SelectorProviderButton.cs index 1d4dcf2..3a05287 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/SelectorProviderButton.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/SelectorProviderButton.cs @@ -7,6 +7,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System.ComponentModel; using System.Diagnostics.Contracts; + using System.Drawing.Design; using System.Web.UI; using DotNetOpenAuth.ComponentModel; using DotNetOpenAuth.Messaging; @@ -27,6 +28,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Gets or sets the path to the image to display on the button's surface. /// </summary> /// <value>The virtual path to the image.</value> + [Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))] + [UrlProperty] public string Image { get; set; } /// <summary> diff --git a/tools/Publish.targets b/tools/Publish.targets index abdaf39..415750c 100644 --- a/tools/Publish.targets +++ b/tools/Publish.targets @@ -67,6 +67,11 @@ <Copy SourceFiles="@(PublishableWebSampleSources)" DestinationFiles="@(PublishableWebSampleTargets)" SkipUnchangedFiles="true" /> </Target> + <Target Name="UnpublishSamples" + DependsOnTargets="DeleteSampleSitesOnIis" + Condition=" '$(SampleWebRoot)' != '' "> + </Target> + <Target Name="PrepareForPublishDocumentation" DependsOnTargets="Documentation"> <ItemGroup> <DocSources Include="$(ProjectRoot)doc\api\**\*" /> @@ -84,6 +89,11 @@ <Copy SourceFiles="@(DocSources)" DestinationFiles="@(DocTargets)" SkipUnchangedFiles="true" /> </Target> + <Target Name="UnpublishDocumentation" + DependsOnTargets="DeleteDocumentationSiteOnIis" + Condition=" '$(DocWebRoot)' != '' "> + </Target> + <Target Name="CreateSampleSitesOnIis" DependsOnTargets="PrepareForIIS;PrepareForPublishSamples"> <Error Text="The PublishSamplesWebSiteName property must be set." Condition=" '$(PublishSamplesWebSiteName)' == '' "/> <Error Text="The SampleWebRoot property must be set." Condition=" '$(SampleWebRoot)' == '' " /> diff --git a/tools/sandcastle.targets b/tools/sandcastle.targets index 4db9d5d..65511f8 100644 --- a/tools/sandcastle.targets +++ b/tools/sandcastle.targets @@ -42,10 +42,31 @@ </ItemGroup> <Target Name="CleanDocumentation"> - <Delete Files="$(ReflectionFile);$(ManifestFile);$(ReflectionBaseFile);$(ChmFile)" TreatErrorsAsWarnings="true"/> - <RemoveDir Directories="$(DocOutputApiPath);$(DocIntermediatePath);$(ChmDir)" ContinueOnError="true"/> - <RemoveDir Directories="$(FxReflectionIntermediatePath)" ContinueOnError="true" /> + <ItemGroup> + <_DirtyFiles Include=" + $(DocOutputApiPath)\**; + $(ReflectionFile); + $(ManifestFile); + $(ReflectionBaseFile); + $(ChmFile) + " + Exclude=" + $(DocOutputApiPath)\Web.config; + $(DocOutputApiPath)\Default.aspx; + " /> + <_DirtyDirectories Include=" + $(DocIntermediatePath); + $(ChmDir); + $(FxReflectionIntermediatePath) + " /> + </ItemGroup> + <Delete Files="@(_DirtyFiles)" TreatErrorsAsWarnings="true"/> + <RemoveDir Directories="@(_DirtyDirectories)" ContinueOnError="true"/> <!--<RemoveDir Directories="$(FxReflectionOutputPath)" ContinueOnError="true" />--> + <ItemGroup> + <_DirtyFiles Remove="@(_DirtyFiles)" /> + <_DirtyDirectories Remove="@(_DirtyDirectories)" /> + </ItemGroup> </Target> <Target Name="CreateIntermediatePath"> |