├── .gitignore ├── .nuget ├── NuGet.exe └── packages.config ├── DotNetOpenAuth.Samples.sln ├── LICENSE.txt ├── README.md ├── Settings.StyleCop ├── build.ps1 ├── default.ps1 ├── nuget.config └── src ├── DotNetOpenAuth.ApplicationBlock ├── CustomExtensions │ ├── Acme.cs │ ├── AcmeRequest.cs │ ├── AcmeResponse.cs │ └── UIRequestAtRelyingPartyFactory.cs ├── DotNetOpenAuth.ApplicationBlock.csproj ├── Facebook │ ├── FacebookClient.cs │ └── FacebookGraph.cs ├── GoogleConsumer.cs ├── InMemoryClientAuthorizationTracker.cs ├── InMemoryTokenManager.cs ├── Properties │ └── AssemblyInfo.cs ├── TokenManager.cs ├── TwitterConsumer.cs ├── Util.cs ├── WindowsLiveClient.cs ├── WindowsLiveGraph.cs ├── YammerConsumer.cs ├── YubikeyRelyingParty.cs └── packages.config ├── OAuth ├── OAuthAuthorizationServer │ ├── Code │ │ ├── Client.cs │ │ ├── DataClasses.dbml │ │ ├── DataClasses.dbml.layout │ │ ├── DataClasses.designer.cs │ │ ├── DatabaseKeyNonceStore.cs │ │ ├── HttpHeaderAttribute.cs │ │ ├── OAuth2AuthorizationServer.cs │ │ └── Utilities.cs │ ├── Content │ │ ├── bootstrap.yeti.css │ │ └── bootstrap.yeti.min.css │ ├── Controllers │ │ ├── AccountController.cs │ │ ├── HomeController.cs │ │ └── OAuthController.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── Models │ │ ├── AccountAuthorizeModel.cs │ │ └── AccountModels.cs │ ├── OAuthAuthorizationServer.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Scripts │ │ ├── MicrosoftAjax.debug.js │ │ ├── MicrosoftAjax.js │ │ ├── MicrosoftMvcAjax.debug.js │ │ ├── MicrosoftMvcAjax.js │ │ ├── MicrosoftMvcValidation.debug.js │ │ ├── MicrosoftMvcValidation.js │ │ ├── jquery-1.4.1-vsdoc.js │ │ ├── jquery-1.4.1.js │ │ ├── jquery-1.4.1.min.js │ │ ├── jquery-1.4.4-vsdoc.js │ │ ├── jquery-1.4.4.js │ │ ├── jquery-1.4.4.min.js │ │ ├── jquery-ui.js │ │ ├── jquery-ui.min.js │ │ ├── jquery.unobtrusive-ajax.js │ │ ├── jquery.unobtrusive-ajax.min.js │ │ ├── jquery.validate-vsdoc.js │ │ ├── jquery.validate.js │ │ ├── jquery.validate.min.js │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ ├── Views │ │ ├── Account │ │ │ └── LogOn.aspx │ │ ├── Home │ │ │ ├── About.aspx │ │ │ ├── CreateDatabase.aspx │ │ │ └── Index.aspx │ │ ├── OAuth │ │ │ └── Authorize.aspx │ │ ├── Shared │ │ │ ├── Error.aspx │ │ │ ├── LogOnUserControl.ascx │ │ │ └── Site.Master │ │ └── Web.config │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ └── packages.config ├── OAuthClient │ ├── Code │ │ ├── Logging.cs │ │ └── TracePageAppender.cs │ ├── Content │ │ ├── bootstrap.yeti.css │ │ └── bootstrap.yeti.min.css │ ├── Default.aspx │ ├── Facebook.aspx │ ├── Facebook.aspx.cs │ ├── Facebook.aspx.designer.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── GoogleAddressBook.aspx │ ├── GoogleAddressBook.aspx.cs │ ├── GoogleAddressBook.aspx.designer.cs │ ├── GoogleApps2Legged.aspx │ ├── GoogleApps2Legged.aspx.cs │ ├── GoogleApps2Legged.aspx.designer.cs │ ├── MasterPage.master │ ├── OAuthClient.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SampleWcf2.aspx │ ├── SampleWcf2.aspx.cs │ ├── SampleWcf2.aspx.designer.cs │ ├── SampleWcf2Javascript.html │ ├── SampleWcf2Javascript.js │ ├── Scripts │ │ ├── jquery-1.6.1.js │ │ └── jquery-1.6.1.min.js │ ├── Service References │ │ └── SampleResourceServer │ │ │ ├── DataApi.disco │ │ │ ├── DataApi.wsdl │ │ │ ├── DataApi.xsd │ │ │ ├── DataApi1.xsd │ │ │ ├── DataApi2.xsd │ │ │ ├── Reference.cs │ │ │ ├── Reference.svcmap │ │ │ ├── configuration.svcinfo │ │ │ └── configuration91.svcinfo │ ├── Settings.StyleCop │ ├── SignInWithTwitter.aspx │ ├── SignInWithTwitter.aspx.cs │ ├── SignInWithTwitter.aspx.designer.cs │ ├── TracePage.aspx │ ├── TracePage.aspx.cs │ ├── TracePage.aspx.designer.cs │ ├── Twitter.aspx │ ├── Twitter.aspx.cs │ ├── Twitter.aspx.designer.cs │ ├── Web.config │ ├── WindowsLive.aspx │ ├── WindowsLive.aspx.cs │ ├── WindowsLive.aspx.designer.cs │ ├── Yammer.aspx │ ├── Yammer.aspx.cs │ ├── Yammer.aspx.designer.cs │ ├── favicon.ico │ ├── images │ │ └── Sign-in-with-Twitter-darker.png │ └── packages.config ├── OAuthConsumer │ ├── Code │ │ ├── Logging.cs │ │ └── TracePageAppender.cs │ ├── Content │ │ ├── bootstrap.yeti.css │ │ └── bootstrap.yeti.min.css │ ├── Default.aspx │ ├── Global.asax │ ├── Global.asax.cs │ ├── GoogleAddressBook.aspx │ ├── GoogleAddressBook.aspx.cs │ ├── GoogleAddressBook.aspx.designer.cs │ ├── GoogleApps2Legged.aspx │ ├── GoogleApps2Legged.aspx.cs │ ├── GoogleApps2Legged.aspx.designer.cs │ ├── MasterPage.master │ ├── OAuthConsumer.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SampleWcf.aspx │ ├── SampleWcf.aspx.cs │ ├── SampleWcf.aspx.designer.cs │ ├── Service References │ │ └── SampleServiceProvider │ │ │ ├── DataApi.disco │ │ │ ├── DataApi.wsdl │ │ │ ├── DataApi.xsd │ │ │ ├── DataApi1.xsd │ │ │ ├── DataApi2.xsd │ │ │ ├── Reference.cs │ │ │ ├── Reference.svcmap │ │ │ ├── configuration.svcinfo │ │ │ └── configuration91.svcinfo │ ├── Settings.StyleCop │ ├── SignInWithTwitter.aspx │ ├── SignInWithTwitter.aspx.cs │ ├── SignInWithTwitter.aspx.designer.cs │ ├── TracePage.aspx │ ├── TracePage.aspx.cs │ ├── TracePage.aspx.designer.cs │ ├── Twitter.aspx │ ├── Twitter.aspx.cs │ ├── Twitter.aspx.designer.cs │ ├── Web.config │ ├── Yammer.aspx │ ├── Yammer.aspx.cs │ ├── Yammer.aspx.designer.cs │ ├── favicon.ico │ ├── images │ │ └── Sign-in-with-Twitter-darker.png │ └── packages.config ├── OAuthConsumerWpf │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── Authorize.xaml │ ├── Authorize.xaml.cs │ ├── Authorize2.xaml │ ├── Authorize2.xaml.cs │ ├── InMemoryTokenManager.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── OAuthConsumerWpf.csproj │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Service References │ │ └── WcfSampleService │ │ │ ├── DataApi.disco │ │ │ ├── DataApi.wsdl │ │ │ ├── DataApi.xsd │ │ │ ├── DataApi1.xsd │ │ │ ├── DataApi2.xsd │ │ │ ├── Reference.cs │ │ │ ├── Reference.svcmap │ │ │ ├── configuration.svcinfo │ │ │ └── configuration91.svcinfo │ ├── favicon.ico │ └── packages.config ├── OAuthResourceServer │ ├── Code │ │ ├── Global.cs │ │ ├── IDataApi.cs │ │ ├── OAuthAuthorizationManager.cs │ │ ├── OAuthPrincipalAuthorizationPolicy.cs │ │ └── TracePageAppender.cs │ ├── Content │ │ ├── bootstrap.yeti.css │ │ └── bootstrap.yeti.min.css │ ├── DataApi.cs │ ├── DataApi.svc │ ├── Default.aspx │ ├── Default.aspx.cs │ ├── Default.aspx.designer.cs │ ├── Global.asax │ ├── Login.aspx │ ├── MasterPage.master │ ├── Members │ │ ├── Logoff.aspx │ │ └── Web.config │ ├── OAuthResourceServer.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Settings.StyleCop │ ├── TracePage.aspx │ ├── TracePage.aspx.cs │ ├── TracePage.aspx.designer.cs │ ├── Web.config │ ├── favicon.ico │ └── packages.config └── OAuthServiceProvider │ ├── Code │ ├── Constants.cs │ ├── CustomOAuthTypeProvider.cs │ ├── DataClasses.dbml │ ├── DataClasses.dbml.layout │ ├── DataClasses.designer.cs │ ├── DatabaseNonceStore.cs │ ├── DatabaseTokenManager.cs │ ├── Global.cs │ ├── IDataApi.cs │ ├── OAuthAuthorizationManager.cs │ ├── OAuthConsumer.cs │ ├── OAuthPrincipalAuthorizationPolicy.cs │ ├── OAuthToken.cs │ ├── RequestScopedTokenMessage.cs │ ├── TokenAuthorizationState.cs │ ├── TracePageAppender.cs │ └── Utilities.cs │ ├── DataApi.cs │ ├── DataApi.svc │ ├── Default.aspx │ ├── Default.aspx.cs │ ├── Default.aspx.designer.cs │ ├── Global.asax │ ├── Login.aspx │ ├── MasterPage.master │ ├── Members │ ├── Authorize.aspx │ ├── Authorize.aspx.cs │ ├── Authorize.aspx.designer.cs │ ├── AuthorizedConsumers.aspx │ ├── AuthorizedConsumers.aspx.cs │ ├── AuthorizedConsumers.aspx.designer.cs │ ├── Logoff.aspx │ └── Web.config │ ├── OAuth.ashx │ ├── OAuthServiceProvider.csproj │ ├── Properties │ └── AssemblyInfo.cs │ ├── Settings.StyleCop │ ├── TracePage.aspx │ ├── TracePage.aspx.cs │ ├── TracePage.aspx.designer.cs │ ├── Web.config │ └── favicon.ico ├── OpenID ├── OpenIdOfflineProvider │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── CheckIdWindow.xaml │ ├── CheckIdWindow.xaml.cs │ ├── HostedProvider.cs │ ├── HttpHost.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── NativeMethods.cs │ ├── OpenIdOfflineProvider.csproj │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Settings.StyleCop │ ├── TextBoxTextWriter.cs │ ├── openid.ico │ └── packages.config ├── OpenIdProviderMvc │ ├── App_Data │ │ └── Users.xml │ ├── Code │ │ ├── AccountMembershipService.cs │ │ ├── AnonymousIdentifierProvider.cs │ │ ├── FormsAuthenticationService.cs │ │ ├── IFormsAuthentication.cs │ │ ├── IMembershipService.cs │ │ ├── ReadOnlyXmlMembershipProvider.cs │ │ └── Util.cs │ ├── Content │ │ ├── bootstrap.yeti.css │ │ └── bootstrap.yeti.min.css │ ├── Controllers │ │ ├── AccountController.cs │ │ ├── HomeController.cs │ │ ├── OpenIdController.cs │ │ └── UserController.cs │ ├── Default.aspx │ ├── Default.aspx.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── Models │ │ └── User.cs │ ├── OpenIdProviderMvc.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Scripts │ │ ├── MicrosoftAjax.debug.js │ │ ├── MicrosoftAjax.js │ │ ├── MicrosoftMvcAjax.debug.js │ │ ├── MicrosoftMvcAjax.js │ │ ├── MicrosoftMvcValidation.debug.js │ │ ├── MicrosoftMvcValidation.js │ │ ├── jquery-1.3.1-vsdoc.js │ │ ├── jquery-1.3.1.js │ │ ├── jquery-1.3.1.min-vsdoc.js │ │ ├── jquery-1.3.1.min.js │ │ ├── jquery-1.4.4-vsdoc.js │ │ ├── jquery-1.4.4.js │ │ ├── jquery-1.4.4.min.js │ │ ├── jquery-ui.js │ │ ├── jquery-ui.min.js │ │ ├── jquery.unobtrusive-ajax.js │ │ ├── jquery.unobtrusive-ajax.min.js │ │ ├── jquery.validate-vsdoc.js │ │ ├── jquery.validate.js │ │ ├── jquery.validate.min.js │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ ├── Views │ │ ├── Account │ │ │ └── LogOn.aspx │ │ ├── Home │ │ │ └── Index.aspx │ │ ├── OpenId │ │ │ ├── AskUser.aspx │ │ │ └── Provider.aspx │ │ ├── Shared │ │ │ ├── Error.aspx │ │ │ ├── LogOnUserControl.ascx │ │ │ ├── Site.Master │ │ │ └── Xrds.aspx │ │ ├── User │ │ │ └── Identity.aspx │ │ └── Web.config │ ├── Web.config │ ├── favicon.ico │ └── packages.config ├── OpenIdRelyingPartyClassicAsp │ ├── MembersOnly.asp │ ├── default.asp │ ├── favicon.ico │ ├── images │ │ ├── DotNetOpenAuth.png │ │ └── openid_login.png │ ├── login.asp │ ├── logout.asp │ ├── packages.config │ ├── styles.css │ └── web.config ├── OpenIdRelyingPartyMvc │ ├── .gitignore │ ├── Content │ │ ├── bootstrap.yeti.css │ │ ├── bootstrap.yeti.min.css │ │ ├── css │ │ │ └── openidlogin.css │ │ └── images │ │ │ ├── aol.gif │ │ │ ├── facebook.gif │ │ │ ├── google.gif │ │ │ ├── openid.png │ │ │ ├── openid_small.gif │ │ │ └── yahoo.gif │ ├── Controllers │ │ ├── AccountController.cs │ │ ├── HomeController.cs │ │ └── UserController.cs │ ├── Default.aspx │ ├── Global.asax │ ├── Global.asax.cs │ ├── OpenIdRelyingPartyMvc.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Scripts │ │ ├── MicrosoftAjax.debug.js │ │ ├── MicrosoftAjax.js │ │ ├── MicrosoftMvcAjax.debug.js │ │ ├── MicrosoftMvcAjax.js │ │ ├── MicrosoftMvcValidation.debug.js │ │ ├── MicrosoftMvcValidation.js │ │ ├── jquery-2.2.3.intellisense.js │ │ ├── jquery-2.2.3.js │ │ ├── jquery-2.2.3.min.js │ │ ├── jquery-2.2.3.min.map │ │ ├── jquery-ui.js │ │ ├── jquery-ui.min.js │ │ ├── jquery.unobtrusive-ajax.js │ │ ├── jquery.unobtrusive-ajax.min.js │ │ ├── jquery.validate-vsdoc.js │ │ ├── jquery.validate.js │ │ ├── jquery.validate.min.js │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ ├── Views │ │ ├── Home │ │ │ ├── Index.aspx │ │ │ └── xrds.aspx │ │ ├── Shared │ │ │ ├── Site.Master │ │ │ ├── Site.Master.cs │ │ │ └── Site.Master.designer.cs │ │ ├── User │ │ │ ├── Index.aspx │ │ │ └── Login.aspx │ │ └── Web.config │ ├── Web.config │ ├── favicon.ico │ └── packages.config ├── OpenIdWebRingSsoProvider │ ├── App_Data │ │ └── Users.xml │ ├── Code │ │ ├── ReadOnlyXmlMembershipProvider.cs │ │ └── Util.cs │ ├── Default.aspx │ ├── Default.aspx.cs │ ├── Default.aspx.designer.cs │ ├── Login.aspx │ ├── Login.aspx.cs │ ├── Login.aspx.designer.cs │ ├── OpenIdWebRingSsoProvider.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Server.aspx │ ├── Server.aspx.cs │ ├── Server.aspx.designer.cs │ ├── Web.config │ ├── op_xrds.aspx │ ├── packages.config │ ├── user.aspx │ ├── user.aspx.cs │ ├── user.aspx.designer.cs │ └── user_xrds.aspx └── OpenIdWebRingSsoRelyingParty │ ├── Admin │ ├── Default.aspx │ ├── Default.aspx.cs │ ├── Default.aspx.designer.cs │ └── Web.config │ ├── AuthTicketRoles.cs │ ├── Default.aspx │ ├── Default.aspx.cs │ ├── Default.aspx.designer.cs │ ├── Login.aspx │ ├── Login.aspx.cs │ ├── Login.aspx.designer.cs │ ├── OpenIdWebRingSsoRelyingParty.csproj │ ├── Properties │ └── AssemblyInfo.cs │ ├── Web.config │ ├── packages.config │ └── xrds.aspx └── VersionAssemblyInfo.cs /.gitignore: -------------------------------------------------------------------------------- 1 | [Oo]bj/ 2 | [Bb]in/ 3 | TestResults 4 | TestResult.xml 5 | drops 6 | *.VisualState.xml 7 | StyleCop.Cache 8 | *.LDF 9 | *~ 10 | PrecompiledWeb 11 | *.suo 12 | *.log 13 | *.cache 14 | *.user 15 | *.tmp 16 | *.ldf 17 | *.mdf 18 | *.swx 19 | deploy 20 | deploy/* 21 | artifacts/log 22 | artifacts/ 23 | packages/ 24 | /TestResults 25 | .dotest 26 | *.Publish.xml 27 | *.dbproj.schemaview 28 | _ReSharper* 29 | *.vs10x 30 | *.docstates 31 | /.vs 32 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DotNetOpenAuth Samples 2 | ======================== 3 | 4 | [![Build status](https://ci.appveyor.com/api/projects/status/0xmmx1wpt3ys7oa8?svg=true)](https://ci.appveyor.com/project/DavidChristiansen/dotnetopenauth-samples-177) 5 | 6 | 7 | This repository contains sample code for DotNetOpenAuth and aims to help developers toward a successful implementation. 8 | 9 | # How to use 10 | 11 | 1. Download the source via the ZIP file option (typically on the right hand side) or clone the repository 12 | 2. Open in Visual Studio 13 | 14 | 15 | ## Call To Action 16 | 17 | We need developers to help produce more comprehensive demonstrations of implementation and best practice. If you are interested in helping out or have 18 | code that you feel others will benefit from please contact [david@dotnetopenauth.net](mailto:david@dotnetopenauth.net) 19 | -------------------------------------------------------------------------------- /Settings.StyleCop: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | False 8 | 9 | 10 | 11 | 12 | False 13 | 14 | 15 | 16 | 17 | False 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | False 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | False 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | Param( 2 | [string]$buildNumber = "0", 3 | [string]$preRelease = $null 4 | ) 5 | 6 | gci .\ -Recurse "packages.config" |% { 7 | "Restoring " + $_.FullName 8 | .\.nuget\nuget.exe i $_.FullName -o .\packages 9 | } 10 | 11 | Import-Module .\packages\psake.4.4.1\tools\psake.psm1 12 | 13 | if(Test-Path Env:\APPVEYOR_BUILD_NUMBER){ 14 | $buildNumber = [int]$Env:APPVEYOR_BUILD_NUMBER 15 | Write-Host "Using APPVEYOR_BUILD_NUMBER" 16 | 17 | $task = "appVeyor" 18 | } 19 | 20 | "Build number $buildNumber" 21 | 22 | Invoke-Psake .\default.ps1 $task -framework "4.0x64" -properties @{ buildNumber=$buildNumber; preRelease=$preRelease } 23 | 24 | Remove-Module psake -------------------------------------------------------------------------------- /default.ps1: -------------------------------------------------------------------------------- 1 | properties { 2 | $base_directory = Resolve-Path . 3 | $src_directory = "$base_directory" 4 | $output_directory = "$base_directory\build" 5 | $sln_file = "$src_directory\DotNetOpenAuth.Samples.sln" 6 | $target_config = "Release" 7 | $framework_version = "v4.5" 8 | $nuget_path = "$src_directory\.nuget\nuget.exe" 9 | 10 | $buildNumber = 0; 11 | $version = "2.5.0.0" 12 | $preRelease = $null 13 | } 14 | 15 | task default -depends Clean, Compile 16 | task appVeyor -depends Clean, Compile 17 | 18 | task Clean { 19 | rmdir $output_directory -ea SilentlyContinue -recurse 20 | exec { msbuild /nologo /verbosity:quiet $sln_file /p:Configuration=$target_config /t:Clean } 21 | } 22 | 23 | task Compile -depends UpdateVersion { 24 | exec { msbuild /nologo /verbosity:q $sln_file /p:Configuration=$target_config /p:TargetFrameworkVersion=v4.5 } 25 | } 26 | 27 | task UpdateVersion { 28 | $vSplit = $version.Split('.') 29 | if($vSplit.Length -ne 4) 30 | { 31 | throw "Version number is invalid. Must be in the form of 0.0.0.0" 32 | } 33 | $major = $vSplit[0] 34 | $minor = $vSplit[1] 35 | $patch = $vSplit[2] 36 | $assemblyFileVersion = "$major.$minor.$patch.$buildNumber" 37 | $assemblyVersion = "$major.$minor.0.0" 38 | $versionAssemblyInfoFile = "$src_directory/VersionAssemblyInfo.cs" 39 | "using System.Reflection;" > $versionAssemblyInfoFile 40 | "" >> $versionAssemblyInfoFile 41 | "[assembly: AssemblyVersion(""$assemblyVersion"")]" >> $versionAssemblyInfoFile 42 | "[assembly: AssemblyFileVersion(""$assemblyFileVersion"")]" >> $versionAssemblyInfoFile 43 | } 44 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/DotNetOpenAuth.ApplicationBlock/CustomExtensions/AcmeRequest.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Outercurve Foundation. All rights reserved. 4 | // 5 | //----------------------------------------------------------------------- 6 | 7 | namespace DotNetOpenAuth.ApplicationBlock.CustomExtensions { 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using DotNetOpenAuth.Messaging; 12 | using DotNetOpenAuth.OpenId.Messages; 13 | 14 | public class AcmeRequest : IOpenIdMessageExtension { 15 | private IDictionary extraData = new Dictionary(); 16 | 17 | [MessagePart] 18 | public string FavoriteFlavor { get; set; } 19 | 20 | #region IOpenIdMessageExtension Members 21 | 22 | public string TypeUri { 23 | get { return Acme.CustomExtensionTypeUri; } 24 | } 25 | 26 | public IEnumerable AdditionalSupportedTypeUris { 27 | get { return Enumerable.Empty(); } 28 | } 29 | 30 | public bool IsSignedByRemoteParty { get; set; } 31 | 32 | #endregion 33 | 34 | #region IMessage Members 35 | 36 | public Version Version { 37 | get { return Acme.Version; } 38 | } 39 | 40 | public IDictionary ExtraData { 41 | get { return this.extraData; } 42 | } 43 | 44 | public void EnsureValidMessage() { 45 | } 46 | 47 | #endregion 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/DotNetOpenAuth.ApplicationBlock/Facebook/FacebookClient.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Outercurve Foundation. All rights reserved. 4 | // 5 | //----------------------------------------------------------------------- 6 | 7 | namespace DotNetOpenAuth.ApplicationBlock { 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Text; 12 | using System.Web; 13 | using DotNetOpenAuth.Messaging; 14 | using DotNetOpenAuth.OAuth2; 15 | 16 | public class FacebookClient : WebServerClient { 17 | private static readonly AuthorizationServerDescription FacebookDescription = new AuthorizationServerDescription { 18 | TokenEndpoint = new Uri("https://graph.facebook.com/oauth/access_token"), 19 | AuthorizationEndpoint = new Uri("https://graph.facebook.com/oauth/authorize"), 20 | }; 21 | 22 | /// 23 | /// Initializes a new instance of the class. 24 | /// 25 | public FacebookClient() : base(FacebookDescription) { 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/DotNetOpenAuth.ApplicationBlock/Facebook/FacebookGraph.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Outercurve Foundation. All rights reserved. 4 | // 5 | //----------------------------------------------------------------------- 6 | 7 | namespace DotNetOpenAuth.ApplicationBlock.Facebook { 8 | using System; 9 | using System.Collections.Generic; 10 | using System.IO; 11 | using System.Linq; 12 | using System.Runtime.Serialization; 13 | using System.Runtime.Serialization.Json; 14 | using System.Text; 15 | 16 | [DataContract] 17 | public class FacebookGraph { 18 | private static DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(FacebookGraph)); 19 | 20 | [DataMember(Name = "id")] 21 | public long Id { get; set; } 22 | 23 | [DataMember(Name = "name")] 24 | public string Name { get; set; } 25 | 26 | [DataMember(Name = "first_name")] 27 | public string FirstName { get; set; } 28 | 29 | [DataMember(Name = "last_name")] 30 | public string LastName { get; set; } 31 | 32 | [DataMember(Name = "link")] 33 | public Uri Link { get; set; } 34 | 35 | [DataMember(Name = "birthday")] 36 | public string Birthday { get; set; } 37 | 38 | public static FacebookGraph Deserialize(string json) { 39 | if (string.IsNullOrEmpty(json)) { 40 | throw new ArgumentNullException("json"); 41 | } 42 | 43 | return Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(json))); 44 | } 45 | 46 | public static FacebookGraph Deserialize(Stream jsonStream) { 47 | if (jsonStream == null) { 48 | throw new ArgumentNullException("jsonStream"); 49 | } 50 | 51 | return (FacebookGraph)jsonSerializer.ReadObject(jsonStream); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/DotNetOpenAuth.ApplicationBlock/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DotNetOpenAuth.ApplicationBlock")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DotNetOpenAuth.ApplicationBlock")] 13 | [assembly: AssemblyCopyright("Copyright © 2011 Outercurve Foundation")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("6db0c62e-2f06-46fa-acfe-4d737467c8c7")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/DotNetOpenAuth.ApplicationBlock/TokenManager.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Outercurve Foundation. All rights reserved. 4 | // 5 | //----------------------------------------------------------------------- 6 | 7 | namespace DotNetOpenAuth.ApplicationBlock { 8 | using System; 9 | using DotNetOpenAuth.OAuth2; 10 | 11 | public class TokenManager : IClientAuthorizationTracker { 12 | public IAuthorizationState GetAuthorizationState(Uri callbackUrl, string clientState) { 13 | return new AuthorizationState { 14 | Callback = callbackUrl, 15 | }; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Code/HttpHeaderAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthAuthorizationServer.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Mvc; 7 | 8 | /// 9 | /// Represents an attribute that is used to add HTTP Headers to a Controller Action response. 10 | /// 11 | public class HttpHeaderAttribute : ActionFilterAttribute { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The HTTP header name. 16 | /// The HTTP header value. 17 | public HttpHeaderAttribute(string name, string value) { 18 | this.Name = name; 19 | this.Value = value; 20 | } 21 | 22 | /// 23 | /// Gets or sets the name of the HTTP Header. 24 | /// 25 | public string Name { get; set; } 26 | 27 | /// 28 | /// Gets or sets the value of the HTTP Header. 29 | /// 30 | public string Value { get; set; } 31 | 32 | /// 33 | /// Called by the MVC framework after the action result executes. 34 | /// 35 | /// The filter context. 36 | public override void OnResultExecuted(ResultExecutedContext filterContext) { 37 | filterContext.HttpContext.Response.AppendHeader(this.Name, this.Value); 38 | base.OnResultExecuted(filterContext); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Code/Utilities.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthAuthorizationServer.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | internal static class Utilities { 8 | /// 9 | /// Ensures that local times are converted to UTC times. Unspecified kinds are recast to UTC with no conversion. 10 | /// 11 | /// The date-time to convert. 12 | /// The date-time in UTC time. 13 | internal static DateTime AsUtc(this DateTime value) { 14 | if (value.Kind == DateTimeKind.Unspecified) { 15 | return new DateTime(value.Ticks, DateTimeKind.Utc); 16 | } 17 | 18 | return value.ToUniversalTime(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="OAuthAuthorizationServer.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Models/AccountAuthorizeModel.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthAuthorizationServer.Models { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | using DotNetOpenAuth.OAuth2.Messages; 8 | 9 | public class AccountAuthorizeModel { 10 | public string ClientApp { get; set; } 11 | 12 | public HashSet Scope { get; set; } 13 | 14 | public EndUserAuthorizationRequest AuthorizationRequest { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Models/AccountModels.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthAuthorizationServer.Models { 2 | using System.ComponentModel; 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class LogOnModel { 6 | [Required] 7 | [DisplayName("OpenID")] 8 | public string UserSuppliedIdentifier { get; set; } 9 | 10 | [DisplayName("Remember me?")] 11 | public bool RememberMe { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OAuthAuthorizationServer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("OAuthAuthorizationServer")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("be2911ac-b0a2-406e-bffa-acd8484d179e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Views/Account/LogOn.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Log On 5 | 6 | 7 |

8 | Log On

9 | <% using (Html.BeginForm()) { %> 10 | <%: Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.") %> 11 |
12 |
13 | Account Information 14 |
15 | <%: Html.LabelFor(m => m.UserSuppliedIdentifier) %> 16 |
17 |
18 | <%: Html.TextBoxFor(m => m.UserSuppliedIdentifier) %> 19 | <%: Html.ValidationMessageFor(m => m.UserSuppliedIdentifier) %> 20 |
21 |
22 | <%: Html.CheckBoxFor(m => m.RememberMe) %> 23 | <%: Html.LabelFor(m => m.RememberMe) %> 24 |
25 |

26 | 27 |

28 |
29 |
30 | <% } %> 31 |
32 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Views/Home/About.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | About Us 5 | 6 | 7 | 8 |

About

9 |

10 | Put content here. 11 |

12 |
13 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Views/Home/CreateDatabase.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Views/Shared/Site.Master" %> 2 | 3 | 4 | <% if (ViewData["Success"] != null) { 5 | %> 6 |

7 | Database (re)created!

8 |

9 | Note that to be useful, you really need to either modify the database to add an 10 | account with data that will be accessed by this sample, or modify this very page 11 | to inject that data into the database. 12 |

13 | <% 14 | } 15 | %> 16 |

17 | <%= ViewData["Error"] %> 18 |

19 |
20 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Views/Home/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Home Page 5 | 6 | 7 |

8 | DotNetOpenAuth presents the OAuth 2.0 Authorization Server! 9 |

10 |

11 | To learn more about DotNetOpenAuth visit http://www.DotNetOpenAuth.net/. 13 |

14 | <% using (Html.BeginForm("CreateDatabase", "Home")) {%> 15 | 16 | <% 17 | }%> 18 |
19 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Views/Shared/Error.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Error 5 | 6 | 7 | 8 |

9 | Sorry, an error occurred while processing your request. 10 |

11 |
12 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Views/Shared/LogOnUserControl.ascx: -------------------------------------------------------------------------------- 1 | <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> 2 | 23 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Views/Shared/Site.Master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> 2 | 3 | 4 | 5 | 6 | <asp:ContentPlaceHolder ID="TitleContent" runat="server" /> 7 | 8 | 9 | 10 | 11 | 25 |
26 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/OAuth/OAuthAuthorizationServer/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Code/Logging.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthClient { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Web; 7 | 8 | /// 9 | /// Logging tools for this sample. 10 | /// 11 | public static class Logging { 12 | /// 13 | /// An application memory cache of recent log messages. 14 | /// 15 | public static StringBuilder LogMessages = new StringBuilder(); 16 | 17 | /// 18 | /// The logger for this sample to use. 19 | /// 20 | public static log4net.ILog Logger = log4net.LogManager.GetLogger("DotNetOpenAuth.OAuthClient"); 21 | } 22 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Code/TracePageAppender.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthClient { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Web; 6 | 7 | public class TracePageAppender : log4net.Appender.AppenderSkeleton { 8 | protected override void Append(log4net.Core.LoggingEvent loggingEvent) { 9 | StringWriter sw = new StringWriter(Logging.LogMessages); 10 | Layout.Format(sw, loggingEvent); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="DotNetOpenAuth Consumer samples" Language="C#" MasterPageFile="~/MasterPage.master" 2 | AutoEventWireup="true" %> 3 | 4 | 5 |

OAuth allows this web site to access your private data with your authorization, but 6 | without you having to give up your password.

7 |

Select a demo:

8 | 17 |
18 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Facebook.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Inherits="OAuthClient.Facebook" Codebehind="Facebook.aspx.cs" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 | Welcome, 12 | 13 |
14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Facebook.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthClient { 2 | using System; 3 | using System.Configuration; 4 | using System.Net; 5 | using System.Web; 6 | using DotNetOpenAuth.ApplicationBlock; 7 | using DotNetOpenAuth.ApplicationBlock.Facebook; 8 | using DotNetOpenAuth.OAuth2; 9 | 10 | public partial class Facebook : System.Web.UI.Page { 11 | private static readonly FacebookClient client = new FacebookClient { 12 | ClientIdentifier = ConfigurationManager.AppSettings["facebookAppID"], 13 | ClientCredentialApplicator = ClientCredentialApplicator.PostParameter(ConfigurationManager.AppSettings["facebookAppSecret"]), 14 | }; 15 | 16 | protected void Page_Load(object sender, EventArgs e) { 17 | IAuthorizationState authorization = client.ProcessUserAuthorization(); 18 | if (authorization == null) { 19 | // Kick off authorization request 20 | client.RequestUserAuthorization(); 21 | } else { 22 | var request = WebRequest.Create("https://graph.facebook.com/me?access_token=" + Uri.EscapeDataString(authorization.AccessToken)); 23 | using (var response = request.GetResponse()) { 24 | using (var responseStream = response.GetResponseStream()) { 25 | var graph = FacebookGraph.Deserialize(responseStream); 26 | this.nameLabel.Text = HttpUtility.HtmlEncode(graph.Name); 27 | } 28 | } 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Facebook.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthClient { 11 | 12 | 13 | public partial class Facebook { 14 | 15 | /// 16 | /// form1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// nameLabel control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Label nameLabel; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Language="C#" Inherits="OAuthClient.Global" CodeBehind="Global.asax.cs" %> 2 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Global.asax.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthClient { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | public partial class Global : HttpApplication { 8 | protected void Application_Start(object sender, EventArgs e) { 9 | log4net.Config.XmlConfigurator.Configure(); 10 | Logging.Logger.Info("Sample starting..."); 11 | } 12 | 13 | protected void Application_End(object sender, EventArgs e) { 14 | Logging.Logger.Info("Sample shutting down..."); 15 | 16 | // this would be automatic, but in partial trust scenarios it is not. 17 | log4net.LogManager.Shutdown(); 18 | } 19 | 20 | protected void Application_Error(object sender, EventArgs e) { 21 | Logging.Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}", HttpContext.Current.Server.GetLastError()); 22 | } 23 | 24 | protected void Session_Start(object sender, EventArgs e) { 25 | // Code that runs when a new session is started 26 | } 27 | 28 | protected void Session_End(object sender, EventArgs e) { 29 | // Code that runs when a session ends. 30 | // Note: The Session_End event is raised only when the sessionstate mode 31 | // is set to InProc in the Web.config file. If session mode is set to StateServer 32 | // or SQLServer, the event is not raised. 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/GoogleAddressBook.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Gmail address book demo" Language="C#" MasterPageFile="~/MasterPage.master" 2 | AutoEventWireup="true" Inherits="OAuthClient.GoogleAddressBook" Codebehind="GoogleAddressBook.aspx.cs" %> 3 | 4 | 5 | 6 | 7 |

Google setup

8 |

A Google client app must be endorsed by a Google user.

9 |
    10 |
  1. Visit Google 11 | and create a client app.
  2. 12 |
  3. Modify your web.config file to include your consumer key and consumer secret. 13 |
  4. 14 |
15 |
16 | 17 |

Updates

18 |

Ok, Google has authorized us to download your contacts. Click 'Get address book' 19 | to download the first 5 contacts to this sample. Notice how we never asked you 20 | for your Google username or password.

21 | 23 | 24 |
25 |
26 |
27 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/GoogleAddressBook.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthClient { 11 | 12 | 13 | public partial class GoogleAddressBook { 14 | 15 | /// 16 | /// MultiView1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.MultiView MultiView1; 23 | 24 | /// 25 | /// getAddressBookButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button getAddressBookButton; 32 | 33 | /// 34 | /// resultsPlaceholder control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.PlaceHolder resultsPlaceholder; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/GoogleApps2Legged.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master"CodeBehind="GoogleApps2Legged.aspx.cs" Inherits="OAuthConsumer.GoogleApps2Legged" %> 2 | 3 | 4 | 5 | 6 |

Google setup

7 |

A Google client app must be endorsed by a Google user.

8 |
    9 |
  1. Visit Google 10 | and create a client app.
  2. 11 |
  3. Modify your web.config file to include your consumer key and consumer secret. 12 |
  4. 13 |
14 |
15 | 16 |

Updates

17 |

Ok, Google has authorized us to download your contacts. Click 'Get address book' 18 | to download the first 5 contacts to this sample. Notice how we never asked you 19 | for your Google username or password.

20 | 22 | 23 |
24 |
25 |
26 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/GoogleApps2Legged.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthConsumer { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Configuration; 5 | using System.Linq; 6 | using System.Web; 7 | using System.Web.UI; 8 | using System.Web.UI.WebControls; 9 | using DotNetOpenAuth.ApplicationBlock; 10 | using DotNetOpenAuth.Messaging; 11 | using DotNetOpenAuth.OAuth; 12 | using DotNetOpenAuth.OAuth.Messages; 13 | 14 | public partial class GoogleApps2Legged : System.Web.UI.Page { 15 | private InMemoryTokenManager TokenManager { 16 | get { 17 | var tokenManager = (InMemoryTokenManager)Application["GoogleTokenManager"]; 18 | if (tokenManager == null) { 19 | string consumerKey = ConfigurationManager.AppSettings["googleConsumerKey"]; 20 | string consumerSecret = ConfigurationManager.AppSettings["googleConsumerSecret"]; 21 | if (!string.IsNullOrEmpty(consumerKey)) { 22 | tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); 23 | Application["GoogleTokenManager"] = tokenManager; 24 | } 25 | } 26 | 27 | return tokenManager; 28 | } 29 | } 30 | 31 | protected void Page_Load(object sender, EventArgs e) { 32 | var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); 33 | string accessToken = google.RequestNewClientAccount(); 34 | ////string tokenSecret = google.TokenManager.GetTokenSecret(accessToken); 35 | MessageReceivingEndpoint ep = null; // set up your authorized call here. 36 | google.PrepareAuthorizedRequestAndSend(ep, accessToken); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/GoogleApps2Legged.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthConsumer { 11 | 12 | 13 | public partial class GoogleApps2Legged { 14 | 15 | /// 16 | /// MultiView1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.MultiView MultiView1; 23 | 24 | /// 25 | /// getAddressBookButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button getAddressBookButton; 32 | 33 | /// 34 | /// resultsPlaceholder control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.PlaceHolder resultsPlaceholder; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/MasterPage.master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" %> 2 | 3 | 4 | 5 | DotNetOpenAuth OAuth 2.0 Client sample 6 | 7 | 8 | 9 | 10 | 23 |
24 |
25 | 26 | 27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OAuthClient")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("OAuthClient")] 13 | [assembly: AssemblyCopyright("Copyright © 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("12549916-9ec2-4cf6-9fe3-82ea1f6ea665")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Service References/SampleResourceServer/DataApi.disco: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Service References/SampleResourceServer/DataApi.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Service References/SampleResourceServer/DataApi2.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/SignInWithTwitter.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" 2 | Inherits="OAuthClient.SignInWithTwitter" Codebehind="SignInWithTwitter.aspx.cs" %> 3 | 4 | 5 | 6 | 7 | Sign-in with Twitter 8 | 9 | 10 |
11 |
12 | 13 | 14 |

15 | Twitter setup

16 |

17 | A Twitter client app must be endorsed by a Twitter user. 18 |

19 |
    20 |
  1. Visit Twitter and create 21 | a client app.
  2. 22 |
  3. Modify your web.config file to include your consumer key and consumer secret.
  4. 23 |
24 |
25 | 26 | 28 | 29 |
30 | 31 | Now logged in as 32 | 33 | 34 |
35 |
36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/SignInWithTwitter.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthClient { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Configuration; 5 | using System.Linq; 6 | using System.Web; 7 | using System.Web.Security; 8 | using System.Web.UI; 9 | using System.Web.UI.WebControls; 10 | using System.Xml.Linq; 11 | using System.Xml.XPath; 12 | using DotNetOpenAuth.ApplicationBlock; 13 | using DotNetOpenAuth.OAuth; 14 | 15 | public partial class SignInWithTwitter : System.Web.UI.Page { 16 | protected void Page_Load(object sender, EventArgs e) { 17 | if (TwitterConsumer.IsTwitterConsumerConfigured) { 18 | this.MultiView1.ActiveViewIndex = 1; 19 | 20 | if (!IsPostBack) { 21 | string screenName; 22 | int userId; 23 | if (TwitterConsumer.TryFinishSignInWithTwitter(out screenName, out userId)) { 24 | this.loggedInPanel.Visible = true; 25 | this.loggedInName.Text = screenName; 26 | 27 | // In a real app, the Twitter username would likely be used 28 | // to log the user into the application. 29 | ////FormsAuthentication.RedirectFromLoginPage(screenName, false); 30 | } 31 | } 32 | } 33 | } 34 | 35 | protected void signInButton_Click(object sender, ImageClickEventArgs e) { 36 | TwitterConsumer.StartSignInWithTwitter(this.forceLoginCheckbox.Checked).Send(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/TracePage.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Inherits="OAuthClient.TracePage" Codebehind="TracePage.aspx.cs" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | 12 |

13 |
14 | 		
15 | 	
16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/TracePage.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthClient { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | 8 | /// 9 | /// A page to display recent log messages. 10 | /// 11 | public partial class TracePage : System.Web.UI.Page { 12 | protected void Page_Load(object sender, EventArgs e) { 13 | this.placeHolder1.Controls.Add(new Label { Text = HttpUtility.HtmlEncode(Logging.LogMessages.ToString()) }); 14 | } 15 | 16 | protected void clearLogButton_Click(object sender, EventArgs e) { 17 | Logging.LogMessages.Length = 0; 18 | 19 | // clear the page immediately, and allow for F5 without a Postback warning. 20 | Response.Redirect(Request.Url.AbsoluteUri); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/TracePage.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthClient { 11 | 12 | 13 | public partial class TracePage { 14 | 15 | /// 16 | /// form1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// clearLogButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button clearLogButton; 32 | 33 | /// 34 | /// placeHolder1 control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.PlaceHolder placeHolder1; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/Twitter.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="OAuthClient.Twitter" Codebehind="Twitter.aspx.cs" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Twitter setup

9 |

A Twitter client app must be endorsed by a Twitter user.

10 |
    11 |
  1. Visit Twitter and create 12 | a client app.
  2. 13 |
  3. Modify your web.config file to include your consumer key and consumer secret.
  4. 14 |
15 |
16 | 17 |

Updates

18 |

Ok, Twitter has authorized us to download your feeds. Notice how we never asked 19 | you for your Twitter username or password.

20 |

21 | Upload a new profile photo: 22 | 23 |   25 |   27 |

28 |

29 | Click 'Get updates' to download updates to this sample. 30 |

31 | 32 | 33 |
34 |
35 |
36 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/WindowsLive.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WindowsLive.aspx.cs" Inherits="OAuthClient.WindowsLive" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 |

12 | Windows Live requires a public domain (not localhost) that matches the registered 13 | client app's callback URL. You can either host this sample on a public URL and register 14 | your own client, or you can modify your "%windows%\system32\drivers\etc\hosts" file 15 | to temporarily add this entry: 16 |

17 |
127.0.0.1 samples.dotnetopenauth.net
18 |

19 | Then access this sample via this url: 20 | http://samples.dotnetopenauth.net:59722/WindowsLive.aspx

22 |
23 |
24 | Welcome, 25 | 26 |
27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OAuth/OAuthClient/favicon.ico -------------------------------------------------------------------------------- /src/OAuth/OAuthClient/images/Sign-in-with-Twitter-darker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OAuth/OAuthClient/images/Sign-in-with-Twitter-darker.png -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Code/Logging.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthConsumer { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Web; 7 | 8 | /// 9 | /// Logging tools for this sample. 10 | /// 11 | public static class Logging { 12 | /// 13 | /// An application memory cache of recent log messages. 14 | /// 15 | public static StringBuilder LogMessages = new StringBuilder(); 16 | 17 | /// 18 | /// The logger for this sample to use. 19 | /// 20 | public static log4net.ILog Logger = log4net.LogManager.GetLogger("DotNetOpenAuth.OAuthConsumer"); 21 | } 22 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Code/TracePageAppender.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthConsumer { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Web; 6 | 7 | public class TracePageAppender : log4net.Appender.AppenderSkeleton { 8 | protected override void Append(log4net.Core.LoggingEvent loggingEvent) { 9 | StringWriter sw = new StringWriter(Logging.LogMessages); 10 | Layout.Format(sw, loggingEvent); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="DotNetOpenAuth Consumer samples" Language="C#" MasterPageFile="~/MasterPage.master" 2 | AutoEventWireup="true" %> 3 | 4 | 5 |

OAuth allows this web site to access your private data with your authorization, but 6 | without you having to give up your password.

7 |

Select a demo:

8 | 14 |
15 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Language="C#" Inherits="OAuthConsumer.Global" CodeBehind="Global.asax.cs" %> 2 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Global.asax.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthConsumer { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | public partial class Global : HttpApplication { 8 | protected void Application_Start(object sender, EventArgs e) { 9 | log4net.Config.XmlConfigurator.Configure(); 10 | Logging.Logger.Info("Sample starting..."); 11 | } 12 | 13 | protected void Application_End(object sender, EventArgs e) { 14 | Logging.Logger.Info("Sample shutting down..."); 15 | 16 | // this would be automatic, but in partial trust scenarios it is not. 17 | log4net.LogManager.Shutdown(); 18 | } 19 | 20 | protected void Application_Error(object sender, EventArgs e) { 21 | Logging.Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}", HttpContext.Current.Server.GetLastError()); 22 | } 23 | 24 | protected void Session_Start(object sender, EventArgs e) { 25 | // Code that runs when a new session is started 26 | } 27 | 28 | protected void Session_End(object sender, EventArgs e) { 29 | // Code that runs when a session ends. 30 | // Note: The Session_End event is raised only when the sessionstate mode 31 | // is set to InProc in the Web.config file. If session mode is set to StateServer 32 | // or SQLServer, the event is not raised. 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/GoogleAddressBook.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Gmail address book demo" Language="C#" MasterPageFile="~/MasterPage.master" 2 | AutoEventWireup="true" Inherits="OAuthConsumer.GoogleAddressBook" Codebehind="GoogleAddressBook.aspx.cs" %> 3 | 4 | 5 | 6 | 7 |

Google setup

8 |

A Google client app must be endorsed by a Google user.

9 |
    10 |
  1. Visit Google 11 | and create a client app.
  2. 12 |
  3. Modify your web.config file to include your consumer key and consumer secret. 13 |
  4. 14 |
15 |
16 | 17 |

Updates

18 |

Ok, Google has authorized us to download your contacts. Click 'Get address book' 19 | to download the first 5 contacts to this sample. Notice how we never asked you 20 | for your Google username or password.

21 | 23 | 24 |
25 |
26 |
27 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/GoogleAddressBook.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthConsumer { 11 | 12 | 13 | public partial class GoogleAddressBook { 14 | 15 | /// 16 | /// MultiView1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.MultiView MultiView1; 23 | 24 | /// 25 | /// getAddressBookButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button getAddressBookButton; 32 | 33 | /// 34 | /// resultsPlaceholder control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.PlaceHolder resultsPlaceholder; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/GoogleApps2Legged.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master"CodeBehind="GoogleApps2Legged.aspx.cs" Inherits="OAuthConsumer.GoogleApps2Legged" %> 2 | 3 | 4 | 5 | 6 |

Google setup

7 |

A Google client app must be endorsed by a Google user.

8 |
    9 |
  1. Visit Google 10 | and create a client app.
  2. 11 |
  3. Modify your web.config file to include your consumer key and consumer secret. 12 |
  4. 13 |
14 |
15 | 16 |

Updates

17 |

Ok, Google has authorized us to download your contacts. Click 'Get address book' 18 | to download the first 5 contacts to this sample. Notice how we never asked you 19 | for your Google username or password.

20 | 22 | 23 |
24 |
25 |
26 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/GoogleApps2Legged.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthConsumer { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Configuration; 5 | using System.Linq; 6 | using System.Web; 7 | using System.Web.UI; 8 | using System.Web.UI.WebControls; 9 | using DotNetOpenAuth.ApplicationBlock; 10 | using DotNetOpenAuth.Messaging; 11 | using DotNetOpenAuth.OAuth; 12 | using DotNetOpenAuth.OAuth.Messages; 13 | 14 | public partial class GoogleApps2Legged : System.Web.UI.Page { 15 | private InMemoryTokenManager TokenManager { 16 | get { 17 | var tokenManager = (InMemoryTokenManager)Application["GoogleTokenManager"]; 18 | if (tokenManager == null) { 19 | string consumerKey = ConfigurationManager.AppSettings["googleConsumerKey"]; 20 | string consumerSecret = ConfigurationManager.AppSettings["googleConsumerSecret"]; 21 | if (!string.IsNullOrEmpty(consumerKey)) { 22 | tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); 23 | Application["GoogleTokenManager"] = tokenManager; 24 | } 25 | } 26 | 27 | return tokenManager; 28 | } 29 | } 30 | 31 | protected void Page_Load(object sender, EventArgs e) { 32 | var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); 33 | string accessToken = google.RequestNewClientAccount(); 34 | ////string tokenSecret = google.TokenManager.GetTokenSecret(accessToken); 35 | MessageReceivingEndpoint ep = null; // set up your authorized call here. 36 | google.PrepareAuthorizedRequestAndSend(ep, accessToken); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/GoogleApps2Legged.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthConsumer { 11 | 12 | 13 | public partial class GoogleApps2Legged { 14 | 15 | /// 16 | /// MultiView1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.MultiView MultiView1; 23 | 24 | /// 25 | /// getAddressBookButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button getAddressBookButton; 32 | 33 | /// 34 | /// resultsPlaceholder control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.PlaceHolder resultsPlaceholder; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/MasterPage.master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" %> 2 | 3 | 4 | 5 | 6 | 7 | DotNetOpenAuth Consumer sample 8 | 9 | 10 | 11 | 12 | 25 |
26 |
27 | 28 | 29 |
30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OAuthConsumer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("OAuthConsumer")] 13 | [assembly: AssemblyCopyright("Copyright © 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("12549916-9ec2-4cf6-9fe3-82ea1f6ea665")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/SampleWcf.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="OAuthConsumer.SampleWcf" Codebehind="SampleWcf.aspx.cs" %> 2 | 3 | 4 |
5 | 6 | GetName 7 | GetAge 8 | GetFavoriteSites 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 |
17 | 18 | 19 |
20 | 22 | 23 |
24 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Service References/SampleServiceProvider/DataApi.disco: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Service References/SampleServiceProvider/DataApi.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Service References/SampleServiceProvider/DataApi2.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/SignInWithTwitter.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" 2 | Inherits="OAuthConsumer.SignInWithTwitter" Codebehind="SignInWithTwitter.aspx.cs" %> 3 | 4 | 5 | 6 | 7 | Sign-in with Twitter 8 | 9 | 10 |
11 |
12 | 13 | 14 |

15 | Twitter setup

16 |

17 | A Twitter client app must be endorsed by a Twitter user. 18 |

19 |
    20 |
  1. Visit Twitter and create 21 | a client app.
  2. 22 |
  3. Modify your web.config file to include your consumer key and consumer secret.
  4. 23 |
24 |
25 | 26 | 28 | 29 |
30 | 31 | Now logged in as 32 | 33 | 34 |
35 |
36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/SignInWithTwitter.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthConsumer { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Configuration; 5 | using System.Linq; 6 | using System.Web; 7 | using System.Web.Security; 8 | using System.Web.UI; 9 | using System.Web.UI.WebControls; 10 | using System.Xml.Linq; 11 | using System.Xml.XPath; 12 | using DotNetOpenAuth.ApplicationBlock; 13 | using DotNetOpenAuth.OAuth; 14 | 15 | public partial class SignInWithTwitter : System.Web.UI.Page { 16 | protected void Page_Load(object sender, EventArgs e) { 17 | if (TwitterConsumer.IsTwitterConsumerConfigured) { 18 | this.MultiView1.ActiveViewIndex = 1; 19 | 20 | if (!IsPostBack) { 21 | string screenName; 22 | int userId; 23 | if (TwitterConsumer.TryFinishSignInWithTwitter(out screenName, out userId)) { 24 | this.loggedInPanel.Visible = true; 25 | this.loggedInName.Text = screenName; 26 | 27 | // In a real app, the Twitter username would likely be used 28 | // to log the user into the application. 29 | ////FormsAuthentication.RedirectFromLoginPage(screenName, false); 30 | } 31 | } 32 | } 33 | } 34 | 35 | protected void signInButton_Click(object sender, ImageClickEventArgs e) { 36 | TwitterConsumer.StartSignInWithTwitter(this.forceLoginCheckbox.Checked).Send(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/TracePage.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Inherits="OAuthConsumer.TracePage" Codebehind="TracePage.aspx.cs" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | 12 |

13 |
14 | 		
15 | 	
16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/TracePage.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthConsumer { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | 8 | /// 9 | /// A page to display recent log messages. 10 | /// 11 | public partial class TracePage : System.Web.UI.Page { 12 | protected void Page_Load(object sender, EventArgs e) { 13 | this.placeHolder1.Controls.Add(new Label { Text = HttpUtility.HtmlEncode(Logging.LogMessages.ToString()) }); 14 | } 15 | 16 | protected void clearLogButton_Click(object sender, EventArgs e) { 17 | Logging.LogMessages.Length = 0; 18 | 19 | // clear the page immediately, and allow for F5 without a Postback warning. 20 | Response.Redirect(Request.Url.AbsoluteUri); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/TracePage.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthConsumer { 11 | 12 | 13 | public partial class TracePage { 14 | 15 | /// 16 | /// form1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// clearLogButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button clearLogButton; 32 | 33 | /// 34 | /// placeHolder1 control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.PlaceHolder placeHolder1; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/Twitter.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="OAuthConsumer.Twitter" Codebehind="Twitter.aspx.cs" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Twitter setup

9 |

A Twitter client app must be endorsed by a Twitter user.

10 |
    11 |
  1. Visit Twitter and create 12 | a client app.
  2. 13 |
  3. Modify your web.config file to include your consumer key and consumer secret.
  4. 14 |
15 |
16 | 17 |

Updates

18 |

Ok, Twitter has authorized us to download your feeds. Notice how we never asked 19 | you for your Twitter username or password.

20 |

21 | Upload a new profile photo: 22 | 23 |   25 |   27 |

28 |

29 | Click 'Get updates' to download updates to this sample. 30 |

31 | 32 | 33 |
34 |
35 |
36 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OAuth/OAuthConsumer/favicon.ico -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/images/Sign-in-with-Twitter-darker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OAuth/OAuthConsumer/images/Sign-in-with-Twitter-darker.png -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumer/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthConsumerWpf { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Configuration; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Windows; 8 | 9 | /// 10 | /// Interaction logic for App.xaml 11 | /// 12 | public partial class App : Application { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/Authorize.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | Complete authorization at your service provider, 7 | then enter the verification code below and click Finish: 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/Authorize2.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/Authorize2.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DotNetOpenAuth.Samples.OAuthConsumerWpf { 2 | using System.Windows; 3 | 4 | using DotNetOpenAuth.OAuth2; 5 | 6 | /// 7 | /// Interaction logic for Authorize2.xaml 8 | /// 9 | public partial class Authorize2 : Window { 10 | internal Authorize2(UserAgentClient client) { 11 | this.InitializeComponent(); 12 | this.clientAuthorizationView.Client = client; 13 | } 14 | 15 | public IAuthorizationState Authorization { 16 | get { return this.clientAuthorizationView.Authorization; } 17 | } 18 | 19 | private void clientAuthorizationView_Completed(object sender, ClientAuthorizationCompleteEventArgs e) { 20 | this.DialogResult = e.Authorization != null; 21 | this.Close(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DotNetOpenAuth.Samples.OAuthConsumerWpf.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/Service References/WcfSampleService/DataApi.disco: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/Service References/WcfSampleService/DataApi.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/Service References/WcfSampleService/DataApi1.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OAuth/OAuthConsumerWpf/favicon.ico -------------------------------------------------------------------------------- /src/OAuth/OAuthConsumerWpf/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Code/IDataApi.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthResourceServer.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.Serialization; 6 | using System.ServiceModel; 7 | using System.ServiceModel.Web; 8 | using System.Text; 9 | 10 | [ServiceContract] 11 | public interface IDataApi { 12 | [OperationContract, WebGet(UriTemplate = "/age", ResponseFormat = WebMessageFormat.Json)] 13 | int? GetAge(); 14 | 15 | [OperationContract, WebGet(UriTemplate = "/name", ResponseFormat = WebMessageFormat.Json)] 16 | string GetName(); 17 | 18 | [OperationContract, WebGet(UriTemplate = "/favoritesites", ResponseFormat = WebMessageFormat.Json)] 19 | string[] GetFavoriteSites(); 20 | } 21 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Code/OAuthPrincipalAuthorizationPolicy.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthResourceServer.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IdentityModel.Claims; 5 | using System.IdentityModel.Policy; 6 | using System.Linq; 7 | using System.Security.Principal; 8 | using System.Web; 9 | 10 | public class OAuthPrincipalAuthorizationPolicy : IAuthorizationPolicy { 11 | private readonly Guid uniqueId = Guid.NewGuid(); 12 | private readonly IPrincipal principal; 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The principal. 18 | public OAuthPrincipalAuthorizationPolicy(IPrincipal principal) { 19 | this.principal = principal; 20 | } 21 | 22 | #region IAuthorizationComponent Members 23 | 24 | /// 25 | /// Gets a unique ID for this instance. 26 | /// 27 | public string Id { 28 | get { return this.uniqueId.ToString(); } 29 | } 30 | 31 | #endregion 32 | 33 | #region IAuthorizationPolicy Members 34 | 35 | public ClaimSet Issuer { 36 | get { return ClaimSet.System; } 37 | } 38 | 39 | public bool Evaluate(EvaluationContext evaluationContext, ref object state) { 40 | evaluationContext.AddClaimSet(this, new DefaultClaimSet(Claim.CreateNameClaim(this.principal.Identity.Name))); 41 | evaluationContext.Properties["Principal"] = this.principal; 42 | return true; 43 | } 44 | 45 | #endregion 46 | } 47 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Code/TracePageAppender.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthResourceServer.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Web; 6 | 7 | public class TracePageAppender : log4net.Appender.AppenderSkeleton { 8 | protected override void Append(log4net.Core.LoggingEvent loggingEvent) { 9 | StringWriter sw = new StringWriter(Global.LogMessages); 10 | Layout.Format(sw, loggingEvent); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/DataApi.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthResourceServer { 2 | using System.Linq; 3 | using System.Security.Principal; 4 | using System.ServiceModel; 5 | 6 | using Code; 7 | 8 | /// 9 | /// The WCF service API. 10 | /// 11 | /// 12 | /// Note how there is no code here that is bound to OAuth or any other 13 | /// credential/authorization scheme. That's all part of the channel/binding elsewhere. 14 | /// And the reference to OperationContext.Current.ServiceSecurityContext.PrimaryIdentity 15 | /// is the user being impersonated by the WCF client. 16 | /// In the OAuth case, it is the user who authorized the OAuth access token that was used 17 | /// to gain access to the service. 18 | /// 19 | public class DataApi : IDataApi { 20 | private IIdentity User { 21 | get { return OperationContext.Current.ServiceSecurityContext.PrimaryIdentity; } 22 | } 23 | 24 | public int? GetAge() { 25 | // We'll just make up an age personalized to the user by counting the length of the username. 26 | return this.User.Name.Length; 27 | } 28 | 29 | public string GetName() { 30 | return this.User.Name; 31 | } 32 | 33 | public string[] GetFavoriteSites() { 34 | // Just return a hard-coded list, to avoid having to have a database in a sample. 35 | return new string[] { 36 | "http://www.dotnetopenauth.net/", 37 | "http://www.oauth.net/", 38 | "http://www.openid.net/", 39 | }; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/DataApi.svc: -------------------------------------------------------------------------------- 1 | <%@ ServiceHost Language="C#" Debug="true" Service="OAuthResourceServer.DataApi" CodeBehind="DataApi.cs" %> 2 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Default.aspx: -------------------------------------------------------------------------------- 1 |  <%@ Page Title="DotNetOpenAuth Service Provider Sample" Language="C#" MasterPageFile="~/MasterPage.master" CodeBehind="~/Default.aspx.cs" Inherits="OAuthResourceServer._Default" AutoEventWireup="True" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthResourceServer { 2 | using System; 3 | using System.Configuration; 4 | using System.IO; 5 | 6 | using Code; 7 | 8 | public partial class _Default : System.Web.UI.Page { 9 | } 10 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthResourceServer { 11 | 12 | 13 | public partial class _Default { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Inherits="OAuthResourceServer.Code.Global" CodeBehind="Code\Global.cs" %> 2 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Login.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Login" Language="C#" MasterPageFile="~/MasterPage.master" %> 2 | 3 | <%@ Register Assembly="DotNetOpenAuth.OpenId.RelyingParty.UI" Namespace="DotNetOpenAuth.OpenId.RelyingParty" TagPrefix="rp" %> 4 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/MasterPage.master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" %> 2 | 3 | 4 | 5 | 6 | DotNetOpenAuth OAuth 2.0 Resource Server sample 7 | 8 | 9 | 10 | 11 | 24 |
25 | 26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Members/Logoff.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Log off" Language="C#" MasterPageFile="~/MasterPage.master" %> 2 | 3 | 9 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Members/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OAuthResourceServer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("OAuthResourceServer")] 13 | [assembly: AssemblyCopyright("Copyright © 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("B6206451-6557-4568-8D25-84AF93EC8B7B")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/TracePage.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Inherits="OAuthResourceServer.TracePage" Codebehind="TracePage.aspx.cs" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | 12 |

13 |
14 | 		
15 | 	
16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/TracePage.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthResourceServer { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | using Code; 8 | 9 | /// 10 | /// A page to display recent log messages. 11 | /// 12 | public partial class TracePage : System.Web.UI.Page { 13 | protected void Page_Load(object sender, EventArgs e) { 14 | this.placeHolder1.Controls.Add(new Label { Text = HttpUtility.HtmlEncode(Global.LogMessages.ToString()) }); 15 | } 16 | 17 | protected void clearLogButton_Click(object sender, EventArgs e) { 18 | Global.LogMessages.Length = 0; 19 | 20 | // clear the page immediately, and allow for F5 without a Postback warning. 21 | Response.Redirect(Request.Url.AbsoluteUri); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/TracePage.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthResourceServer { 11 | 12 | 13 | public partial class TracePage { 14 | 15 | /// 16 | /// form1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// clearLogButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button clearLogButton; 32 | 33 | /// 34 | /// placeHolder1 control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.PlaceHolder placeHolder1; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OAuth/OAuthResourceServer/favicon.ico -------------------------------------------------------------------------------- /src/OAuth/OAuthResourceServer/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Code/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider.Code { 2 | using System; 3 | using DotNetOpenAuth.Messaging; 4 | using DotNetOpenAuth.OAuth; 5 | using DotNetOpenAuth.OAuth.ChannelElements; 6 | 7 | /// 8 | /// Service Provider definitions. 9 | /// 10 | public static class Constants { 11 | public static Uri WebRootUrl { get; set; } 12 | 13 | public static ServiceProviderDescription SelfDescription { 14 | get { 15 | ServiceProviderDescription description = new ServiceProviderDescription { 16 | AccessTokenEndpoint = new MessageReceivingEndpoint(new Uri(WebRootUrl, "/OAuth.ashx"), HttpDeliveryMethods.PostRequest), 17 | RequestTokenEndpoint = new MessageReceivingEndpoint(new Uri(WebRootUrl, "/OAuth.ashx"), HttpDeliveryMethods.PostRequest), 18 | UserAuthorizationEndpoint = new MessageReceivingEndpoint(new Uri(WebRootUrl, "/OAuth.ashx"), HttpDeliveryMethods.PostRequest), 19 | TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { 20 | new HmacSha1SigningBindingElement(), 21 | }, 22 | }; 23 | 24 | return description; 25 | } 26 | } 27 | 28 | public static ServiceProvider CreateServiceProvider() { 29 | return new ServiceProvider(SelfDescription, Global.TokenManager, Global.NonceStore); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Code/CustomOAuthTypeProvider.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using DotNetOpenAuth.Messaging; 7 | using DotNetOpenAuth.OAuth.ChannelElements; 8 | using DotNetOpenAuth.OAuth.Messages; 9 | 10 | /// 11 | /// A custom class that will cause the OAuth library to use our custom message types 12 | /// where we have them. 13 | /// 14 | public class CustomOAuthMessageFactory : OAuthServiceProviderMessageFactory { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The token manager instance to use. 19 | public CustomOAuthMessageFactory(IServiceProviderTokenManager tokenManager) 20 | : base(tokenManager) { 21 | } 22 | 23 | public override IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary fields) { 24 | var message = base.GetNewRequestMessage(recipient, fields); 25 | 26 | // inject our own type here to replace the standard one 27 | if (message is UnauthorizedTokenRequest) { 28 | message = new RequestScopedTokenMessage(recipient, message.Version); 29 | } 30 | 31 | return message; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Code/IDataApi.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.Serialization; 6 | using System.ServiceModel; 7 | using System.Text; 8 | 9 | [ServiceContract] 10 | public interface IDataApi { 11 | [OperationContract] 12 | int? GetAge(); 13 | 14 | [OperationContract] 15 | string GetName(); 16 | 17 | [OperationContract] 18 | string[] GetFavoriteSites(); 19 | } 20 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Code/OAuthConsumer.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Outercurve Foundation. All rights reserved. 4 | // 5 | //----------------------------------------------------------------------- 6 | 7 | namespace OAuthServiceProvider.Code { 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Web; 12 | using DotNetOpenAuth.OAuth.ChannelElements; 13 | 14 | public partial class OAuthConsumer : IConsumerDescription { 15 | #region IConsumerDescription Members 16 | 17 | string IConsumerDescription.Key { 18 | get { return this.ConsumerKey; } 19 | } 20 | 21 | string IConsumerDescription.Secret { 22 | get { return this.ConsumerSecret; } 23 | } 24 | 25 | System.Security.Cryptography.X509Certificates.X509Certificate2 IConsumerDescription.Certificate { 26 | get { return null; } 27 | } 28 | 29 | Uri IConsumerDescription.Callback { 30 | get { return string.IsNullOrEmpty(this.Callback) ? null : new Uri(this.Callback); } 31 | } 32 | 33 | DotNetOpenAuth.OAuth.VerificationCodeFormat IConsumerDescription.VerificationCodeFormat { 34 | get { return this.VerificationCodeFormat; } 35 | } 36 | 37 | int IConsumerDescription.VerificationCodeLength { 38 | get { return this.VerificationCodeLength; } 39 | } 40 | 41 | #endregion 42 | } 43 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Code/OAuthPrincipalAuthorizationPolicy.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IdentityModel.Claims; 5 | using System.IdentityModel.Policy; 6 | using System.Linq; 7 | using System.Web; 8 | using DotNetOpenAuth.OAuth.ChannelElements; 9 | 10 | public class OAuthPrincipalAuthorizationPolicy : IAuthorizationPolicy { 11 | private readonly Guid uniqueId = Guid.NewGuid(); 12 | private readonly OAuthPrincipal principal; 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The principal. 18 | public OAuthPrincipalAuthorizationPolicy(OAuthPrincipal principal) { 19 | this.principal = principal; 20 | } 21 | 22 | #region IAuthorizationComponent Members 23 | 24 | /// 25 | /// Gets a unique ID for this instance. 26 | /// 27 | public string Id { 28 | get { return this.uniqueId.ToString(); } 29 | } 30 | 31 | #endregion 32 | 33 | #region IAuthorizationPolicy Members 34 | 35 | public ClaimSet Issuer { 36 | get { return ClaimSet.System; } 37 | } 38 | 39 | public bool Evaluate(EvaluationContext evaluationContext, ref object state) { 40 | evaluationContext.AddClaimSet(this, new DefaultClaimSet(Claim.CreateNameClaim(this.principal.Identity.Name))); 41 | evaluationContext.Properties["Principal"] = this.principal; 42 | return true; 43 | } 44 | 45 | #endregion 46 | } 47 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Code/RequestScopedTokenMessage.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider.Code { 2 | using System; 3 | using DotNetOpenAuth.Messaging; 4 | using DotNetOpenAuth.OAuth.Messages; 5 | 6 | /// 7 | /// A custom web app version of the message sent to request an unauthorized token. 8 | /// 9 | public class RequestScopedTokenMessage : UnauthorizedTokenRequest { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The endpoint that will receive the message. 14 | /// The OAuth version. 15 | public RequestScopedTokenMessage(MessageReceivingEndpoint endpoint, Version version) 16 | : base(endpoint, version) { 17 | } 18 | 19 | /// 20 | /// Gets or sets the scope of the access being requested. 21 | /// 22 | [MessagePart("scope", IsRequired = true)] 23 | public string Scope { get; set; } 24 | } 25 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Code/TokenAuthorizationState.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | /// 8 | /// Various states an OAuth token can be in. 9 | /// 10 | public enum TokenAuthorizationState : int { 11 | /// 12 | /// An unauthorized request token. 13 | /// 14 | UnauthorizedRequestToken = 0, 15 | 16 | /// 17 | /// An authorized request token. 18 | /// 19 | AuthorizedRequestToken = 1, 20 | 21 | /// 22 | /// An authorized access token. 23 | /// 24 | AccessToken = 2, 25 | } 26 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Code/TracePageAppender.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Web; 6 | 7 | public class TracePageAppender : log4net.Appender.AppenderSkeleton { 8 | protected override void Append(log4net.Core.LoggingEvent loggingEvent) { 9 | StringWriter sw = new StringWriter(Global.LogMessages); 10 | Layout.Format(sw, loggingEvent); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Code/Utilities.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Security.Principal; 6 | using System.Web; 7 | 8 | /// 9 | /// Extension methods and other helpful utility methods. 10 | /// 11 | public static class Utilities { 12 | /// 13 | /// Gets the database entity representing the user identified by a given instance. 14 | /// 15 | /// The identity of the user. 16 | /// 17 | /// The database object for that user; or null if the user could not 18 | /// be found or if is null or represents an anonymous identity. 19 | /// 20 | public static User GetUser(this IIdentity identity) { 21 | if (identity == null || !identity.IsAuthenticated) { 22 | return null; 23 | } 24 | 25 | return Global.DataContext.Users.SingleOrDefault(user => user.OpenIDClaimedIdentifier == identity.Name); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/DataApi.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider { 2 | using System.Linq; 3 | using System.ServiceModel; 4 | using OAuthServiceProvider.Code; 5 | 6 | /// 7 | /// The WCF service API. 8 | /// 9 | /// 10 | /// Note how there is no code here that is bound to OAuth or any other 11 | /// credential/authorization scheme. That's all part of the channel/binding elsewhere. 12 | /// And the reference to OperationContext.Current.ServiceSecurityContext.PrimaryIdentity 13 | /// is the user being impersonated by the WCF client. 14 | /// In the OAuth case, it is the user who authorized the OAuth access token that was used 15 | /// to gain access to the service. 16 | /// 17 | public class DataApi : IDataApi { 18 | private User User { 19 | get { return OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.GetUser(); } 20 | } 21 | 22 | public int? GetAge() { 23 | return User.Age; 24 | } 25 | 26 | public string GetName() { 27 | return User.FullName; 28 | } 29 | 30 | public string[] GetFavoriteSites() { 31 | return User.FavoriteSites.Select(site => site.SiteUrl).ToArray(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/DataApi.svc: -------------------------------------------------------------------------------- 1 | <%@ ServiceHost Language="C#" Debug="true" Service="OAuthServiceProvider.DataApi" CodeBehind="DataApi.cs" %> 2 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="DotNetOpenAuth Service Provider Sample" Language="C#" MasterPageFile="~/MasterPage.master" CodeBehind="~/Default.aspx.cs" Inherits="OAuthServiceProvider._Default" AutoEventWireup="True" %> 2 | 3 | <%@ Import Namespace="System.IO" %> 4 | <%@ Import Namespace="System.Data.SqlClient" %> 5 | 6 | 7 | 8 | 10 |

Note that to be useful, you really need to either modify the database to add an 11 | account with data that will be accessed by this sample, or modify this very page 12 | to inject that data into the database.

13 |
14 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Configuration; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Web; 8 | using OAuthServiceProvider.Code; 9 | 10 | public partial class _Default : System.Web.UI.Page { 11 | protected void createDatabaseButton_Click(object sender, EventArgs e) { 12 | string databasePath = Path.Combine(Server.MapPath(Request.ApplicationPath), "App_Data"); 13 | if (!Directory.Exists(databasePath)) { 14 | Directory.CreateDirectory(databasePath); 15 | } 16 | string connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString.Replace("|DataDirectory|", databasePath); 17 | var dc = new DataClassesDataContext(connectionString); 18 | if (dc.DatabaseExists()) { 19 | dc.DeleteDatabase(); 20 | } 21 | try { 22 | dc.CreateDatabase(); 23 | 24 | // Fill with sample data. 25 | dc.OAuthConsumers.InsertOnSubmit(new OAuthConsumer { 26 | ConsumerKey = "sampleconsumer", 27 | ConsumerSecret = "samplesecret", 28 | }); 29 | dc.Users.InsertOnSubmit(new User { 30 | OpenIDFriendlyIdentifier = "=arnott", 31 | OpenIDClaimedIdentifier = "=!9B72.7DD1.50A9.5CCD", 32 | Age = 27, 33 | FullName = "Andrew Arnott", 34 | FavoriteSites = new System.Data.Linq.EntitySet { 35 | new FavoriteSite { SiteUrl = "http://www.microsoft.com" }, 36 | new FavoriteSite { SiteUrl = "http://www.google.com" }, 37 | }, 38 | }); 39 | 40 | dc.SubmitChanges(); 41 | this.databaseStatus.Visible = true; 42 | } catch (System.Data.SqlClient.SqlException ex) { 43 | foreach (System.Data.SqlClient.SqlError error in ex.Errors) { 44 | Response.Write(error.Message); 45 | } 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthServiceProvider { 11 | 12 | 13 | public partial class _Default { 14 | 15 | /// 16 | /// createDatabaseButton control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.Button createDatabaseButton; 23 | 24 | /// 25 | /// databaseStatus control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Label databaseStatus; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Inherits="OAuthServiceProvider.Code.Global" CodeBehind="Code\Global.cs" %> -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Login.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Login" Language="C#" MasterPageFile="~/MasterPage.master" %> 2 | 3 | <%@ Register Assembly="DotNetOpenAuth.OpenId.RelyingParty.UI" Namespace="DotNetOpenAuth.OpenId.RelyingParty" TagPrefix="rp" %> 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/MasterPage.master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" %> 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | DotNetOpenAuth Service Provider sample 12 | 13 | 14 | 15 |
16 |

DotNetOpenAuth Service Provider sample

17 |
18 | 19 | 20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Members/AuthorizedConsumers.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="OAuthServiceProvider.AuthorizedConsumers" Codebehind="AuthorizedConsumers.aspx.cs" %> 2 | 3 | 4 |

The following consumers have access to your data

5 |

TODO

6 |
7 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.UI; 7 | using System.Web.UI.WebControls; 8 | 9 | /// 10 | /// Lists the consumers that have active request or access tokens 11 | /// and provides a mechanism for the user to revoke permissions. 12 | /// 13 | public partial class AuthorizedConsumers : System.Web.UI.Page { 14 | protected void Page_Load(object sender, EventArgs e) { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthServiceProvider { 11 | 12 | 13 | public partial class AuthorizedConsumers { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Members/Logoff.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Log off" Language="C#" MasterPageFile="~/MasterPage.master" %> 2 | 3 | 9 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Members/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/OAuth.ashx: -------------------------------------------------------------------------------- 1 | <%@ WebHandler Language="C#" Class="OAuth" %> 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.SessionState; 7 | using DotNetOpenAuth.OAuth; 8 | using DotNetOpenAuth.OAuth.ChannelElements; 9 | using DotNetOpenAuth.OAuth.Messages; 10 | using DotNetOpenAuth.Messaging; 11 | using OAuthServiceProvider.Code; 12 | 13 | public class OAuth : IHttpHandler, IRequiresSessionState { 14 | ServiceProvider sp; 15 | 16 | public OAuth() { 17 | sp = new ServiceProvider(Constants.SelfDescription, Global.TokenManager, new CustomOAuthMessageFactory(Global.TokenManager)); 18 | } 19 | 20 | public void ProcessRequest(HttpContext context) { 21 | IProtocolMessage request = sp.ReadRequest(); 22 | RequestScopedTokenMessage requestToken; 23 | UserAuthorizationRequest requestAuth; 24 | AuthorizedTokenRequest requestAccessToken; 25 | if ((requestToken = request as RequestScopedTokenMessage) != null) { 26 | var response = sp.PrepareUnauthorizedTokenMessage(requestToken); 27 | sp.Channel.Send(response); 28 | } else if ((requestAuth = request as UserAuthorizationRequest) != null) { 29 | Global.PendingOAuthAuthorization = requestAuth; 30 | HttpContext.Current.Response.Redirect("~/Members/Authorize.aspx"); 31 | } else if ((requestAccessToken = request as AuthorizedTokenRequest) != null) { 32 | var response = sp.PrepareAccessTokenMessage(requestAccessToken); 33 | sp.Channel.Send(response); 34 | } else { 35 | throw new InvalidOperationException(); 36 | } 37 | } 38 | 39 | public bool IsReusable { 40 | get { return true; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OAuthServiceProvider")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("OAuthServiceProvider")] 13 | [assembly: AssemblyCopyright("Copyright © 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("B6206451-6557-4568-8D25-84AF93EC8B7B")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/TracePage.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Inherits="OAuthServiceProvider.TracePage" Codebehind="TracePage.aspx.cs" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | 12 |

13 |
14 | 		
15 | 	
16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/TracePage.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OAuthServiceProvider { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | using OAuthServiceProvider.Code; 8 | 9 | /// 10 | /// A page to display recent log messages. 11 | /// 12 | public partial class TracePage : System.Web.UI.Page { 13 | protected void Page_Load(object sender, EventArgs e) { 14 | this.placeHolder1.Controls.Add(new Label { Text = HttpUtility.HtmlEncode(Global.LogMessages.ToString()) }); 15 | } 16 | 17 | protected void clearLogButton_Click(object sender, EventArgs e) { 18 | Global.LogMessages.Length = 0; 19 | 20 | // clear the page immediately, and allow for F5 without a Postback warning. 21 | Response.Redirect(Request.Url.AbsoluteUri); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/TracePage.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OAuthServiceProvider { 11 | 12 | 13 | public partial class TracePage { 14 | 15 | /// 16 | /// form1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// clearLogButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button clearLogButton; 32 | 33 | /// 34 | /// placeHolder1 control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.PlaceHolder placeHolder1; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OAuth/OAuthServiceProvider/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OAuth/OAuthServiceProvider/favicon.ico -------------------------------------------------------------------------------- /src/OpenID/OpenIdOfflineProvider/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdOfflineProvider/App.xaml.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Outercurve Foundation. All rights reserved. 4 | // 5 | //----------------------------------------------------------------------- 6 | 7 | namespace DotNetOpenAuth.OpenIdOfflineProvider { 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Configuration; 11 | using System.Data; 12 | using System.Linq; 13 | using System.Windows; 14 | using log4net; 15 | using log4net.Core; 16 | 17 | /// 18 | /// Interaction logic for App.xaml 19 | /// 20 | public partial class App : Application { 21 | /// 22 | /// Message logger. 23 | /// 24 | internal static ILog Logger = log4net.LogManager.GetLogger(typeof(App)); 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | public App() { 30 | log4net.Config.XmlConfigurator.Configure(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdOfflineProvider/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DotNetOpenAuth.OpenIdOfflineProvider.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdOfflineProvider/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdOfflineProvider/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | True 8 | 9 | 10 | 11 | 12 | True 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdOfflineProvider/openid.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdOfflineProvider/openid.ico -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/App_Data/Users.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | bob 5 | test 6 | CDI= 7 | 8 | 9 | bob1 10 | test 11 | CAI= 12 | 13 | 14 | bob2 15 | test 16 | hYMC 17 | 18 | 19 | bob3 20 | test 21 | hTKDAg== 22 | 23 | 24 | bob4 25 | test 26 | hTkDAg== 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Code/AccountMembershipService.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdProviderMvc.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Security; 7 | 8 | public class AccountMembershipService : IMembershipService { 9 | private MembershipProvider provider; 10 | 11 | public AccountMembershipService() 12 | : this(null) { 13 | } 14 | 15 | public AccountMembershipService(MembershipProvider provider) { 16 | this.provider = provider ?? Membership.Provider; 17 | } 18 | 19 | public int MinPasswordLength { 20 | get { 21 | return this.provider.MinRequiredPasswordLength; 22 | } 23 | } 24 | 25 | public bool ValidateUser(string userName, string password) { 26 | return this.provider.ValidateUser(userName, password); 27 | } 28 | 29 | public MembershipCreateStatus CreateUser(string userName, string password, string email) { 30 | MembershipCreateStatus status; 31 | this.provider.CreateUser(userName, password, email, null, null, true, null, out status); 32 | return status; 33 | } 34 | 35 | public bool ChangePassword(string userName, string oldPassword, string newPassword) { 36 | MembershipUser currentUser = this.provider.GetUser(userName, true /* userIsOnline */); 37 | return currentUser.ChangePassword(oldPassword, newPassword); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Code/FormsAuthenticationService.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdProviderMvc.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Security; 7 | 8 | public class FormsAuthenticationService : IFormsAuthentication { 9 | public string SignedInUsername { 10 | get { return HttpContext.Current.User.Identity.Name; } 11 | } 12 | 13 | public DateTime? SignedInTimestampUtc { 14 | get { 15 | var cookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; 16 | if (cookie != null) { 17 | var ticket = FormsAuthentication.Decrypt(cookie.Value); 18 | return ticket.IssueDate.ToUniversalTime(); 19 | } else { 20 | return null; 21 | } 22 | } 23 | } 24 | 25 | public void SignIn(string userName, bool createPersistentCookie) { 26 | FormsAuthentication.SetAuthCookie(userName, createPersistentCookie); 27 | } 28 | 29 | public void SignOut() { 30 | FormsAuthentication.SignOut(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Code/IFormsAuthentication.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdProviderMvc.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Security; 7 | 8 | /// 9 | /// An interface that wraps the type. 10 | /// 11 | /// 12 | /// The FormsAuthentication type is sealed and contains static members, so it is difficult to 13 | /// unit test code that calls its members. The interface and helper class below demonstrate 14 | /// how to create an abstract wrapper around such a type in order to make the AccountController 15 | /// code unit testable. 16 | /// 17 | public interface IFormsAuthentication { 18 | string SignedInUsername { get; } 19 | 20 | DateTime? SignedInTimestampUtc { get; } 21 | 22 | void SignIn(string userName, bool createPersistentCookie); 23 | 24 | void SignOut(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Code/IMembershipService.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdProviderMvc.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Security; 7 | 8 | public interface IMembershipService { 9 | /// 10 | /// Gets the length of the min password. 11 | /// 12 | int MinPasswordLength { get; } 13 | 14 | /// 15 | /// Validates the user. 16 | /// 17 | /// Name of the user. 18 | /// The password. 19 | /// Whether the given username and password is correct. 20 | bool ValidateUser(string userName, string password); 21 | 22 | /// 23 | /// Creates a new user account. 24 | /// 25 | /// Name of the user. 26 | /// The password. 27 | /// The email. 28 | /// The success or reason for failure of account creation. 29 | MembershipCreateStatus CreateUser(string userName, string password, string email); 30 | 31 | /// 32 | /// Changes the password for a user. 33 | /// 34 | /// Name of the user. 35 | /// The old password. 36 | /// The new password. 37 | /// A value indicating whether the password change was successful. 38 | bool ChangePassword(string userName, string oldPassword, string newPassword); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Code/Util.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdProviderMvc.Code { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | internal static class Util { 8 | internal static Uri GetAppPathRootedUri(string value) { 9 | string appPath = HttpContext.Current.Request.ApplicationPath.ToLowerInvariant(); 10 | if (!appPath.EndsWith("/")) { 11 | appPath += "/"; 12 | } 13 | 14 | return new Uri(HttpContext.Current.Request.Url, appPath + value); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdProviderMvc.Controllers { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Mvc; 7 | 8 | [HandleError] 9 | public class HomeController : Controller { 10 | public ActionResult Index() { 11 | if (Request.AcceptTypes.Contains("application/xrds+xml")) { 12 | ViewData["OPIdentifier"] = true; 13 | return View("Xrds"); 14 | } 15 | return View(); 16 | } 17 | 18 | public ActionResult Xrds() { 19 | ViewData["OPIdentifier"] = true; 20 | return View(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Controllers/UserController.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdProviderMvc.Controllers { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Mvc; 7 | using System.Web.Mvc.Ajax; 8 | 9 | public class UserController : Controller { 10 | /// 11 | /// Identities the specified id. 12 | /// 13 | /// The username or anonymous identifier. 14 | /// if set to true then represents an anonymous identifier rather than a username. 15 | /// The view to display. 16 | public ActionResult Identity(string id, bool anon) { 17 | if (!anon) { 18 | var redirect = this.RedirectIfNotNormalizedRequestUri(id); 19 | if (redirect != null) { 20 | return redirect; 21 | } 22 | } 23 | 24 | if (Request.AcceptTypes != null && Request.AcceptTypes.Contains("application/xrds+xml")) { 25 | return View("Xrds"); 26 | } 27 | 28 | if (!anon) { 29 | this.ViewData["username"] = id; 30 | } 31 | 32 | return View(); 33 | } 34 | 35 | public ActionResult Xrds(string id) { 36 | return View(); 37 | } 38 | 39 | private ActionResult RedirectIfNotNormalizedRequestUri(string user) { 40 | Uri normalized = Models.User.GetClaimedIdentifierForUser(user); 41 | if (Request.Url != normalized) { 42 | return Redirect(normalized.AbsoluteUri); 43 | } 44 | 45 | return null; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OpenIdProviderMvc._Default" %> 2 | 3 | <%-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. --%> 4 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdProviderMvc { 2 | using System.Web; 3 | using System.Web.Mvc; 4 | using System.Web.UI; 5 | 6 | public partial class _Default : Page { 7 | public void Page_Load(object sender, System.EventArgs e) { 8 | // Change the current path so that the Routing handler can correctly interpret 9 | // the request, then restore the original path so that the OutputCache module 10 | // can correctly process the response (if caching is enabled). 11 | string originalPath = Request.Path; 12 | HttpContext.Current.RewritePath(Request.ApplicationPath, false); 13 | IHttpHandler httpHandler = new MvcHttpHandler(); 14 | httpHandler.ProcessRequest(HttpContext.Current); 15 | HttpContext.Current.RewritePath(originalPath, false); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="OpenIdProviderMvc.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Models/User.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdProviderMvc.Models { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text.RegularExpressions; 6 | using System.Web; 7 | using System.Web.Routing; 8 | using OpenIdProviderMvc.Code; 9 | 10 | internal class User { 11 | internal static Uri ClaimedIdentifierBaseUri { 12 | get { return Util.GetAppPathRootedUri("user/"); } 13 | } 14 | 15 | internal static Uri GetClaimedIdentifierForUser(string username) { 16 | if (string.IsNullOrEmpty(username)) { 17 | throw new ArgumentNullException("username"); 18 | } 19 | 20 | return new Uri(ClaimedIdentifierBaseUri, username.ToLowerInvariant()); 21 | } 22 | 23 | internal static string GetUserFromClaimedIdentifier(Uri claimedIdentifier) { 24 | Regex regex = new Regex(@"/user/([^/\?]+)"); 25 | Match m = regex.Match(claimedIdentifier.AbsoluteUri); 26 | if (!m.Success) { 27 | throw new ArgumentException(); 28 | } 29 | 30 | return m.Groups[1].Value; 31 | } 32 | 33 | internal static Uri GetNormalizedClaimedIdentifier(Uri uri) { 34 | return GetClaimedIdentifierForUser(GetUserFromClaimedIdentifier(uri)); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OpenIdProviderMvc")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("OpenIdProviderMvc")] 13 | [assembly: AssemblyCopyright("Copyright © Outercurve Foundation 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("81ad930e-5e10-46a7-83fb-aed9e3f5f3e0")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Views/Home/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | <%@ Register Assembly="DotNetOpenAuth.OpenId.UI" Namespace="DotNetOpenAuth" TagPrefix="openauth" %> 4 | 5 | Home Page 6 | 7 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Views/OpenId/AskUser.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Do you want to log into another web site?" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" 2 | Inherits="System.Web.Mvc.ViewPage" %> 3 | 4 | 5 |

6 | Logging in somewhere? 7 |

8 |

9 | Are you trying to log into 10 | <%= Html.Encode(ViewData["Realm"]) %>? 11 |

12 | <% using (Html.BeginForm("AskUserResponse", "OpenId")) { %> 13 | <%= Html.AntiForgeryToken() %> 14 | <%= Html.Hidden("confirmed", "false") %> 15 | 19 |
20 | Javascript appears to be disabled in your browser. This page requires Javascript 21 | to be enabled to better protect your security. 22 |
23 | 37 | <% } %> 38 |
39 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Views/OpenId/Provider.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | OpenID Provider endpoint 5 | 6 | 7 |

OpenID Provider endpoint

8 |

This page expects to receive OpenID authentication messages to allow users to log 9 | into other web sites.

10 |
11 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Views/Shared/Error.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | Error 5 | 6 | 7 | 8 |

9 | Sorry, an error occurred while processing your request. 10 |

11 |
12 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Views/Shared/LogOnUserControl.ascx: -------------------------------------------------------------------------------- 1 | <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> 2 | 23 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Views/Shared/Site.Master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> 2 | 3 | 4 | 5 | 6 | 7 | <asp:ContentPlaceHolder ID="TitleContent" runat="server" /> 8 | 9 | 10 | 11 | 12 | 13 | 27 |
28 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Views/Shared/Xrds.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" ContentType="application/xrds+xml" %> 2 | <%@ OutputCache Duration="86400" VaryByParam="none" Location="Any" %> 3 | <%-- 4 | This XRDS view is used for both the OP identifier and the user identity pages. 5 | Only a couple of conditional checks are required to share the view, but sharing the view 6 | makes it very easy to ensure that all the Type URIs that this server supports are included 7 | for all XRDS discovery. 8 | --%> 9 | 13 | 14 | 15 | <% if (ViewData["OPIdentifier"] != null) { %> 16 | http://specs.openid.net/auth/2.0/server 17 | <% } else { %> 18 | http://specs.openid.net/auth/2.0/signon 19 | <% } %> 20 | http://openid.net/extensions/sreg/1.1 21 | http://axschema.org/contact/email 22 | 23 | <%-- 24 | Add these types when and if the Provider supports the respective aspects of the UI extension. 25 | http://specs.openid.net/extensions/ui/1.0/mode/popup 26 | http://specs.openid.net/extensions/ui/1.0/lang-pref 27 | http://specs.openid.net/extensions/ui/1.0/icon--%> 28 | <%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/OpenId/Provider"))%> 29 | 30 | <% if (ViewData["OPIdentifier"] == null) { %> 31 | 32 | http://openid.net/signon/1.0 33 | http://openid.net/extensions/sreg/1.1 34 | http://axschema.org/contact/email 35 | <%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/OpenId/Provider"))%> 36 | 37 | <% } %> 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/Views/User/Identity.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | <%@ Register Assembly="DotNetOpenAuth.OpenId.Provider.UI" Namespace="DotNetOpenAuth.OpenId.Provider" 4 | TagPrefix="op" %> 5 | 6 | <%=Html.Encode(ViewData["username"] ?? string.Empty)%> 7 | Identity page 8 | 9 | 10 | 12 | 14 | 15 | 16 |

17 | <% if (!string.IsNullOrEmpty(ViewData["username"] as string)) { %> 18 | This is 19 | <%=Html.Encode(ViewData["username"])%>'s 20 | <% } %> 21 | OpenID identity page 22 |

23 | <% if (string.Equals(User.Identity.Name, ViewData["username"])) { %> 24 |

25 | This is your identity page. 26 |

27 | <% } %> 28 |
29 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdProviderMvc/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdProviderMvc/favicon.ico -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyClassicAsp/MembersOnly.asp: -------------------------------------------------------------------------------- 1 | 2 | <% 3 | If Session("ClaimedIdentifier") = "" Then 4 | Response.Redirect("login.asp") 5 | End If 6 | %> 7 | 8 | 9 | DotNetOpenAuth Classic ASP sample: Members Only area 10 | 11 | 12 | 13 |
14 | 15 | DotNetOpenAuth 17 |
18 |

19 | Members Only Area 20 |

21 |

22 | Congratulations, <%=Session("ClaimedIdentifier") %>. 23 | You have completed the OpenID login process. 24 |

25 |

Additional data we may have about you using the Simple Registration extension:

26 | 27 | 28 | 29 | 30 |
Email <%=Session("Email") %>
Nickname <%=Session("Nickname") %>
Full name <%=Session("FullName") %>
31 |

Log out.

32 | 33 | 34 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyClassicAsp/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyClassicAsp/favicon.ico -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyClassicAsp/images/DotNetOpenAuth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyClassicAsp/images/DotNetOpenAuth.png -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyClassicAsp/images/openid_login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyClassicAsp/images/openid_login.png -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyClassicAsp/logout.asp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DotNetOpenAuth Classic ASP sample 5 | 6 | 7 | <% 8 | Session.Abandon 9 | Response.Redirect "default.asp" 10 | %> 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyClassicAsp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyClassicAsp/styles.css: -------------------------------------------------------------------------------- 1 | h2 2 | { 3 | font-style: italic; 4 | } 5 | 6 | body 7 | { 8 | font-family: Cambria, Arial, Times New Roman; 9 | font-size: 12pt; 10 | } 11 | 12 | .command 13 | { 14 | font-family: "Courier New", Courier, monospace; 15 | } 16 | 17 | input.openid 18 | { 19 | background-image: url(images/openid_login.png); 20 | background-repeat: no-repeat; 21 | background-position: 0 50%; 22 | padding-left: 15px; 23 | } 24 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/.gitignore: -------------------------------------------------------------------------------- 1 | Bin 2 | obj 3 | *Trace.txt 4 | *.user 5 | StyleCop.Cache 6 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Content/images/aol.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyMvc/Content/images/aol.gif -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Content/images/facebook.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyMvc/Content/images/facebook.gif -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Content/images/google.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyMvc/Content/images/google.gif -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Content/images/openid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyMvc/Content/images/openid.png -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Content/images/openid_small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyMvc/Content/images/openid_small.gif -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Content/images/yahoo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyMvc/Content/images/yahoo.gif -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdRelyingPartyMvc.Controllers { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Mvc; 7 | 8 | public class HomeController : Controller { 9 | public ActionResult Index() { 10 | Response.AppendHeader( 11 | "X-XRDS-Location", 12 | new Uri(Request.Url, Response.ApplyAppPathModifier("~/Home/xrds")).AbsoluteUri); 13 | return View("Index"); 14 | } 15 | 16 | public ActionResult Xrds() { 17 | return View("Xrds"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" %> 2 | 3 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="OpenIdRelyingPartyMvc.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Global.asax.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdRelyingPartyMvc { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Mvc; 7 | using System.Web.Routing; 8 | 9 | //// Note: For instructions on enabling IIS6 or IIS7 classic mode, 10 | //// visit http://go.microsoft.com/?LinkId=9394801 11 | 12 | public class MvcApplication : System.Web.HttpApplication { 13 | public static void RegisterRoutes(RouteCollection routes) { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | "Default", // Route name 18 | "{controller}/{action}/{id}", // URL with parameters 19 | new { controller = "Home", action = "Index", id = string.Empty }); // Parameter defaults 20 | 21 | routes.MapRoute( 22 | "Root", 23 | string.Empty, 24 | new { controller = "Home", action = "Index", id = string.Empty }); 25 | } 26 | 27 | protected void Application_Start(object sender, EventArgs e) { 28 | RegisterRoutes(RouteTable.Routes); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OpenIdRelyingPartyMvc")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("OpenIdRelyingPartyMvc")] 13 | [assembly: AssemblyCopyright("Copyright © Outercurve Foundation 2008")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("43c1645b-2968-4d5d-8828-5994e0b960ff")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Views/Home/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 |

OpenID Relying Party

5 |

Provided by DotNetOpenAuth

6 | <% if (User.Identity.IsAuthenticated) { %> 7 |

You are already logged in! Try visiting the 8 | <%=Html.ActionLink("Members Only", "Index", "User") %> 9 | area.

10 | <% } else { %> 11 |

Visit the 12 | <%=Html.ActionLink("Members Only", "Index", "User") %> 13 | area to trigger a login.

14 | <% } %> 15 |
16 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Views/Home/xrds.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" ContentType="application/xrds+xml" %> 2 | <%-- 3 | This page is a required for relying party discovery per OpenID 2.0. 4 | It allows Providers to call back to the relying party site to confirm the 5 | identity that it is claiming in the realm and return_to URLs. 6 | This page should be pointed to by the 'realm' home page, which in this sample 7 | is default.aspx. 8 | --%> 9 | 13 | 14 | 15 | http://specs.openid.net/auth/2.0/return_to 16 | <%-- Every page with an OpenID login should be listed here. --%> 17 | <%-- We use the Authenticate action instead of Login because Authenticate 18 | is the action that receives OpenId assertions. --%> 19 | <%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/user/authenticate"))%> 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Views/Shared/Site.Master.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdRelyingPartyMvc.Views.Shared { 2 | public partial class Site : System.Web.Mvc.ViewMasterPage { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Views/Shared/Site.Master.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OpenIdRelyingPartyMvc.Views.Shared { 11 | 12 | 13 | public partial class Site { 14 | 15 | /// 16 | /// HeadContentPlaceHolder control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.ContentPlaceHolder HeadContentPlaceHolder; 23 | 24 | /// 25 | /// MainContentPlaceHolder control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.ContentPlaceHolder MainContentPlaceHolder; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Views/User/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="OpenID Relying Party, by DotNetOpenAuth" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" 2 | Inherits="System.Web.Mvc.ViewPage" %> 3 | 4 | 5 |

Members Only Area

6 |

Congratulations, 7 | <%=Session["FriendlyIdentifier"] %>. You have completed the OpenID login process. 8 |

9 |

10 | <%=Html.ActionLink("Logout", "logout", new {}, new {@class="btn btn-default"}) %> 11 |

12 |
13 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/Views/User/Login.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | <% if (ViewData["Message"] != null) { %> 5 |
6 | <%= Html.Encode(ViewData["Message"].ToString())%> 7 |
8 | <% } %> 9 |

You must log in before entering the Members Area:

10 |
" method="post"> 11 | 12 | 13 | 14 |
15 | 18 | 27 | 28 |
29 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/OpenID/OpenIdRelyingPartyMvc/favicon.ico -------------------------------------------------------------------------------- /src/OpenID/OpenIdRelyingPartyMvc/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/App_Data/Users.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | bob 5 | test 6 | 7 | 8 | bob1 9 | test 10 | 11 | 12 | bob2 13 | test 14 | 15 | 16 | bob3 17 | test 18 | 19 | 20 | bob4 21 | test 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OpenIdWebRingSsoProvider._Default" %> 2 | 3 | <%@ Register Assembly="DotNetOpenAuth.OpenId.UI" Namespace="DotNetOpenAuth" TagPrefix="openid" %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |

13 | This sample is of an OpenID Provider that acts within a controlled set of web 14 | sites (perhaps all belonging to the same organization).  It authenticates 15 | the user in its own way (Windows Auth, username/password, InfoCard, X.509, 16 | anything), and then sends an automatically OpenID assertion to a limited set of 17 | whitelisted RPs without prompting the user. 18 |

19 |

20 | This particular sample uses Windows Authentication so that when the user visits 21 | an RP and the RP sends the user to this OP for authentication, the process is 22 | completely implicit -- the user never sees the OP.

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdWebRingSsoProvider { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.UI; 7 | using System.Web.UI.WebControls; 8 | using DotNetOpenAuth.OpenId.Provider; 9 | using OpenIdWebRingSsoProvider.Code; 10 | 11 | public partial class _Default : System.Web.UI.Page { 12 | protected void Page_Load(object sender, EventArgs e) { 13 | // The user may have just completed a login. If they're logged in, see if we can complete the OpenID login. 14 | if (User.Identity.IsAuthenticated && ProviderEndpoint.PendingAuthenticationRequest != null) { 15 | Util.ProcessAuthenticationChallenge(ProviderEndpoint.PendingAuthenticationRequest); 16 | if (ProviderEndpoint.PendingAuthenticationRequest.IsAuthenticated.HasValue) { 17 | ProviderEndpoint.SendResponse(); 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OpenIdWebRingSsoProvider { 11 | 12 | 13 | public partial class _Default { 14 | 15 | /// 16 | /// XrdsPublisher1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::DotNetOpenAuth.XrdsPublisher XrdsPublisher1; 23 | 24 | /// 25 | /// form1 control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/Login.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdWebRingSsoProvider { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.UI; 7 | using System.Web.UI.WebControls; 8 | using DotNetOpenAuth.OpenId.Provider; 9 | using OpenIdWebRingSsoProvider.Code; 10 | 11 | /// 12 | /// Challenges the user to authenticate to the OpenID SSO Provider. 13 | /// 14 | /// 15 | /// This login page is used only when the Provider is configured for 16 | /// FormsAuthentication. The default configuration is to use 17 | /// Windows authentication. 18 | /// 19 | public partial class Login : System.Web.UI.Page { 20 | protected void Page_Load(object sender, EventArgs e) { 21 | // This site doesn't need XSRF protection because only trusted RPs are ever allowed to receive authentication results 22 | // and because the login page itself is the only page the user could ever see as an in-between step to logging in, 23 | // and a login form isn't vulnerable to XSRF. 24 | if (!IsPostBack) { 25 | if (ProviderEndpoint.PendingAuthenticationRequest != null) { 26 | if (!ProviderEndpoint.PendingAuthenticationRequest.IsDirectedIdentity) { 27 | this.login1.UserName = Code.Util.ExtractUserName( 28 | ProviderEndpoint.PendingAuthenticationRequest.LocalIdentifier); 29 | ((TextBox)this.login1.FindControl("UserName")).ReadOnly = true; 30 | this.login1.FindControl("Password").Focus(); 31 | } 32 | } 33 | this.cancelButton.Visible = ProviderEndpoint.PendingAuthenticationRequest != null; 34 | } 35 | } 36 | 37 | protected void cancelButton_Click(object sender, EventArgs e) { 38 | var req = ProviderEndpoint.PendingAuthenticationRequest; 39 | if (req != null) { 40 | req.IsAuthenticated = false; 41 | ProviderEndpoint.SendResponse(); 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/Login.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OpenIdWebRingSsoProvider { 11 | 12 | 13 | public partial class Login { 14 | 15 | /// 16 | /// form1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// login1 control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Login login1; 32 | 33 | /// 34 | /// cancelButton control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.Button cancelButton; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OpenIdWebRingSsoProvider")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft IT")] 12 | [assembly: AssemblyProduct("OpenIdWebRingSsoProvider")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft IT 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/Server.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Server.aspx.cs" Inherits="OpenIdWebRingSsoProvider.Server" ValidateRequest="false" %> 2 | 3 | <%@ Register Assembly="DotNetOpenAuth.OpenId.Provider.UI" Namespace="DotNetOpenAuth.OpenId.Provider" 4 | TagPrefix="openid" %> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |
15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/Server.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdWebRingSsoProvider { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.UI; 7 | using System.Web.UI.WebControls; 8 | using DotNetOpenAuth.OpenId.Provider; 9 | using OpenIdWebRingSsoProvider.Code; 10 | 11 | public partial class Server : System.Web.UI.Page { 12 | protected void Page_Load(object sender, EventArgs e) { 13 | } 14 | 15 | protected void providerEndpoint1_AuthenticationChallenge(object sender, AuthenticationChallengeEventArgs e) { 16 | Util.ProcessAuthenticationChallenge(e.Request); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/Server.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace OpenIdWebRingSsoProvider { 11 | 12 | 13 | public partial class Server { 14 | 15 | /// 16 | /// providerEndpoint1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::DotNetOpenAuth.OpenId.Provider.ProviderEndpoint providerEndpoint1; 23 | 24 | /// 25 | /// form1 control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/op_xrds.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" ContentType="application/xrds+xml" %> 2 | <%-- 3 | This page is a required as part of the service discovery phase of the openid 4 | protocol (step 1). It simply renders the xml for doing service discovery of 5 | server.aspx using the xrds mechanism. 6 | This XRDS doc is discovered via the user.aspx page. 7 | --%> 8 | 12 | 13 | 14 | http://specs.openid.net/auth/2.0/server 15 | http://openid.net/extensions/sreg/1.1 16 | <%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%> 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/user.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Inherits="OpenIdWebRingSsoProvider.User" 2 | CodeBehind="user.aspx.cs" %> 3 | 4 | <%@ Register Assembly="DotNetOpenAuth.OpenId.Provider.UI" Namespace="DotNetOpenAuth.OpenId.Provider" 5 | TagPrefix="openid" %> 6 | 7 | 8 | 9 | 12 | 13 | 15 | 16 | 17 |

18 | OpenID identity page for 19 | 20 |

21 | 22 | 23 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/user.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdWebRingSsoProvider { 2 | using System; 3 | using DotNetOpenAuth.OpenId.Provider; 4 | using OpenIdWebRingSsoProvider.Code; 5 | 6 | /// 7 | /// This page is a required as part of the service discovery phase of the openid protocol (step 1). 8 | /// 9 | /// 10 | /// The XRDS (or Yadis) content is also rendered to provide the consumer with an alternative discovery mechanism. The Yadis protocol allows the consumer 11 | /// to provide the user with a more flexible range of authentication mechanisms (which ever has been defined in xrds.aspx). See http://en.wikipedia.org/wiki/Yadis. 12 | /// 13 | public partial class User : System.Web.UI.Page { 14 | protected void Page_Load(object sender, EventArgs e) { 15 | this.usernameLabel.Text = Util.ExtractUserName(Page.Request.Url); 16 | } 17 | 18 | protected void IdentityEndpoint20_NormalizeUri(object sender, IdentityEndpointNormalizationEventArgs e) { 19 | string username = Util.ExtractUserName(Page.Request.Url); 20 | e.NormalizedIdentifier = new Uri(Util.BuildIdentityUrl(username)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoProvider/user_xrds.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" ContentType="application/xrds+xml" %> 2 | <%-- 3 | This page is a required as part of the service discovery phase of the openid 4 | protocol (step 1). It simply renders the xml for doing service discovery of 5 | server.aspx using the xrds mechanism. 6 | This XRDS doc is discovered via the user.aspx page. 7 | --%> 8 | 12 | 13 | 14 | http://specs.openid.net/auth/2.0/signon 15 | http://openid.net/extensions/sreg/1.1 16 | <%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%> 17 | 18 | 19 | http://openid.net/signon/1.0 20 | http://openid.net/extensions/sreg/1.1 21 | <%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%> 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/Admin/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OpenIdWebRingSsoRelyingParty.Admin.Default" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 | You must be an admin! 12 |
13 |

14 | The roles you're assigned come from the trusted Provider's identity assertion. The 15 | sample OP comes hard-wired to assert membership in the Admin and Member roles. 16 |

17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/Admin/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdWebRingSsoRelyingParty.Admin { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.UI; 7 | using System.Web.UI.WebControls; 8 | 9 | public partial class Default : System.Web.UI.Page { 10 | protected void Page_Load(object sender, EventArgs e) { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/Admin/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.4927 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace OpenIdWebRingSsoRelyingParty.Admin { 12 | 13 | 14 | public partial class Default { 15 | 16 | /// 17 | /// form1 control. 18 | /// 19 | /// 20 | /// Auto-generated field. 21 | /// To modify move field declaration from designer file to code-behind file. 22 | /// 23 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/Admin/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OpenIdWebRingSsoRelyingParty._Default" %> 2 | 3 | 4 | 5 | 6 | Sample SSO relying party 7 | 8 | 9 |
10 |
11 | We've recognized you (via the SSO OP) as: 12 | 13 |

Try visiting the Admin area

14 |
15 |

This sample is of an OpenID Relying Party that acts within a controlled set of 16 | web sites (perhaps all belonging to the same organization).  This 17 | particular RP is configured to require authentication for all web pages, and to 18 | always use just one (trusted) OP (the OpenIdWebRingSsoProvider) without ever 19 | prompting the user.

20 |

Although the sample OP uses Windows Authentication, and so this RP could easily 21 | do the same, the idea is that the OP and RP may exist on different network 22 | topologies, or the OP may be the only site with access to the user credential 23 | database, or any number of other scenarios where the RP doesn't have the freedom 24 | to authenticate the user the way the OP has, yet this set of web sites want to 25 | have the users only authenticate themselves to one site with one set of 26 | credentials.

27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | namespace OpenIdWebRingSsoRelyingParty { 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.UI; 7 | using System.Web.UI.WebControls; 8 | 9 | public partial class _Default : System.Web.UI.Page { 10 | protected void Page_Load(object sender, EventArgs e) { 11 | if (Array.IndexOf(Request.AcceptTypes, "application/xrds+xml") >= 0) { 12 | Server.Transfer("xrds.aspx"); 13 | } else if (!User.Identity.IsAuthenticated) { 14 | Response.Redirect("Login.aspx"); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.4927 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace OpenIdWebRingSsoRelyingParty { 12 | 13 | 14 | public partial class _Default { 15 | 16 | /// 17 | /// form1 control. 18 | /// 19 | /// 20 | /// Auto-generated field. 21 | /// To modify move field declaration from designer file to code-behind file. 22 | /// 23 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 24 | 25 | /// 26 | /// LoginName1 control. 27 | /// 28 | /// 29 | /// Auto-generated field. 30 | /// To modify move field declaration from designer file to code-behind file. 31 | /// 32 | protected global::System.Web.UI.WebControls.LoginName LoginName1; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/Login.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="OpenIdWebRingSsoRelyingParty.Login" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 |
13 | Sorry. We couldn't log you in. 14 |
15 | 16 |

17 | 18 |

19 |
20 | 21 | You don't have permission to visit <%=HttpUtility.HtmlEncode(Request.QueryString["ReturnUrl"]) %>. 22 | 23 |
24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OpenIdWebRingSsoRelyingParty")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft IT")] 12 | [assembly: AssemblyProduct("OpenIdWebRingSsoRelyingParty")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft IT 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/OpenID/OpenIdWebRingSsoRelyingParty/xrds.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" ContentType="application/xrds+xml" %> 2 | <%-- 3 | This page is a required for relying party discovery per OpenID 2.0. 4 | It allows Providers to call back to the relying party site to confirm the 5 | identity that it is claiming in the realm and return_to URLs. 6 | This page should be pointed to by the 'realm' home page, which in this sample 7 | is default.aspx. 8 | --%> 9 | 13 | 14 | 15 | http://specs.openid.net/auth/2.0/return_to 16 | <%-- Every page with an OpenID login should be listed here. --%> 17 | <%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/login.aspx"))%> 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/VersionAssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotNetOpenAuth/DotNetOpenAuth.Samples/24e1095a8b9f2c3ba384ee79e8099a223712aad5/src/VersionAssemblyInfo.cs --------------------------------------------------------------------------------