12 |
13 |
14 |
15 | Twitter setup
16 |
17 | A Twitter client app must be endorsed by a Twitter user.
18 |
19 |
20 | Visit Twitter and create
21 | a client app .
22 | Modify your web.config file to include your consumer key and consumer secret.
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 |
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 | Visit Twitter and create
12 | a client app .
13 | Modify your web.config file to include your consumer key and consumer secret.
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 | Finish
10 | Cancel
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 |
12 |
13 |
22 |
23 |
24 |
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 |
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 |
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 |
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 |
16 |
17 |
18 |
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 |
3 | <%
4 | if (Request.IsAuthenticated)
5 | {
6 | %>
7 |
Welcome <%= Html.Encode(Page.User.Identity.Name) %> !
8 |
9 | <%= Html.ActionLink("Log Off", "LogOff", "Account") %>
10 |
11 | <%
12 | }
13 | else
14 | {
15 | %>
16 |
17 | <%= Html.ActionLink("Log On", "LogOn", "Account") %>
18 |
19 | <%
20 | }
21 | %>
22 |
23 |
--------------------------------------------------------------------------------
/src/OpenID/OpenIdProviderMvc/Views/Shared/Site.Master:
--------------------------------------------------------------------------------
1 | <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
24 | <% Html.RenderPartial("LogOnUserControl"); %>
25 |
26 |
27 |
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 |
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 | Email <%=Session("Email") %>
28 | Nickname <%=Session("Nickname") %>
29 | Full name <%=Session("FullName") %>
30 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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
--------------------------------------------------------------------------------