diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-12 22:00:46 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-12 22:00:46 -0700 |
commit | eea1b39e043cbd64bccda02e9c9da81aeb359ada (patch) | |
tree | 39f6a1ba996bb6ebf081d5a41b25d5ebebc3f6cd /projecttemplates/WebFormsRelyingParty/Members | |
parent | 096a53e5a79cac2eecb1311661a255a5f4e6aa6e (diff) | |
download | DotNetOpenAuth-eea1b39e043cbd64bccda02e9c9da81aeb359ada.zip DotNetOpenAuth-eea1b39e043cbd64bccda02e9c9da81aeb359ada.tar.gz DotNetOpenAuth-eea1b39e043cbd64bccda02e9c9da81aeb359ada.tar.bz2 |
Work toward the WebFormsRelyingParty project template to use OAuth 2.0 instead of 1.0a.
It compiles now. (and the MVC one doesn't).
Diffstat (limited to 'projecttemplates/WebFormsRelyingParty/Members')
3 files changed, 14 insertions, 91 deletions
diff --git a/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx b/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx index 7886157..7e07323 100644 --- a/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx +++ b/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx @@ -29,19 +29,6 @@ <b>Javascript appears to be disabled in your browser. </b>This page requires Javascript to be enabled to better protect your security. </div> - <asp:Panel runat="server" BackColor="Red" ForeColor="White" Font-Bold="true" Visible="false" - ID="OAuth10ConsumerWarning"> - This website is registered with - <asp:Label runat="server" ID="serviceProviderDomainNameLabel" /> - to make authorization requests, but has not been configured to send requests securely. - If you grant access but you did not initiate this request at - <asp:Label runat="server" ID="consumerDomainNameLabel1" />, it may be possible for - other users of - <asp:Label runat="server" ID="consumerDomainNameLabel2" /> - to access your data. We recommend you deny access unless you are certain that you - initiated this request directly with - <asp:Label runat="server" ID="consumerDomainNameLabel3" />. - </asp:Panel> <script language="javascript" type="text/javascript"> //<![CDATA[ diff --git a/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs b/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs index 16e48f0..cd523dd 100644 --- a/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs +++ b/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs @@ -13,22 +13,23 @@ namespace WebFormsRelyingParty.Members { using System.Web.UI.WebControls; using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.Messages; + using DotNetOpenAuth.OAuth2.Messages; + using RelyingPartyLogic; public partial class OAuthAuthorize : System.Web.UI.Page { + private EndUserAuthorizationRequest pendingRequest; + protected void Page_Load(object sender, EventArgs e) { - if (!IsPostBack) { - var pendingRequest = OAuthServiceProvider.PendingAuthorizationRequest; - if (pendingRequest == null) { - Response.Redirect("AccountInfo.aspx"); - } + this.pendingRequest = OAuthServiceProvider.AuthorizationServer.ReadAuthorizationRequest(); + if (this.pendingRequest == null) { + Response.Redirect("AccountInfo.aspx"); + } + if (!IsPostBack) { this.csrfCheck.Value = Code.SiteUtilities.SetCsrfCookie(); - this.consumerNameLabel.Text = HttpUtility.HtmlEncode(OAuthServiceProvider.PendingAuthorizationConsumer.Name); - this.OAuth10ConsumerWarning.Visible = pendingRequest.IsUnsafeRequest; - - this.serviceProviderDomainNameLabel.Text = HttpUtility.HtmlEncode(this.Request.Url.Host); - this.consumerDomainNameLabel3.Text = this.consumerDomainNameLabel2.Text = this.consumerDomainNameLabel1.Text = HttpUtility.HtmlEncode(OAuthServiceProvider.PendingAuthorizationConsumer.Name); + var requestingClient = Database.DataContext.Consumers.First(c => c.ConsumerKey == this.pendingRequest.ClientIdentifier); + this.consumerNameLabel.Text = HttpUtility.HtmlEncode(requestingClient.Name); } else { Code.SiteUtilities.VerifyCsrfCookie(this.csrfCheck.Value); } @@ -36,31 +37,12 @@ namespace WebFormsRelyingParty.Members { protected void yesButton_Click(object sender, EventArgs e) { this.outerMultiView.SetActiveView(this.authorizationGrantedView); - - var consumer = OAuthServiceProvider.PendingAuthorizationConsumer; - var tokenManager = OAuthServiceProvider.ServiceProvider.TokenManager; - var pendingRequest = OAuthServiceProvider.PendingAuthorizationRequest; - ITokenContainingMessage requestTokenMessage = pendingRequest; - var requestToken = tokenManager.GetRequestToken(requestTokenMessage.Token); - - OAuthServiceProvider.AuthorizePendingRequestToken(); - - // The rest of this method only executes if we couldn't automatically - // redirect to the consumer. - if (pendingRequest.IsUnsafeRequest) { - this.verifierMultiView.SetActiveView(this.noCallbackView); - } else { - this.verifierMultiView.SetActiveView(this.verificationCodeView); - string verifier = ServiceProvider.CreateVerificationCode(consumer.VerificationCodeFormat, consumer.VerificationCodeLength); - this.verificationCodeLabel.Text = HttpUtility.HtmlEncode(verifier); - requestToken.VerificationCode = verifier; - tokenManager.UpdateToken(requestToken); - } + OAuthServiceProvider.AuthorizationServer.ApproveAuthorizationRequest(this.pendingRequest, HttpContext.Current.User.Identity.Name); } protected void noButton_Click(object sender, EventArgs e) { this.outerMultiView.SetActiveView(this.authorizationDeniedView); - OAuthServiceProvider.PendingAuthorizationRequest = null; + OAuthServiceProvider.AuthorizationServer.RejectAuthorizationRequest(this.pendingRequest); } } } diff --git a/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.designer.cs b/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.designer.cs index 20d5ea9..19947de 100644 --- a/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.designer.cs +++ b/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. -// Runtime Version:2.0.50727.4927 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ @@ -68,51 +67,6 @@ namespace WebFormsRelyingParty.Members { protected global::System.Web.UI.WebControls.HiddenField csrfCheck; /// <summary> - /// OAuth10ConsumerWarning control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Panel OAuth10ConsumerWarning; - - /// <summary> - /// serviceProviderDomainNameLabel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label serviceProviderDomainNameLabel; - - /// <summary> - /// consumerDomainNameLabel1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label consumerDomainNameLabel1; - - /// <summary> - /// consumerDomainNameLabel2 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label consumerDomainNameLabel2; - - /// <summary> - /// consumerDomainNameLabel3 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label consumerDomainNameLabel3; - - /// <summary> /// authorizationGrantedView control. /// </summary> /// <remarks> |