OAuth OK!
This commit is contained in:
parent
494a840f70
commit
567e4a6635
382 changed files with 52478 additions and 7572 deletions
|
|
@ -1,4 +1,4 @@
|
|||
@model Yavsc.Application
|
||||
@model Yavsc.Models.Auth.Client
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
|
|
@ -8,9 +8,17 @@
|
|||
|
||||
<form asp-action="Create">
|
||||
<div class="form-horizontal">
|
||||
<h4>Application</h4>
|
||||
<h4>Client</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<div class="checkbox">
|
||||
<input asp-for="Active" />
|
||||
<label asp-for="Active"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="DisplayName" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
|
|
@ -32,6 +40,13 @@
|
|||
<span asp-validation-for="RedirectUri" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="RefreshTokenLifeTime" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="RefreshTokenLifeTime" class="form-control" />
|
||||
<span asp-validation-for="RefreshTokenLifeTime" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Secret" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
|
|
@ -39,6 +54,16 @@
|
|||
<span asp-validation-for="Secret" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Type" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<select name="Type" class="form-control">
|
||||
<option value="0" >JavaScript</option>
|
||||
<option value="1" >NativeConfidential</option>
|
||||
</select>
|
||||
<span asp-validation-for="Type" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
@model Yavsc.Application
|
||||
@model Yavsc.Models.Auth.Client
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
|
|
@ -8,9 +8,15 @@
|
|||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Application</h4>
|
||||
<h4>Client</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Active)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Active)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.DisplayName)
|
||||
</dt>
|
||||
|
|
@ -29,12 +35,24 @@
|
|||
<dd>
|
||||
@Html.DisplayFor(model => model.RedirectUri)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.RefreshTokenLifeTime)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.RefreshTokenLifeTime)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Secret)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Secret)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Type)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Type)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
@model Yavsc.Application
|
||||
@model Yavsc.Models.Auth.Client
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
|
|
@ -7,9 +7,21 @@
|
|||
<h2>Details</h2>
|
||||
|
||||
<div>
|
||||
<h4>Application</h4>
|
||||
<h4>Client</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Id)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Id)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Active)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Active)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.DisplayName)
|
||||
</dt>
|
||||
|
|
@ -29,10 +41,10 @@
|
|||
@Html.DisplayFor(model => model.RedirectUri)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.ApplicationID)
|
||||
@Html.DisplayNameFor(model => model.RefreshTokenLifeTime)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.ApplicationID)
|
||||
@Html.DisplayFor(model => model.RefreshTokenLifeTime)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Secret)
|
||||
|
|
@ -40,9 +52,15 @@
|
|||
<dd>
|
||||
@Html.DisplayFor(model => model.Secret)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Type)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Type)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
<a asp-action="Edit" asp-route-id="@Model.ApplicationID">Edit</a> |
|
||||
<a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</p>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
@model Yavsc.Application
|
||||
@model Yavsc.Models.Auth.Client
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
|
|
@ -8,10 +8,18 @@
|
|||
|
||||
<form asp-action="Edit">
|
||||
<div class="form-horizontal">
|
||||
<h4>Application</h4>
|
||||
<h4>Client</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="ApplicationID" />
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<div class="checkbox">
|
||||
<input asp-for="Active" />
|
||||
<label asp-for="Active"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="DisplayName" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
|
|
@ -33,6 +41,13 @@
|
|||
<span asp-validation-for="RedirectUri" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="RefreshTokenLifeTime" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="RefreshTokenLifeTime" class="form-control" />
|
||||
<span asp-validation-for="RefreshTokenLifeTime" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Secret" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
|
|
@ -40,6 +55,13 @@
|
|||
<span asp-validation-for="Secret" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Type" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<select asp-for="Type" class="form-control"></select>
|
||||
<span asp-validation-for="Type" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Save" class="btn btn-default" />
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
@model IEnumerable<Yavsc.Application>
|
||||
@model IEnumerable<Yavsc.Models.Auth.Client>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.ApplicationID)
|
||||
@Html.DisplayNameFor(model => model.Active)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.DisplayName)
|
||||
|
|
@ -23,16 +23,22 @@
|
|||
<th>
|
||||
@Html.DisplayNameFor(model => model.RedirectUri)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.RefreshTokenLifeTime)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Secret)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Type)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ApplicationID)
|
||||
@Html.DisplayFor(modelItem => item.Active)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DisplayName)
|
||||
|
|
@ -43,13 +49,19 @@
|
|||
<td>
|
||||
@Html.DisplayFor(modelItem => item.RedirectUri)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.RefreshTokenLifeTime)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Secret)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.ApplicationID">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.ApplicationID">Details</a> |
|
||||
<a asp-action="Delete" asp-route-id="@item.ApplicationID">Delete</a>
|
||||
@Html.DisplayFor(modelItem => item.Type)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
32
Yavsc/Views/OAuth/Authorize-new.cshtml
Normal file
32
Yavsc/Views/OAuth/Authorize-new.cshtml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
@using Microsoft.AspNet.Http.Authentication
|
||||
@using Microsoft.AspNet.WebUtilities
|
||||
@using System.Security.Claims
|
||||
@using Microsoft.Extensions.Primitives
|
||||
@model Yavsc.Models.Auth.AuthorisationView
|
||||
@{
|
||||
ViewBag.Title = @SR["Authorize"];
|
||||
}
|
||||
<h1>Authorization Server</h1>
|
||||
<h2>OAuth2 Authorize</h2>
|
||||
<form method="POST" asp-action="Authorize" asp-controller="OAuth">
|
||||
<p>Hello, @User.Identity.Name</p>
|
||||
<p>@Model.Message</p>
|
||||
<p>A third party application want to do the following on your behalf:</p>
|
||||
<ul>
|
||||
@foreach (var scope in Model.Scopes)
|
||||
{
|
||||
<li><em>@scope.Id</em>: @scope.Description</li>
|
||||
}
|
||||
</ul>
|
||||
<p>
|
||||
<input type="submit" class="btn btn-lg btn-success" name="submit.Grant" value="Grant" />
|
||||
<input type="submit" class="btn btn-lg btn-danger" name="submit.Deny" value="Deny" />
|
||||
<input type="submit" class="btn btn-lg btn-success" name="submit.Login" value="Sign in as different user" />
|
||||
</p>
|
||||
@if (Model.QueryStringComponents!=null) {
|
||||
@foreach (var key in Model.QueryStringComponents.Keys) {
|
||||
@Html.Hidden(key,Model.QueryStringComponents[key])
|
||||
}
|
||||
|
||||
}
|
||||
</form>
|
||||
|
|
@ -1,32 +1,34 @@
|
|||
@using Microsoft.AspNet.Http.Authentication
|
||||
@using Microsoft.AspNet.Http.Authentication
|
||||
@using Microsoft.AspNet.WebUtilities
|
||||
@using System.Security.Claims
|
||||
@using System.Security.Claims
|
||||
@model Yavsc.Models.Auth.AuthorisationView
|
||||
@{
|
||||
AuthenticationManager authentication = Context.Authentication;
|
||||
ClaimsPrincipal principal = authentication.AuthenticateAsync(Constants.ApplicationAuthenticationSheme).Result;
|
||||
string[] scopes = QueryHelpers.ParseQuery(Context.Request.QueryString.Value)["scope"];
|
||||
ViewBag.Title = @SR["Authorize"];
|
||||
}
|
||||
<!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)
|
||||
<h1>Authorization Server</h1>
|
||||
<h2>OAuth2 Authorize</h2>
|
||||
|
||||
<form method="POST" asp-action="Authorize" asp-controller="OAuth"
|
||||
asp-route-client_id="@Model.ClientId"
|
||||
asp-route-redirect_url="@Model.RedirectUrl"
|
||||
asp-route-state="@Model.State"
|
||||
asp-route-response_type="@Model.ResponseType"
|
||||
>
|
||||
<p>Hello, @User.Identity.Name</p>
|
||||
<p>@Model.Message</p>
|
||||
<p>A third party application want to do the following on your behalf:</p>
|
||||
<ul>
|
||||
@if (Model.Scopes!=null) {
|
||||
@foreach (var scope in Model.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>
|
||||
<li><em>@scope.Id</em>: @scope.Description</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
<p>
|
||||
<input type="submit" class="btn btn-lg btn-success" name="submit.Grant" value="Grant" />
|
||||
<input type="submit" class="btn btn-lg btn-danger" name="submit.Deny" value="Deny" />
|
||||
<input type="submit" class="btn btn-lg btn-success" name="submit.Login" value="Sign in as different user" />
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
@model AuthorisationView
|
||||
|
||||
<div class="jumbotron">
|
||||
<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 scope in Model.Scopes) {
|
||||
<li>@scope</li>
|
||||
}
|
||||
@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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue