Browse Source

Merge branch 'dev' into adding-widget-to-editor

pull/13242/head
malik masis 4 years ago
parent
commit
a3dc489868
  1. 135
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml
  2. 28
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs
  3. 18
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs

135
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml

@ -1,34 +1,119 @@
@page @page
@using Microsoft.AspNetCore.Http.Extensions
@using Microsoft.AspNetCore.Mvc.Localization
@using MyCompanyName.MyProjectName.Pages @using MyCompanyName.MyProjectName.Pages
@using MyCompanyName.MyProjectName.Localization
@using Volo.Abp.Users @using Volo.Abp.Users
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@using Volo.Abp.Ui.Branding
@model IndexModel @model IndexModel
@inject IHtmlLocalizer<MyProjectNameResource> L
@inject ICurrentUser CurrentUser @inject ICurrentUser CurrentUser
@if (CurrentUser.IsAuthenticated) @inject IBrandingProvider BrandingProvider
{ @inject ITheme Theme
<div>
@{
Layout = Theme.GetEmptyLayout();
}
<div class="d-flex align-items-center" style="min-height: 100vh;">
<div class="container">
<abp-row> <abp-row>
<abp-column size-md="_3" class="text-center">
<i class="fa fa-user d-block" style="font-size: 10em; color: #12b900"></i> <div class="col mx-auto account-column">
<a abp-button="Primary" href="/Account/Logout">Logout</a> <div class="account-brand p-4 text-center mb-1">
</abp-column>
<abp-column size-md="_9"> @if (!BrandingProvider.LogoUrl.IsNullOrEmpty())
<h2>@CurrentUser.UserName</h2> {
<h5 class="text-muted">@CurrentUser.Email</h5> <a class="navbar-brand" href="/" alt="@BrandingProvider.AppName"></a>
<div> }
<strong>Roles</strong>: @CurrentUser.Roles.JoinAsString(", ") else
<br /> {
<strong>Claims</strong>: <br /> <h1>@BrandingProvider.AppName</h1>
@Html.Raw(CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString(" <br /> ")) }
</div> </div>
</abp-column> <abp-card>
</abp-row>
</div> <abp-card-body>
}
<div class="container">
<abp-row>
<abp-column size="_9">
<div class="d-flex align-items-center">
<div class="me-3 p-2">
<i class="fa fa-user d-block" style="font-size: 10em; color: #12b900"></i>
</div>
<div class="p2">
@if (CurrentUser.IsAuthenticated)
{
<span class="fs-16">
@L["Welcome"] <span class="fw-7">@CurrentUser.UserName</span>
</span>
<span class="fs-14 d-block text-dark-800 opacity-75 mb-1">@CurrentUser.Email</span>
<div class="d-grid gap-2">
<a abp-button="Outline_Primary" asp-controller="Manage" asp-action="Index" asp-area="Account">@L["MyAccount"]</a>
<a abp-button="Primary" asp-controller="Logout" asp-action="Index" asp-area="Account">@L["Logout"]</a>
</div>
}
else
{
<a abp-button="Primary" asp-controller="Login" asp-action="Index" asp-area="Account">@L["Login"]</a>
}
</div>
@if (!CurrentUser.IsAuthenticated) </div>
{ </abp-column>
<div class="text-center"> <abp-column size="_3">
<i class="fa fa-user d-block" style="font-size: 10em; color: #aaa"></i><br/><br /> <div class="ml-auto p-2 float-end">
<a abp-button="Primary" asp-page="/Account/Login">Login</a> <abp-dropdown>
<abp-dropdown-button text="@Model.CurrentLanguage" />
<abp-dropdown-menu>
@foreach (var language in Model.Languages)
{
<abp-dropdown-item href="~/Abp/Languages/Switch?culture=@(language.CultureName)&uiCulture=@(language.UiCultureName)&returnUrl=@(System.Net.WebUtility.UrlEncode(Request.GetEncodedPathAndQuery()))">@language.DisplayName</abp-dropdown-item>
}
</abp-dropdown-menu>
</abp-dropdown>
</div>
</abp-column>
</abp-row>
<hr class="m-4" />
<abp-row>
@foreach (var application in Model.Applications)
{
<abp-column size-md="_4" class="mb-2">
<abp-card>
<abp-card-body>
@if (!application.LogoUri.IsNullOrEmpty())
{
<div class="mx-auto">
<img src="@application.LogoUri" style="height:64px" class="mb-3" />
</div>
}
<h4>@application.DisplayName</h4>
<span class="text-muted">@application.ClientUri</span>
<div class="mt-1">
<a abp-button="Outline_Secondary" href="@application.ClientUri">@L["Visit"]</a>
</div>
</abp-card-body>
</abp-card>
</abp-column>
}
</abp-row>
</div>
</abp-card-body>
</abp-card>
</div>
</abp-row>
</div> </div>
} </div>

28
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs

