[HttpGet]
public async Task<IActionResult> Index(string returnUrl)
{
var model = await BuildConsentViewModel(returnUrl);
if (model == null)
{
}
return View(model);
}
@if (Model.IdentityScopes.Any())
{
<div>
<span class="glyphicon glyphicon-user"></span>
用户信息
</div>
<ul class="list-group">
@foreach (var scope in Model.IdentityScopes)
{
@Html.Partial("_ScopeListitem", scope)
}
</ul>
}
@using mvcCookieAuthSample.ViewModels;
@model ScopeViewModel
<li>
<label>
<input type="checkbox"
name="ScopesConsented"
id="scopes_@Model.Name"
value="@Model.Name"
checked="@Model.Checked"
disabled="@Model.Required"/>
<strong>@Model.Name</strong>
@if (Model.Emphasize)
{
<span class="glyphicon glyphicon-exclamation-sign"></span>
}
</label>
@if (string.IsNullOrEmpty(Model.Description))
{
<div>
<label for="scopes_@Model.Name">@Model.Description</label>
</div>
}
</li>
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client()
{
ClientId = "client",
ClientName = "Client",
ClientUri = "http://localhost:5001",
LogoUri = "https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQe9J82GNBVtbc0Co3IV63l4mQgRlMdn4lQI7cDmICHjA4VmFuv&usqp=CAU",
AllowRememberConsent = true,
AllowedGrantTypes = GrantTypes.Implicit,// 隐式模式
ClientSecrets =
{
new Secret("secret".Sha256())
},
RequireConsent = true,
RedirectUris = { "http://localhost:5001/signin-oidc" },
PostLogoutRedirectUris = { "http://localhost:5001/signout-callback-oidc" },
//AllowedScopes = {"api"},
AllowedScopes =
{
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Email,
}
}
};
}
@if (!string.IsNullOrWhiteSpace(Model.ClientLogoUrl))