Skoruba.IdentityServer4.Admin
repository·master·Indexed 25 days ago
https://github.com/skoruba/identityserver4.adminAn administration UI for managing IdentityServer4 and ASP.NET Core Identity. It provides a web interface to manage clients, API resources, identity resources, users, and roles. The system supports SqlServer, MySql, and PostgreSQL, and includes a dotnet template for project scaffolding, Docker Compose support, and integration with Azure Key Vault.
What's inside Skoruba.IdentityServer4.Admin
- Skoruba.IdentityServer4.Admin is a management interface designed for the administration of IdentityServer4 and Asp.Net Core Identity. It provides a UI to manage identity and access management configurations.
Generate a PFX certificate for signing tokens
masterIf you do not have a certificate for signing tokens, you can generate a
.pfxfile using OpenSSL.On Windows, you can install OpenSSL via Chocolatey:
choco install openssl.lightThen, run the following commands to generate the certificate files:
openssl genrsa 2048 > private.pem openssl req -x509 -new -key private.pem -out public.pem openssl pkcs12 -export -in public.pem -inkey private.pem -out mycert.pfxNote: Remember the password used during the export process, as it will be required later.
Install client libraries and manage assets
masterThe project uses npm for client libraries and Gulp for asset bundling.
Install Libraries:
cd src/Skoruba.IdentityServer4.Admin npm install cd src/Skoruba.IdentityServer4.STS.Identity npm installGulp Tasks:
gulp fonts: copy fonts todistfoldergulp styles: minify CSS, compile SASS to CSSgulp scripts: bundle and minify JSgulp clean: removedistfoldergulp build: runstylesandscriptstasksgulp watch: watch all changes in SASS files
Configure Authorization policies in the Admin UI
masterUse
services.AddAuthorizationPolicies()to manage authorization. This method contains the base policy for the AdminUI, and is the appropriate place to register additional policies for extending authorization capabilities.services.AddAuthorizationPolicies();Configure authentication for the Admin UI
masterUse the
AddAuthenticationServiceshelper method inStartup.csto register authentication. The Admin UI uses OpenIdConnect middleware connected to IdentityServer4.Note: In staging environments, cookie middleware is used for fake authentication. The fake login URL is
/Account/Login.services.AddAuthenticationServices<AdminIdentityDbContext, UserIdentity, UserIdentityRole>(HostingEnvironment, rootConfiguration.AdminConfiguration);Configure Localization and MVC in the STS
masterIn the
Skoruba.IdentityServer4.STS.Identityproject, use theAddMvcWithLocalizationextension method to register MVC and Localization. This method uses the Asp.Net Core Identity types for the generic controllers.services.AddMvcWithLocalization<UserIdentity, string>();Install .NET Core 3.1 SDK on Ubuntu 19.04
masterTo install the .NET Core 3.1 SDK on Ubuntu 19.04, register the Microsoft package repository and use
apt-getto install the SDK.wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb sudo apt-get update sudo apt-get install apt-transport-https sudo apt-get update sudo apt-get install dotnet-sdk-3.1Configure DbContexts for the Admin UI
masterIn the
Skoruba.IdentityServer4.Adminproject, use theAddDbContextshelper method withinStartup.cs(insideConfigureServices) to register the required DbContexts for the administration system.The following DbContexts are used:
AdminIdentityDbContext: For Asp.Net Core Identity.AdminLogDbContext: For logging.IdentityServerConfigurationDbContext: For the IdentityServer configuration store.IdentityServerPersistedGrantDbContext: For the IdentityServer operational store.
services.AddDbContexts<AdminIdentityDbContext, IdentityServerConfigurationDbContext, IdentityServerPersistedGrantDbContext, AdminLogDbContext>(HostingEnvironment, Configuration);Configure Administration for Ubuntu and PostgreSQL
masterFollow the tutorial for setting up the administration interface on Ubuntu using a PostgreSQL database.Install the Skoruba.IdentityServer4.Admin template
masterInstall the dotnet new template to create new projects using the Skoruba administration scaffolding. Note that version 2.0.0 and higher is compatible with IdentityServer4 version 4.
Warning: This version affects your database data if you use the default migrations. Ensure you have a database backup before proceeding.
dotnet new -i Skoruba.IdentityServer4.Admin.Templates::2.1.0Configure Localization and MVC in the Admin UI
masterRegister MVC and Localization using the
AddMvcWithLocalizationextension method. This method uses the same types as the Asp.Net Core Identity registration because these types are injected into generic Controllers.services.AddMvcWithLocalization<UserDto<string>, string, RoleDto<string>, string, string, string, UserIdentity, UserIdentityRole, string, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken, UsersDto<UserDto<string>, string>, RolesDto<RoleDto<string>, string>, UserRolesDto<RoleDto<string>, string, string>, UserClaimsDto<string>, UserProviderDto<string>, UserProvidersDto<string>, UserChangePasswordDto<string>, RoleClaimsDto<string>>();Configure Asp.Net Core Identity in the Admin UI
masterUse the
AddAdminAspNetIdentityServicesextension method to register all dependencies for managing Asp.Net Core Identity data.This is the recommended location to modify the Identity model, such as changing the primary key type from
stringto another type.services.AddAdminAspNetIdentityServices<AdminIdentityDbContext, IdentityServerPersistedGrantDbContext, UserDto<string>, string, RoleDto<string>, string, string, string, UserIdentity, UserIdentityRole, string, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken, UsersDto<UserDto<string>, string>, RolesDto<RoleDto<string>, string>, UserRolesDto<RoleDto<string>, string, string>, UserClaimsDto<string>, UserProviderDto<string>, UserProvidersDto<string>, UserChangePasswordDto<string>, RoleClaimsDto<string>, UserClaimDto<string>, RoleClaimDto<string>>();