@ -1,10 +1,36 @@
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Localization;
using Volo.Abp.OpenIddict.Applications;
namespace MyCompanyName.MyProjectName.Pages; namespace MyCompanyName.MyProjectName.Pages;
public class IndexModel : AbpPageModel public class IndexModel : AbpPageModel
{ {
public void OnGet() public List<OpenIddictApplication> Applications { get; protected set; }
public IReadOnlyList<LanguageInfo> Languages { get; protected set; }
public string CurrentLanguage { get; protected set; }
protected IOpenIddictApplicationRepository OpenIdApplicationRepository { get; }
protected ILanguageProvider LanguageProvider { get; }
public IndexModel(IOpenIddictApplicationRepository openIdApplicationmRepository, ILanguageProvider languageProvider)
{ {
OpenIdApplicationRepository = openIdApplicationmRepository;
LanguageProvider = languageProvider;
}
public async Task OnGetAsync()
{
Applications = await OpenIdApplicationRepository.GetListAsync();
Languages = await LanguageProvider.GetLanguagesAsync();
CurrentLanguage = CultureInfo.CurrentCulture.DisplayName;
} }
} }

18
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs

@ -10,6 +10,7 @@ using Volo.Abp;
using Volo.Abp.Authorization.Permissions; using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.OpenIddict.Applications;
using Volo.Abp.PermissionManagement; using Volo.Abp.PermissionManagement;
using Volo.Abp.Uow; using Volo.Abp.Uow;
@ -21,14 +22,14 @@ namespace MyCompanyName.MyProjectName.OpenIddict;
public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency
{ {
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly IOpenIddictApplicationManager _applicationManager; private readonly IAbpApplicationManager _applicationManager;
private readonly IOpenIddictScopeManager _scopeManager; private readonly IOpenIddictScopeManager _scopeManager;
private readonly IPermissionDataSeeder _permissionDataSeeder; private readonly IPermissionDataSeeder _permissionDataSeeder;
private readonly IStringLocalizer<OpenIddictResponse> L; private readonly IStringLocalizer<OpenIddictResponse> L;
public OpenIddictDataSeedContributor( public OpenIddictDataSeedContributor(
IConfiguration configuration, IConfiguration configuration,
IOpenIddictApplicationManager applicationManager, IAbpApplicationManager applicationManager,
IOpenIddictScopeManager scopeManager, IOpenIddictScopeManager scopeManager,
IPermissionDataSeeder permissionDataSeeder, IPermissionDataSeeder permissionDataSeeder,
IStringLocalizer<OpenIddictResponse> l) IStringLocalizer<OpenIddictResponse> l)
@ -98,6 +99,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
}, },
scopes: commonScopes, scopes: commonScopes,
redirectUri: $"{webClientRootUrl}signin-oidc", redirectUri: $"{webClientRootUrl}signin-oidc",
clientUri: webClientRootUrl,
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc" postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc"
); );
} }
@ -122,6 +124,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
}, },
scopes: commonScopes, scopes: commonScopes,
redirectUri: consoleAndAngularClientRootUrl, redirectUri: consoleAndAngularClientRootUrl,
clientUri: consoleAndAngularClientRootUrl,
postLogoutRedirectUri: consoleAndAngularClientRootUrl postLogoutRedirectUri: consoleAndAngularClientRootUrl
); );
} }
@ -144,6 +147,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
}, },
scopes: commonScopes, scopes: commonScopes,
redirectUri: $"{blazorRootUrl}/authentication/login-callback", redirectUri: $"{blazorRootUrl}/authentication/login-callback",
clientUri: blazorRootUrl,
postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback" postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback"
); );
} }
@ -167,6 +171,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
}, },
scopes: commonScopes, scopes: commonScopes,
redirectUri: $"{blazorServerTieredRootUrl}signin-oidc", redirectUri: $"{blazorServerTieredRootUrl}signin-oidc",
clientUri: blazorServerTieredRootUrl,
postLogoutRedirectUri: $"{blazorServerTieredRootUrl}signout-callback-oidc" postLogoutRedirectUri: $"{blazorServerTieredRootUrl}signout-callback-oidc"
); );
} }
@ -188,7 +193,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.AuthorizationCode,
}, },
scopes: commonScopes, scopes: commonScopes,
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html" redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
clientUri: swaggerRootUrl
); );
} }
} }
@ -201,6 +207,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
string secret, string secret,
List<string> grantTypes, List<string> grantTypes,
List<string> scopes, List<string> scopes,
string clientUri = null,
string redirectUri = null, string redirectUri = null,
string postLogoutRedirectUri = null, string postLogoutRedirectUri = null,
List<string> permissions = null) List<string> permissions = null)
@ -224,13 +231,14 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
var client = await _applicationManager.FindByClientIdAsync(name); var client = await _applicationManager.FindByClientIdAsync(name);
if (client == null) if (client == null)
{ {
var application = new OpenIddictApplicationDescriptor var application = new AbpApplicationDescriptor
{ {
ClientId = name, ClientId = name,
Type = type, Type = type,
ClientSecret = secret, ClientSecret = secret,
ConsentType = consentType, ConsentType = consentType,
DisplayName = displayName DisplayName = displayName,
ClientUri = clientUri,
}; };
Check.NotNullOrEmpty(grantTypes, nameof(grantTypes)); Check.NotNullOrEmpty(grantTypes, nameof(grantTypes));

Loading…
Cancel
Save