-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefault.cshtml
71 lines (68 loc) · 2.45 KB
/
Default.cshtml
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@{
Layout = null;
var appSettings = System.Configuration.ConfigurationManager.AppSettings;
var backgroundColor = appSettings["background"]== null? "#000000": appSettings["background"];
var secretmessage = appSettings["secret"] == null ? "" : appSettings["secret"];
}
@using System.Security.Claims
@using System.Threading
@using System.Web.Configuration
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Auth Testing</title>
</head>
<body style="font-family:Arial; background: @backgroundColor; color:white;">
<div>
@{
var claimsPrincipal = Thread.CurrentPrincipal as ClaimsPrincipal;
<h1> @secretmessage </h1>
if (claimsPrincipal != null && claimsPrincipal.Identity.IsAuthenticated)
{
<h2 style="color:red">Authentication Succeeded!</h2>
<div><span><strong>Principal Name:</strong><br />@claimsPrincipal.Identity.Name</span></div>
<div><span><a href="@WebConfigurationManager.AppSettings["WEBSITE_AUTH_LOGOUT_PATH"]">Logout</a></span></div>
<br />
<div><span><strong>x-ms-client-principal-name:</strong><br />@Request.Headers["X-MS-CLIENT-PRINCIPAL-NAME"]</span></div>
<br />
<div><strong>Raw Claims</strong></div>
<table border="1">
<tbody>
@foreach (var claim in claimsPrincipal.Claims)
{
<tr>
<td>@claim.Type</td>
<td>@claim.Value</td>
</tr>
}
</tbody>
</table>
<br />
}
else
{
<div style="color:blue">Current request is unauthenticated!</div>
}
}
</div>
<br />
<div>
<div><strong>Raw HTTP Headers</strong></div>
<table border="1">
<tbody>
@{
foreach (string header in this.Request.Headers)
{
<tr>
<td>@header</td>
<td>@this.Request.Headers[header]</td>
</tr>
}
}
</tbody>
</table>
</div>
<h3>Thanks to Byron Tardif for this code! </h3>
</body>
</html>