blob: cd523ddb27db50725b8d97d84302537ffad9f7cd (
plain)
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
41
42
43
44
45
46
47
48
|
//-----------------------------------------------------------------------
// <copyright file="OAuthAuthorize.aspx.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace WebFormsRelyingParty.Members {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
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) {
this.pendingRequest = OAuthServiceProvider.AuthorizationServer.ReadAuthorizationRequest();
if (this.pendingRequest == null) {
Response.Redirect("AccountInfo.aspx");
}
if (!IsPostBack) {
this.csrfCheck.Value = Code.SiteUtilities.SetCsrfCookie();
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);
}
}
protected void yesButton_Click(object sender, EventArgs e) {
this.outerMultiView.SetActiveView(this.authorizationGrantedView);
OAuthServiceProvider.AuthorizationServer.ApproveAuthorizationRequest(this.pendingRequest, HttpContext.Current.User.Identity.Name);
}
protected void noButton_Click(object sender, EventArgs e) {
this.outerMultiView.SetActiveView(this.authorizationDeniedView);
OAuthServiceProvider.AuthorizationServer.RejectAuthorizationRequest(this.pendingRequest);
}
}
}
|