oauth
This commit is contained in:
parent
989df49cf2
commit
19b41ed9f4
19 changed files with 1729 additions and 7620 deletions
|
|
@ -1,20 +1,18 @@
|
|||
@using System.Collections.Generic
|
||||
@using Microsoft.AspNet.Http
|
||||
@using Microsoft.AspNet.Http.Authentication
|
||||
@model LoginViewModel
|
||||
@inject SignInManager<ApplicationUser> SignInManager
|
||||
|
||||
@using Microsoft.AspNet.Http.Authentication
|
||||
@using Yavsc.ViewModels.Account
|
||||
@model LoginViewModel
|
||||
@{
|
||||
ViewData["Title"] = SR["Log in"];
|
||||
}
|
||||
|
||||
<h2>@ViewData["Title"]</h2>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<section>
|
||||
<form asp-controller="Account" asp-action="Login" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="form-horizontal" role="form">
|
||||
<h4>@SR["Use a local account to log in."]</h4>
|
||||
<hr />
|
||||
<div class="jumbotron">
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
<hr/>
|
||||
|
||||
<h2 class="lead text-left">@SR["Use a local account to log in"]</h2>
|
||||
<form action="@Constants.LoginPath" method="post" class="form-horizontal" role="form">
|
||||
|
||||
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label for="UserName" class="col-md-2 control-label">@SR["UserName"]</label>
|
||||
|
|
@ -40,25 +38,24 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<button type="submit" class="btn btn-default">@SR["Login"]</button>
|
||||
<button type="submit" class="btn btn-lg btn-success">@SR["Login"]</button>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
<a asp-action="Register">@SR["Register as a new user?"]</a>
|
||||
<a asp-action="Register" asp-controller="Account">@SR["Register as a new user"]?</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="ForgotPassword">@SR["Forgot your password?"]</a>
|
||||
<a asp-action="ForgotPassword" asp-controller="Account">@SR["Forgot your password"]?</a>
|
||||
</p>
|
||||
<input type="hidden" name="Provider" value="LOCAL" />
|
||||
<input type="hidden" name="ReturnUrl" value="@Model.ReturnUrl" />
|
||||
|
||||
@Html.AntiForgeryToken()
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<section>
|
||||
<h4>@SR["Use another service to log in."]</h4>
|
||||
<hr />
|
||||
@{
|
||||
var loginProviders = SignInManager.GetExternalAuthenticationSchemes().ToList();
|
||||
if (loginProviders.Count == 0)
|
||||
|
||||
<hr/>
|
||||
<h2 class="lead text-left">@SR["Use another service to log in"]:</h2>
|
||||
@if (Model.ExternalProviders?.Count() == 0)
|
||||
{
|
||||
<div>
|
||||
<p>
|
||||
|
|
@ -69,22 +66,13 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<form asp-controller="Account" asp-action="ExternalLogin" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="form-horizontal" role="form">
|
||||
<div>
|
||||
<p>
|
||||
@foreach (var provider in loginProviders)
|
||||
{
|
||||
<button type="submit" class="btn btn-default" name="provider" value="@provider.AuthenticationScheme" title="Log in using your @provider.DisplayName account">@provider.AuthenticationScheme</button>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
@foreach (var description in Model.ExternalProviders) {
|
||||
<form action="@Constants.LoginPath" method="post">
|
||||
<input type="hidden" name="Provider" value="@description.AuthenticationScheme" />
|
||||
<input type="hidden" name="ReturnUrl" value="@Model.ReturnUrl" />
|
||||
<button class="btn btn-lg btn-success" type="submit">@SR["Connect using"] @description.DisplayName</button>
|
||||
@Html.AntiForgeryToken()
|
||||
</form>
|
||||
}
|
||||
}
|
||||
</section>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||
}
|
||||
|
|
|
|||
32
Yavsc/Views/OAuth/Authorize.cshtml
Normal file
32
Yavsc/Views/OAuth/Authorize.cshtml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
@using Microsoft.AspNet.Http.Authentication
|
||||
@using Microsoft.AspNet.WebUtilities
|
||||
@using System.Security.Claims
|
||||
@{
|
||||
AuthenticationManager authentication = Context.Authentication;
|
||||
ClaimsPrincipal principal = authentication.AuthenticateAsync(Constants.ApplicationAuthenticationSheme).Result;
|
||||
string[] scopes = QueryHelpers.ParseQuery(Context.Request.QueryString.Value)["scope"];
|
||||
}
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Authorize</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Authorization Server</h1>
|
||||
<h2>OAuth2 Authorize</h2>
|
||||
<form method="POST">
|
||||
<p>Hello, @principal.Identity.Name</p>
|
||||
<p>A third party application want to do the following on your behalf:</p>
|
||||
<ul>
|
||||
@foreach (var scope in scopes)
|
||||
{
|
||||
<li>@scope</li>
|
||||
}
|
||||
</ul>
|
||||
<p>
|
||||
<input type="submit" name="submit.Grant" value="Grant" />
|
||||
<input type="submit" name="submit.Login" value="Sign in as different user" />
|
||||
</p>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
20
Yavsc/Views/OAuth/AuthorizeError.cshtml
Normal file
20
Yavsc/Views/OAuth/AuthorizeError.cshtml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
@using Microsoft.AspNet.Http
|
||||
@using System
|
||||
@using System.Security.Claims
|
||||
@{
|
||||
var error = Context.Items["oauth.Error"];
|
||||
var errorDescription = Context.Items["oauth.ErrorDescription"];
|
||||
var errorUri = Context.Items["oauth.ErrorUri"];
|
||||
}
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Authorize Error</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Katana.Sandbox.WebServer</h1>
|
||||
<h2>OAuth2 Authorize Error</h2>
|
||||
<p>Error: @error</p>
|
||||
<p>@errorDescription</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
@using AspNet.Security.OpenIdConnect.Extensions
|
||||
@using Microsoft.IdentityModel.Protocols.OpenIdConnect
|
||||
|
||||
|
||||
|
||||
@model AuthorisationView
|
||||
|
||||
<div class="jumbotron">
|
||||
<h1>Authorization</h1>
|
||||
<h1>Authorization @Application?.DisplayName</h1>
|
||||
|
||||
<p>@Model.Message</p>
|
||||
|
||||
<p class="lead text-left">Do you wanna grant <strong>@Model.Application.DisplayName</strong> an access to your resources? (scopes requested: @Model.Message.Scope)</p>
|
||||
|
||||
<form enctype="application/x-www-form-urlencoded" method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@foreach (var parameter in Model.Message.Parameters) {
|
||||
<input type="hidden" name="@parameter.Key" value="@parameter.Value" />
|
||||
@foreach (var scope in Model.Scopes) {
|
||||
<li>@scope</li>
|
||||
}
|
||||
<input formaction="/connect/authorize/accept" class="btn btn-lg btn-success" name="Authorize" type="submit" value="Yeah, sure" />
|
||||
<input formaction="/api/token/get" class="btn btn-lg btn-success" name="Authorize" type="submit" value="hum" />
|
||||
<input formaction="/connect/authorize/deny" class="btn btn-lg btn-danger" name="Deny" type="submit" value="Hell, no" />
|
||||
</form>
|
||||
@Html.Hidden("ReturnUrl")
|
||||
<input formaction="/oauth/accept" class="btn btn-lg btn-success" name="Authorize" type="submit" value="Yeah, sure" />
|
||||
<input formaction="/oauth/deny" class="btn btn-lg btn-danger" name="Deny" type="submit" value="Hell, no" />
|
||||
<input formaction="/oauth/deny" class="btn btn-lg btn-success" name="Submit.Login" type="submit" value="Login using another account" />
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<hr/>
|
||||
|
||||
<h2 class="lead text-left">@SR["Use a local account to log in"]</h2>
|
||||
<form action="/login" method="post" class="form-horizontal" role="form">
|
||||
<form action="@Constants.LoginPath" method="post" class="form-horizontal" role="form">
|
||||
|
||||
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
else
|
||||
{
|
||||
@foreach (var description in Model.ExternalProviders) {
|
||||
<form action="/signin" method="post">
|
||||
<form action="@Constants.LoginPath" method="post">
|
||||
<input type="hidden" name="Provider" value="@description.AuthenticationScheme" />
|
||||
<input type="hidden" name="ReturnUrl" value="@Model.ReturnUrl" />
|
||||
<button class="btn btn-lg btn-success" type="submit">@SR["Connect using"] @description.DisplayName</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue