├── .gitattributes ├── .gitignore ├── .vs ├── Identityserver4 │ └── v16 │ │ └── .suo ├── VSWorkspaceState.json ├── WQLIdentityServer │ ├── DesignTimeBuild │ │ ├── .dtbcache │ │ └── .dtbcache.v2 │ └── v16 │ │ ├── .suo │ │ ├── Server │ │ └── sqlite3 │ │ │ ├── db.lock │ │ │ └── storage.ide │ │ └── TestStore │ │ └── 0 │ │ ├── 000-0000.testlog │ │ └── testlog.manifest └── slnx.sqlite ├── LICENSE ├── README.en.md ├── README.md ├── WQLIdentity.Application.Test ├── ApiResourceServiceTest.cs ├── BaseUnitTest.cs ├── ClientServiceTest.cs ├── IdentityResourceServiceTest.cs ├── RoleServiceTest.cs ├── UserServiceTest.cs └── WQLIdentity.Application.Test.csproj ├── WQLIdentity.Application ├── Dtos │ ├── ApiResources │ │ ├── ApiResourceDto.cs │ │ ├── ApiResourceListDto.cs │ │ ├── ApiResourceMapping.cs │ │ ├── ApiScopeDto.cs │ │ ├── ApiScopeResourceDto.cs │ │ ├── CreateApiPropertiesDto.cs │ │ ├── CreateApiResouce.cs │ │ ├── CreateApiScopeDto.cs │ │ ├── CreateApiSecretDto.cs │ │ ├── UpdateApiResource.cs │ │ └── UpdateScopeDto.cs │ ├── ClaimViewDto.cs │ ├── Claims │ │ ├── ClaimsMapping.cs │ │ └── CreateClaimDto.cs │ ├── Clients │ │ ├── ClientClaimDto.cs │ │ ├── ClientDto.cs │ │ ├── ClientListDto.cs │ │ ├── ClientMapping.cs │ │ ├── ClientPropertyDto.cs │ │ ├── ClientSecretDto.cs │ │ ├── CreateClientDto.cs │ │ └── UpdateClientDto.cs │ ├── CreateUserOrRoleClaimDto.cs │ ├── ErrorMsgDto.cs │ ├── IdentityResources │ │ ├── CreateIdentityResourceDto.cs │ │ ├── IdentityResourceDto.cs │ │ ├── IdentityResourceListDto.cs │ │ ├── IdentityResourceMapping.cs │ │ └── IdentityResourcePropertyDto.cs │ ├── Roles │ │ ├── CreateRoleDto.cs │ │ ├── RoleListDto.cs │ │ ├── RoleMapping.cs │ │ └── UpdateRoleDto.cs │ └── UserManager │ │ ├── CreateUserDto.cs │ │ ├── PasswordDto.cs │ │ ├── UpdateUserDto.cs │ │ ├── UserDetailDto.cs │ │ ├── UserListDto.cs │ │ ├── UserMapping.cs │ │ └── UserRoleDto.cs ├── Interfaces │ ├── IApiResourceservice.cs │ ├── IApiScopeService.cs │ ├── IApplicationBaseService.cs │ ├── IClientAppService.cs │ ├── IIdentityResourceService.cs │ ├── IRoleAppService.cs │ ├── IUserAppService.cs │ └── IUserManagerService.cs ├── Services │ ├── ApiResourceService.cs │ ├── ApiScopeService.cs │ ├── ApplicationBaseService.cs │ ├── ClientAppService.cs │ ├── IdentityResourceService.cs │ ├── RoleAppService.cs │ └── UserAppService.cs └── WQLIdentity.Application.csproj ├── WQLIdentity.Domain ├── Entities │ ├── Claims.cs │ └── Entity.cs ├── Interface │ ├── IApplicationRepository.cs │ ├── IConfigurationRepository.cs │ └── IScopeRepository.cs └── WQLIdentity.Domain.csproj ├── WQLIdentity.Infra.Data.Mysql ├── Migrations │ ├── Application │ │ └── Mysql │ │ │ ├── 20190917041209_InitialCreate.Designer.cs │ │ │ ├── 20190917041209_InitialCreate.cs │ │ │ ├── 20201012034049_IdentityServer4_v4.Designer.cs │ │ │ ├── 20201012034049_IdentityServer4_v4.cs │ │ │ └── MysqlApplicationDbContextModelSnapshot.cs │ ├── Configuration │ │ └── Mysql │ │ │ ├── 20190917040000_InitialCreate.Designer.cs │ │ │ ├── 20190917040000_InitialCreate.cs │ │ │ ├── 20201012034012_IdentityServer4_v4.Designer.cs │ │ │ ├── 20201012034012_IdentityServer4_v4.cs │ │ │ └── MysqlConfigurationDbcontextModelSnapshot.cs │ └── PersistedGrant │ │ └── Mysql │ │ ├── 20190917040013_InitialCreate.Designer.cs │ │ ├── 20190917040013_InitialCreate.cs │ │ ├── 20201012034035_IdentityServer4_v4.Designer.cs │ │ ├── 20201012034035_IdentityServer4_v4.cs │ │ └── MysqlPersistedGrantDbcontextModelSnapshot.cs ├── MysqlApplicationDbContext.cs ├── MysqlConfigurationDbcontext.cs ├── MysqlPersistedGrantDbContext.cs ├── Repositorys │ ├── MysqlApiScopeRepository.cs │ ├── MysqlApplicationRepository.cs │ └── MysqlConfigurationRepository.cs └── WQLIdentity.Infra.Data.Mysql.csproj ├── WQLIdentity.Infra.Data ├── ApplicationDbContext.cs ├── CustomConfigurationDbContext.cs ├── CustomPersistedGrantDbContext.cs ├── Entities │ ├── ApplicationRole.cs │ └── ApplicationUser.cs ├── Migrations │ ├── Application │ │ └── SqlServer │ │ │ ├── 20190917065308_InitialCreate.Designer.cs │ │ │ ├── 20190917065308_InitialCreate.cs │ │ │ ├── 20201012010031_IdentityServer4_v4.Designer.cs │ │ │ ├── 20201012010031_IdentityServer4_v4.cs │ │ │ └── ApplicationDbContextModelSnapshot.cs │ ├── Configuration │ │ └── SqlServer │ │ │ ├── 20190917065237_InitialCreate.Designer.cs │ │ │ ├── 20190917065237_InitialCreate.cs │ │ │ ├── 20201012005922_IdentityServer4_v4.Designer.cs │ │ │ ├── 20201012005922_IdentityServer4_v4.cs │ │ │ └── ConfigurationDbContextModelSnapshot.cs │ └── PersistedGrant │ │ └── SqlServer │ │ ├── 20190917065254_InitialCreate.Designer.cs │ │ ├── 20190917065254_InitialCreate.cs │ │ ├── 20201012010008_IdentityServer4_v4.Designer.cs │ │ ├── 20201012010008_IdentityServer4_v4.cs │ │ └── PersistedGrantDbContextModelSnapshot.cs ├── Repository │ ├── ApiScopeRepository.cs │ ├── ApplicationRepository.cs │ ├── BaseRepository.cs │ └── ConfigurationRepository.cs └── WQLIdentity.Infra.Data.csproj ├── WQLIdentityServer.Infra ├── Dto │ ├── ClientType.cs │ ├── HashType.cs │ ├── PageInputDto.cs │ ├── Pagelist.cs │ └── SelectItemDto.cs ├── Extensions │ └── QueryableExtensions.cs ├── Helpers │ └── EnumHelpers.cs └── WQLIdentityServer.Infra.csproj ├── WQLIdentityServer.sln ├── WQLIdentityServer ├── Controllers │ └── HomeController.cs ├── Models │ └── ErrorViewModel.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── Views │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _CookieConsentPartial.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── WQLIdentityServer.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── WQLIdentityServerAPI ├── .config │ └── dotnet-tools.json ├── Config.cs ├── Configurations │ ├── AuthenticationConfig.cs │ ├── AutoMapperConfig.cs │ ├── AutofacModule.cs │ ├── ConfigurePolicy.cs │ ├── Consts │ │ ├── DatabaseConst.cs │ │ └── PolicyConst.cs │ ├── CorsConfig.cs │ ├── DataBaseConfig.cs │ ├── IdentityConfig.cs │ ├── IdentityServerConfig.cs │ ├── MiniProfilerConfig.cs │ ├── SameSiteHandlingExtensions.cs │ └── SwaggerConfig.cs ├── Controllers │ ├── ApiResourceController.cs │ ├── ApiScopeController.cs │ ├── BaseApiController.cs │ ├── ClaimsController.cs │ ├── ClientController.cs │ ├── IdentityResourceController.cs │ ├── InfrastructureController.cs │ ├── Quickstart │ │ ├── Account │ │ │ ├── AccountController.cs │ │ │ ├── AccountOptions.cs │ │ │ ├── ExternalController.cs │ │ │ ├── ExternalProvider.cs │ │ │ ├── LoggedOutViewModel.cs │ │ │ ├── LoginInputModel.cs │ │ │ ├── LoginViewModel.cs │ │ │ ├── LogoutInputModel.cs │ │ │ ├── LogoutViewModel.cs │ │ │ └── RedirectViewModel.cs │ │ ├── Consent │ │ │ ├── ConsentController.cs │ │ │ ├── ConsentInputModel.cs │ │ │ ├── ConsentOptions.cs │ │ │ ├── ConsentViewModel.cs │ │ │ ├── ProcessConsentResult.cs │ │ │ └── ScopeViewModel.cs │ │ ├── Device │ │ │ ├── DeviceAuthorizationInputModel.cs │ │ │ ├── DeviceAuthorizationViewModel.cs │ │ │ └── DeviceController.cs │ │ ├── Diagnostics │ │ │ ├── DiagnosticsController.cs │ │ │ └── DiagnosticsViewModel.cs │ │ ├── Extensions.cs │ │ ├── Grants │ │ │ ├── GrantsController.cs │ │ │ └── GrantsViewModel.cs │ │ ├── Home │ │ │ ├── ErrorViewModel.cs │ │ │ └── HomeController.cs │ │ ├── SecurityHeadersAttribute.cs │ │ └── TestUsers.cs │ ├── RoleAppController.cs │ ├── TestValueController.cs │ └── UserAppController.cs ├── Filters │ └── PermissionAuthorize.cs ├── IdentityServers │ ├── CustomProfileService.cs │ ├── CustomResourceOwnerPasswordValidtor.cs │ ├── Services │ │ ├── AuthCodeService.cs │ │ └── IAuthCodeService.cs │ └── SmsAuthCodeValidator.cs ├── LICENSE ├── Middleware │ ├── AllServicesMildd.cs │ ├── DateTimeConverter.cs │ └── Exceptions │ │ ├── CustomExceptionMiddlewareExtensions.cs │ │ └── CustomExceptionMidlleware.cs ├── Models │ ├── DefaultReponse.cs │ ├── Identity │ │ └── AuthorizeClaims.cs │ └── SettingOptions.cs ├── NLog.config ├── Program.cs ├── Properties │ ├── PublishProfiles │ │ ├── FolderProfile.pubxml │ │ ├── FolderProfile.pubxml.user │ │ ├── FolderProfile1.pubxml │ │ └── FolderProfile1.pubxml.user │ ├── Resources.Designer.cs │ ├── Resources.resx │ └── launchSettings.json ├── SeedData │ ├── AuthorizationConsts.cs │ └── EnsureSeedData.cs ├── Services │ └── ProfileService.cs ├── Startup.cs ├── Views │ ├── Account │ │ ├── AccessDenied.cshtml │ │ ├── LoggedOut.cshtml │ │ ├── Login.cshtml │ │ └── Logout.cshtml │ ├── Consent │ │ └── Index.cshtml │ ├── Device │ │ ├── Success.cshtml │ │ ├── UserCodeCapture.cshtml │ │ └── UserCodeConfirmation.cshtml │ ├── Diagnostics │ │ └── Index.cshtml │ ├── Grants │ │ └── Index.cshtml │ ├── Home │ │ └── Index.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── Redirect.cshtml │ │ ├── _Layout.cshtml │ │ ├── _Nav.cshtml │ │ ├── _ScopeListItem.cshtml │ │ └── _ValidationSummary.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── WQLIdentityServerAPI.csproj ├── WQLIdentityServerAPI.csproj.user ├── appsettings.Development.json ├── appsettings.json ├── getmaster.ps1 ├── getmaster.sh ├── gulpfile.js ├── package-lock.json ├── package.json ├── swaggerIndex.html ├── tempkey.jwk ├── tempkey.rsa └── wwwroot │ ├── css │ ├── app.min.css │ ├── site.css │ └── site.scss │ ├── favicon.ico │ ├── icon.jpg │ ├── icon.png │ └── js │ ├── app.min.js │ ├── signin-redirect.js │ └── signout-redirect.js ├── WQLIdentityTestFaker ├── ApiResourceFaker.cs ├── IdentityHelpers.cs └── WQLIdentityTestFaker.csproj ├── Web └── IdentityServerSites │ ├── .env │ ├── .env.production │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── babel.config.js │ ├── package-lock.json │ ├── package.json │ ├── public │ ├── favicon.ico │ └── index.html │ ├── src │ ├── App.vue │ ├── assets │ │ └── imgs │ │ │ ├── back.jpg │ │ │ └── wqlapi.png │ ├── components │ │ ├── Breadcrumb │ │ │ └── index.vue │ │ ├── Hamburger │ │ │ └── index.vue │ │ ├── HelloWorld.vue │ │ ├── SignedInUser.vue │ │ ├── SvgIcon │ │ │ └── index.vue │ │ └── modules │ │ │ ├── ApiProperties.vue │ │ │ ├── ApiResourceEdit.vue │ │ │ ├── ApiScopes.vue │ │ │ ├── ApiSecret.vue │ │ │ ├── ClaimCreate.vue │ │ │ ├── ClaimEdit.vue │ │ │ ├── ClientCreate.vue │ │ │ ├── ClientEdit.vue │ │ │ ├── RoleEdit.vue │ │ │ └── UserEdit.vue │ ├── config │ │ └── oidc.js │ ├── icons │ │ ├── index.js │ │ ├── svg │ │ │ ├── dashboard.svg │ │ │ ├── example.svg │ │ │ ├── eye-open.svg │ │ │ ├── eye.svg │ │ │ ├── form.svg │ │ │ ├── link.svg │ │ │ ├── nested.svg │ │ │ ├── password.svg │ │ │ ├── table.svg │ │ │ ├── tree.svg │ │ │ ├── user.svg │ │ │ └── wqlapi.svg │ │ └── svgo.yml │ ├── layout │ │ ├── components │ │ │ ├── AppMain.vue │ │ │ ├── Navbar.vue │ │ │ ├── Sidebar │ │ │ │ ├── FixiOSBug.js │ │ │ │ ├── Item.vue │ │ │ │ ├── Link.vue │ │ │ │ ├── Logo.vue │ │ │ │ ├── SidebarItem.vue │ │ │ │ └── index.vue │ │ │ └── index.js │ │ ├── index.vue │ │ └── mixin │ │ │ └── ResizeHandler.js │ ├── main.js │ ├── plugin │ │ └── http.js │ ├── router.js │ ├── services │ │ ├── SecurityService.js │ │ └── uilts.js │ ├── settings.js │ ├── silent-renew-oidc.js │ ├── store │ │ ├── getters.js │ │ ├── index.js │ │ └── modules │ │ │ ├── app.js │ │ │ ├── settings.js │ │ │ └── user.js │ ├── styles │ │ ├── element-ui.scss │ │ ├── index.scss │ │ ├── mixin.scss │ │ ├── sidebar.scss │ │ ├── transition.scss │ │ └── variables.scss │ ├── utils │ │ ├── auth.js │ │ ├── get-page-title.js │ │ ├── index.js │ │ ├── request.js │ │ └── validate.js │ └── views │ │ ├── About.vue │ │ ├── AccessDenied.vue │ │ ├── ApiResources.vue │ │ ├── ClaimManagement.vue │ │ ├── Client.vue │ │ ├── Home.vue │ │ ├── IdentityResource.vue │ │ ├── Login.vue │ │ ├── RoleManagement.vue │ │ ├── UserManagement.vue │ │ ├── Userinfo.vue │ │ └── oidcs │ │ ├── Callback.vue │ │ ├── OidcCallbackError.vue │ │ ├── OidcPopupCallback.vue │ │ └── Protected.vue │ ├── vue.config.js │ └── yarn.lock ├── auth.rp └── doc └── imgs ├── client.bmp └── server.bmp /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | npm-debug.log 4 | 5 | # Build results 6 | [Dd]ebug/ 7 | [Dd]ebugPublic/ 8 | [Rr]elease/ 9 | [Rr]eleases/ 10 | x64/ 11 | x86/ 12 | [Aa][Rr][Mm]/ 13 | [Aa][Rr][Mm]64/ 14 | bld/ 15 | [Bb]in/ 16 | [Oo]bj/ 17 | [Ll]og/ 18 | /.svn 19 | /.vs/WQLIdentityServer/DesignTimeBuild 20 | -------------------------------------------------------------------------------- /.vs/Identityserver4/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/.vs/Identityserver4/v16/.suo -------------------------------------------------------------------------------- /.vs/VSWorkspaceState.json: -------------------------------------------------------------------------------- 1 | { 2 | "ExpandedNodes": [ 3 | "" 4 | ], 5 | "PreviewInSolutionExplorer": false 6 | } -------------------------------------------------------------------------------- /.vs/WQLIdentityServer/DesignTimeBuild/.dtbcache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/.vs/WQLIdentityServer/DesignTimeBuild/.dtbcache -------------------------------------------------------------------------------- /.vs/WQLIdentityServer/DesignTimeBuild/.dtbcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/.vs/WQLIdentityServer/DesignTimeBuild/.dtbcache.v2 -------------------------------------------------------------------------------- /.vs/WQLIdentityServer/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/.vs/WQLIdentityServer/v16/.suo -------------------------------------------------------------------------------- /.vs/WQLIdentityServer/v16/Server/sqlite3/db.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/.vs/WQLIdentityServer/v16/Server/sqlite3/db.lock -------------------------------------------------------------------------------- /.vs/WQLIdentityServer/v16/Server/sqlite3/storage.ide: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/.vs/WQLIdentityServer/v16/Server/sqlite3/storage.ide -------------------------------------------------------------------------------- /.vs/WQLIdentityServer/v16/TestStore/0/000-0000.testlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/.vs/WQLIdentityServer/v16/TestStore/0/000-0000.testlog -------------------------------------------------------------------------------- /.vs/WQLIdentityServer/v16/TestStore/0/testlog.manifest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/.vs/WQLIdentityServer/v16/TestStore/0/testlog.manifest -------------------------------------------------------------------------------- /.vs/slnx.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/.vs/slnx.sqlite -------------------------------------------------------------------------------- /README.en.md: -------------------------------------------------------------------------------- 1 | # IdentityServer4 统一授权认证系统 2 | 3 | #### Description 4 | 基于ASP.NET CORE+IdentityServer4+Vue+Sqlserver 的统一授权认证系统,包含系统管理界面。 5 | 6 | #### Software Architecture 7 | Software architecture description 8 | 9 | #### Installation 10 | 11 | 1. xxxx 12 | 2. xxxx 13 | 3. xxxx 14 | 15 | #### Instructions 16 | 17 | 1. xxxx 18 | 2. xxxx 19 | 3. xxxx 20 | 21 | #### Contribution 22 | 23 | 1. Fork the repository 24 | 2. Create Feat_xxx branch 25 | 3. Commit your code 26 | 4. Create Pull Request 27 | 28 | 29 | #### Gitee Feature 30 | 31 | 1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md 32 | 2. Gitee blog [blog.gitee.com](https://blog.gitee.com) 33 | 3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) 34 | 4. The most valuable open source project [GVP](https://gitee.com/gvp) 35 | 5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) 36 | 6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) -------------------------------------------------------------------------------- /WQLIdentity.Application.Test/ApiResourceServiceTest.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using IdentityServer4.EntityFramework.Entities; 3 | using Moq; 4 | using System; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using WQLIdentity.Application.Dtos.ApiResources; 8 | using WQLIdentity.Application.Interfaces; 9 | using WQLIdentity.Application.Services; 10 | using WQLIdentityServer.Infra.Dto; 11 | using WQLIdentityTestFaker; 12 | using Xunit; 13 | 14 | namespace WQLIdentity.Application.Test 15 | { 16 | public class ApiResourceServiceTest:BaseUnitTest 17 | { 18 | private IApiResourceService service; 19 | 20 | 21 | 22 | public ApiResourceServiceTest() 23 | { 24 | MockApiresourceRepo.Setup(d => d.GetAll()).Returns(ApiResourceFaker.GenerateApiResource().Generate(5).AsQueryable()); 25 | 26 | //remove 27 | MockApiresourceRepo.Setup(s => s.GetByIdAsync(It.Is(d => d == 999))).ReturnsAsync(ApiResourceFaker.GenerateApiResource().Generate()); 28 | MockApiresourceRepo.Setup(s => s.Remove(It.IsAny())); 29 | 30 | Mapper = new MapperConfiguration(cfg => 31 | { 32 | cfg.AddProfile(new ApiResourceMapping()); 33 | cfg.CreateMap(typeof(Pagelist<>), typeof(Pagelist<>)); 34 | 35 | }); 36 | 37 | service = new ApiResourceService(MockApiresourceRepo.Object, MockApiScopeRepo.Object, MockApiresourceSecretRepo.Object, MockApiresourcePropertyRepo.Object, Mapper.CreateMapper()); 38 | } 39 | [Fact] 40 | public void Get_ApiResource_MapTo_ApiResourceList() 41 | { 42 | var list= service.GetApiResources(PageInput); 43 | 44 | Assert.Equal(5, list.TotalCount); 45 | } 46 | 47 | 48 | 49 | 50 | [Fact] 51 | public async void Should_Remove_ApiResource() 52 | { 53 | 54 | var result= await service.Remove(999); 55 | 56 | MockApiresourceRepo.Setup(s => s.SaveChangesAsync()).ReturnsAsync(1); 57 | 58 | MockApiresourceRepo.Verify(d => d.GetByIdAsync(999), Times.Once); 59 | MockApiresourceRepo.Verify(s => s.Remove(It.IsAny()), Times.Once); 60 | 61 | } 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /WQLIdentity.Application.Test/BaseUnitTest.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using IdentityServer4.EntityFramework.Entities; 3 | using Moq; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using WQLIdentity.Domain.Interface; 8 | using WQLIdentityServer.Infra.Dto; 9 | using Xunit; 10 | 11 | namespace WQLIdentity.Application.Test 12 | { 13 | public class BaseUnitTest 14 | { 15 | protected Mock> MockApiresourceRepo; 16 | protected Mock> MockApiScopeRepo; 17 | protected Mock> MockApiresourceSecretRepo; 18 | protected Mock> MockApiresourcePropertyRepo; 19 | 20 | protected PageInputDto PageInput; 21 | 22 | 23 | protected virtual MapperConfiguration Mapper { get; set; } 24 | public BaseUnitTest() 25 | { 26 | MockApiresourceRepo = new Mock>(); 27 | MockApiScopeRepo = new Mock>(); 28 | MockApiresourceSecretRepo = new Mock>(); 29 | MockApiresourcePropertyRepo = new Mock>(); 30 | 31 | PageInput = new PageInputDto() 32 | { 33 | Search = "", 34 | PageSize = 10, 35 | Page = 0, 36 | }; 37 | 38 | 39 | Mapper = new MapperConfiguration(cfg=> { }); 40 | } 41 | 42 | [Fact] 43 | public void Should_Valid_AtuoMap_Configuration() 44 | { 45 | Mapper.AssertConfigurationIsValid(); 46 | } 47 | 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /WQLIdentity.Application.Test/ClientServiceTest.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using WQLIdentity.Application.Dtos.Clients; 6 | using WQLIdentityServer.Infra.Dto; 7 | 8 | namespace WQLIdentity.Application.Test 9 | { 10 | public class ClientServiceTest : BaseUnitTest 11 | { 12 | 13 | 14 | public ClientServiceTest() 15 | { 16 | Mapper = new MapperConfiguration(cfg => 17 | { 18 | cfg.AddProfile(new ClientMapping()); 19 | cfg.CreateMap(typeof(Pagelist<>), typeof(Pagelist<>)); 20 | 21 | }); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /WQLIdentity.Application.Test/IdentityResourceServiceTest.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using WQLIdentity.Application.Dtos.IdentityResources; 6 | using WQLIdentityServer.Infra.Dto; 7 | 8 | namespace WQLIdentity.Application.Test 9 | { 10 | public class IdentityResourceServiceTest:BaseUnitTest 11 | { 12 | public IdentityResourceServiceTest() 13 | { 14 | Mapper = new MapperConfiguration(cfg => 15 | { 16 | cfg.AddProfile(new IdentityResourceMapping()); 17 | cfg.CreateMap(typeof(Pagelist<>), typeof(Pagelist<>)); 18 | 19 | }); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WQLIdentity.Application.Test/RoleServiceTest.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using WQLIdentity.Application.Dtos.Roles; 6 | using WQLIdentityServer.Infra.Dto; 7 | 8 | namespace WQLIdentity.Application.Test 9 | { 10 | public class RoleServiceTest:BaseUnitTest 11 | { 12 | public RoleServiceTest() 13 | { 14 | Mapper = new MapperConfiguration(cfg => 15 | { 16 | cfg.AddProfile(new RoleMapping()); 17 | cfg.CreateMap(typeof(Pagelist<>), typeof(Pagelist<>)); 18 | 19 | }); 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /WQLIdentity.Application.Test/UserServiceTest.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using WQLIdentity.Application.Dtos.UserManager; 6 | using WQLIdentityServer.Infra.Dto; 7 | 8 | namespace WQLIdentity.Application.Test 9 | { 10 | public class UserServiceTest:BaseUnitTest 11 | { 12 | public UserServiceTest() 13 | { 14 | Mapper = new MapperConfiguration(cfg => 15 | { 16 | cfg.AddProfile(new UserMapping()); 17 | cfg.CreateMap(typeof(Pagelist<>), typeof(Pagelist<>)); 18 | 19 | }); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WQLIdentity.Application.Test/WQLIdentity.Application.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/ApiResourceDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace WQLIdentity.Application.Dtos.ApiResources 5 | { 6 | public class ApiResourceDto 7 | { 8 | 9 | public int Id { get; set; } 10 | public bool Enabled { get; set; } 11 | public string Name { get; set; } 12 | public string DisplayName { get; set; } 13 | public string Description { get; set; } 14 | 15 | public List UserClaims { get; set; } 16 | 17 | public DateTime Created { get; set; } 18 | public DateTime? Updated { get; set; } 19 | public DateTime? LastAccessed { get; set; } 20 | public bool NonEditable { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/ApiResourceListDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WQLIdentity.Application.Dtos.ApiResources 4 | { 5 | public class ApiResourceListDto 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | public string Description { get; set; } 10 | public DateTime Created { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/ApiResourceMapping.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using IdentityServer4.EntityFramework.Entities; 3 | using System.Linq; 4 | 5 | namespace WQLIdentity.Application.Dtos.ApiResources 6 | { 7 | public class ApiResourceMapping : Profile 8 | { 9 | public ApiResourceMapping() 10 | { 11 | CreateMap(MemberList.Source).ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(x => new ApiResourceClaim { Type = x }))); 12 | 13 | CreateMap(MemberList.Source).ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(x => new ApiResourceClaim { Type = x }))); 14 | //CreateMap().ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(c=>c.Type) )); 15 | 16 | CreateMap(MemberList.Destination).ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(c => c.Type))); 17 | 18 | CreateMap(MemberList.Destination); 19 | 20 | //apiscope 21 | CreateMap(MemberList.None).ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(c => c.Type))); 22 | CreateMap(MemberList.None).ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(x => new ApiScopeClaim { Type = x }))); 23 | CreateMap(MemberList.None).ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(x => new ApiScopeClaim { Type = x }))); 24 | 25 | 26 | 27 | //apiscret 28 | CreateMap(MemberList.None); 29 | CreateMap(MemberList.None); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/ApiScopeDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WQLIdentity.Application.Dtos.ApiResources 4 | { 5 | public class ApiScopeDto 6 | { 7 | public int Id { get; set; } 8 | public bool Enabled { get; set; } 9 | public string Name { get; set; } 10 | public string DisplayName { get; set; } 11 | public string Description { get; set; } 12 | public bool Required { get; set; } 13 | public bool Emphasize { get; set; } 14 | public bool ShowInDiscoveryDocument { get; set; } 15 | public List UserClaims { get; set; } 16 | public int ApiResourceId { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/ApiScopeResourceDto.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using IdentityServer4.EntityFramework.Entities; 3 | 4 | namespace WQLIdentity.Application.Dtos.ApiResources 5 | { 6 | [AutoMap(typeof(ApiResourceScope))] 7 | public class ApiScopeResourceDto 8 | { 9 | public int ResourceId { get; set; } 10 | public string ScopeName { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/CreateApiPropertiesDto.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace WQLIdentity.Application.Dtos.ApiResources 4 | { 5 | public class CreateApiPropertiesDto 6 | { 7 | public int ApiResourceId { get; set; } 8 | 9 | 10 | [Required] 11 | public string Key { get; set; } 12 | 13 | [Required] 14 | public string Value { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/CreateApiResouce.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WQLIdentity.Application.Dtos.ApiResources 4 | { 5 | public class CreateApiResouce 6 | { 7 | 8 | public bool Enabled { get; set; } 9 | public string Name { get; set; } 10 | public string DisplayName { get; set; } 11 | public string Description { get; set; } 12 | public List UserClaims { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/CreateApiScopeDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WQLIdentity.Application.Dtos.ApiResources 4 | { 5 | public class CreateApiScopeDto 6 | { 7 | public string Name { get; set; } 8 | public string DisplayName { get; set; } 9 | public string Description { get; set; } 10 | public bool Required { get; set; } 11 | public bool Emphasize { get; set; } 12 | public bool ShowInDiscoveryDocument { get; set; } 13 | public List UserClaims { get; set; } 14 | public int ApiResourceId { get; set; } 15 | 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/CreateApiSecretDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | using WQLIdentityServer.Infra.Dto; 4 | 5 | namespace WQLIdentity.Application.Dtos.ApiResources 6 | { 7 | public class CreateApiSecretDto 8 | { 9 | public string Description { get; set; } 10 | [Required] 11 | public string Value { get; set; } 12 | public DateTime? Expiration { get; set; } 13 | [Required] 14 | public HashType? Hash { get; set; } = 0; 15 | [Required] 16 | public string Type { get; set; } 17 | public int ApiResourceId { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/UpdateApiResource.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WQLIdentity.Application.Dtos.ApiResources 4 | { 5 | public class UpdateApiResource 6 | { 7 | public int Id { get; set; } 8 | public bool Enabled { get; set; } 9 | public string Name { get; set; } 10 | public string DisplayName { get; set; } 11 | public string Description { get; set; } 12 | public List UserClaims { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ApiResources/UpdateScopeDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WQLIdentity.Application.Dtos.ApiResources 4 | { 5 | public class UpdateScopeDto 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | public string DisplayName { get; set; } 10 | public string Description { get; set; } 11 | public bool Required { get; set; } 12 | public bool Emphasize { get; set; } 13 | public bool ShowInDiscoveryDocument { get; set; } 14 | public List UserClaims { get; set; } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ClaimViewDto.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace WQLIdentity.Application.Dtos 4 | { 5 | public class ClaimViewDto 6 | { 7 | [Required] 8 | public string Value { get; set; } 9 | [Required] 10 | public string Type { get; set; } 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Claims/ClaimsMapping.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | 3 | namespace WQLIdentity.Application.Dtos.Claims 4 | { 5 | public class ClaimsMapping : Profile 6 | { 7 | public ClaimsMapping() 8 | { 9 | CreateMap(MemberList.Source); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Claims/CreateClaimDto.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace WQLIdentity.Application.Dtos.Claims 4 | { 5 | public class CreateClaimDto 6 | { 7 | [Required] 8 | public string Type { get; set; } 9 | [Required] 10 | public string Value { get; set; } 11 | [Required] 12 | public string Description { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Clients/ClientClaimDto.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace WQLIdentity.Application.Dtos.Clients 4 | { 5 | public class ClientClaimDto 6 | { 7 | public int Id { get; set; } 8 | 9 | [Required] 10 | public string Type { get; set; } 11 | 12 | [Required] 13 | public string Value { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Clients/ClientListDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Application.Dtos.Clients 2 | { 3 | public class ClientListDto 4 | { 5 | public int Id { get; set; } 6 | /// 7 | /// Unique ID of the client 8 | /// 9 | public string ClientId { get; set; } 10 | /// 11 | /// Client display name (used for logging and consent screen) 12 | /// 13 | public string ClientName { get; set; } 14 | /// 15 | /// Specifies if client is enabled (defaults to true) 16 | /// 17 | public bool Enabled { get; set; } 18 | /// 19 | /// URI to client logo (used on consent screen) 20 | /// 21 | public string LogoUri { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Clients/ClientPropertyDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Application.Dtos.Clients 2 | { 3 | public class ClientPropertyDto 4 | { 5 | public int Id { get; set; } 6 | public string Key { get; set; } 7 | public string Value { get; set; } 8 | public int ClientId { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Clients/ClientSecretDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | using WQLIdentityServer.Infra.Dto; 4 | 5 | namespace WQLIdentity.Application.Dtos.Clients 6 | { 7 | public class ClientSecretDto 8 | { 9 | [Required] 10 | public string Type { get; set; } 11 | 12 | public int Id { get; set; } 13 | 14 | public string Description { get; set; } 15 | [Required] 16 | public HashType? Hash { get; set; } = 0; 17 | [Required] 18 | public string Value { get; set; } 19 | 20 | public DateTime? Expiration { get; set; } 21 | [Required] 22 | public int ClientId { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Clients/CreateClientDto.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | using WQLIdentityServer.Infra.Dto; 3 | 4 | namespace WQLIdentity.Application.Dtos.Clients 5 | { 6 | public class CreateClientDto 7 | { 8 | [Required] 9 | public string ClientName { get; set; } 10 | [Required] 11 | public string ClientId { get; set; } 12 | public ClientType ClientType { get; set; } = 0; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/CreateUserOrRoleClaimDto.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace WQLIdentity.Application.Dtos 4 | { 5 | public class CreateUserOrRoleClaimDto 6 | { 7 | [Required] 8 | public string Value { get; set; } 9 | [Required] 10 | public string Type { get; set; } 11 | [Required] 12 | public string Id { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/ErrorMsgDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Application.Dtos 2 | { 3 | public class ErrorMsgDto 4 | { 5 | public string Name { get; set; } 6 | public string Message { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/IdentityResources/CreateIdentityResourceDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WQLIdentity.Application.Dtos.IdentityResources 4 | { 5 | public class CreateIdentityResourceDto 6 | { 7 | public int Id { get; set; } 8 | public bool Enabled { get; set; } 9 | public string Name { get; set; } 10 | public string DisplayName { get; set; } 11 | public string Description { get; set; } 12 | public bool Required { get; set; } 13 | public bool Emphasize { get; set; } 14 | public bool ShowInDiscoveryDocument { get; set; } 15 | public List UserClaims { get; set; } 16 | 17 | public bool NonEditable { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/IdentityResources/IdentityResourceDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace WQLIdentity.Application.Dtos.IdentityResources 5 | { 6 | public class IdentityResourceDto 7 | { 8 | public int Id { get; set; } 9 | public bool Enabled { get; set; } 10 | public string Name { get; set; } 11 | public string DisplayName { get; set; } 12 | public string Description { get; set; } 13 | public bool Required { get; set; } 14 | public bool Emphasize { get; set; } 15 | public bool ShowInDiscoveryDocument { get; set; } 16 | public List UserClaims { get; set; } 17 | 18 | public DateTime Created { get; set; } 19 | public DateTime? Updated { get; set; } 20 | public bool NonEditable { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/IdentityResources/IdentityResourceListDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WQLIdentity.Application.Dtos.IdentityResources 4 | { 5 | public class IdentityResourceListDto 6 | { 7 | public int Id { get; set; } 8 | public bool Enabled { get; set; } 9 | public string Name { get; set; } 10 | 11 | public string Description { get; set; } 12 | public DateTime Created { get; set; } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/IdentityResources/IdentityResourceMapping.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using IdentityServer4.EntityFramework.Entities; 3 | using System.Linq; 4 | 5 | namespace WQLIdentity.Application.Dtos.IdentityResources 6 | { 7 | public class IdentityResourceMapping : Profile 8 | { 9 | public IdentityResourceMapping() 10 | { 11 | 12 | 13 | 14 | CreateMap(MemberList.None).ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(x => new IdentityResourceClaim { Type = x }))); 15 | 16 | 17 | CreateMap(MemberList.Destination) 18 | .ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(x => x.Type))); 19 | 20 | 21 | 22 | CreateMap(MemberList.None); 23 | 24 | CreateMap(MemberList.None); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/IdentityResources/IdentityResourcePropertyDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Application.Dtos.IdentityResources 2 | { 3 | public class IdentityResourcePropertyDto 4 | { 5 | public int IdentityResourceId { get; set; } 6 | public string Key { get; set; } 7 | public string Value { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Roles/CreateRoleDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Application.Dtos.Roles 2 | { 3 | public class CreateRoleDto 4 | { 5 | public string Name { get; set; } 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Roles/RoleListDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WQLIdentity.Application.Dtos.Roles 4 | { 5 | public class RoleListDto 6 | { 7 | public string Id { get; set; } 8 | public string Name { get; set; } 9 | public DateTime CreatedOn { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Roles/RoleMapping.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using WQLIdentity.Infra.Data.Entities; 3 | 4 | namespace WQLIdentity.Application.Dtos.Roles 5 | { 6 | public class RoleMapping : Profile 7 | { 8 | public RoleMapping() 9 | { 10 | CreateMap(MemberList.None); 11 | CreateMap(MemberList.None); 12 | CreateMap(MemberList.None); 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/Roles/UpdateRoleDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Application.Dtos.Roles 2 | { 3 | public class UpdateRoleDto 4 | { 5 | public string Id { get; set; } 6 | public string Name { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/UserManager/CreateUserDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace WQLIdentity.Application.Dtos.UserManager 5 | { 6 | public class CreateUserDto 7 | { 8 | [Required] 9 | [RegularExpression(@"^[a-zA-Z0-9_@\-\.\+]+$")] 10 | public string UserName { get; set; } 11 | [Required] 12 | [DataType(DataType.Password)] 13 | [Display(Name = "Password")] 14 | public string Password { get; set; } 15 | 16 | [DataType(DataType.Password)] 17 | [Display(Name = "Confirm password")] 18 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 19 | public string ConfirmPassword { get; set; } 20 | 21 | public string Picture { get; set; } 22 | 23 | [Required] 24 | [EmailAddress] 25 | public string Email { get; set; } 26 | 27 | public bool EmailConfirmed { get; set; } 28 | 29 | public string PhoneNumber { get; set; } 30 | 31 | public bool PhoneNumberConfirmed { get; set; } 32 | 33 | public bool LockoutEnabled { get; set; } 34 | 35 | public bool TwoFactorEnabled { get; set; } 36 | 37 | public string AccessFailedCount { get; set; } 38 | 39 | public string Name { get; set; } 40 | 41 | public string Department { get; set; } 42 | public DateTimeOffset? LockoutEnd { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/UserManager/PasswordDto.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace WQLIdentity.Application.Dtos.UserManager 4 | { 5 | public class PasswordDto 6 | { 7 | [Required] 8 | public string UserId { get; set; } 9 | [Required] 10 | public string OldPassword { get; set; } 11 | [Required] 12 | public string NewPassword { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/UserManager/UpdateUserDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Application.Dtos.UserManager 2 | { 3 | public class UpdateUserDto 4 | { 5 | public string Id { get; set; } 6 | 7 | public string UserName { get; set; } 8 | public string Name { get; set; } 9 | public string Department { get; set; } 10 | public string Picture { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/UserManager/UserDetailDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WQLIdentity.Application.Dtos.UserManager 4 | { 5 | public class UserDetailDto 6 | { 7 | 8 | public string UserName { get; set; } 9 | 10 | 11 | 12 | 13 | public string Picture { get; set; } 14 | 15 | public string Email { get; set; } 16 | 17 | 18 | 19 | public string PhoneNumber { get; set; } 20 | 21 | 22 | public bool LockoutEnabled { get; set; } 23 | 24 | public bool TwoFactorEnabled { get; set; } 25 | 26 | public string AccessFailedCount { get; set; } 27 | 28 | public string Name { get; set; } 29 | 30 | public string Department { get; set; } 31 | public DateTime CreatedOn { get; } 32 | 33 | public DateTimeOffset? LockoutEnd { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/UserManager/UserListDto.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using System; 3 | using System.ComponentModel; 4 | using WQLIdentity.Infra.Data.Entities; 5 | 6 | namespace WQLIdentity.Application.Dtos.UserManager 7 | { 8 | [AutoMap(typeof(ApplicationUser))] 9 | public class UserListDto 10 | { 11 | public string Id { get; set; } 12 | public string UserName { get; set; } 13 | public DateTime CreatedOn { get; set; } 14 | public string Name { get; set; } 15 | public string Picture { get; set; } 16 | 17 | public string Department { get; set; } 18 | public string Email { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/UserManager/UserMapping.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using WQLIdentity.Infra.Data.Entities; 3 | 4 | namespace WQLIdentity.Application.Dtos.UserManager 5 | { 6 | public class UserMapping : Profile 7 | { 8 | public UserMapping() 9 | { 10 | CreateMap(MemberList.None); 11 | CreateMap(MemberList.None); 12 | CreateMap(MemberList.None); 13 | 14 | CreateMap(MemberList.None); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Dtos/UserManager/UserRoleDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Application.Dtos.UserManager 2 | { 3 | public class UserRoleDto 4 | { 5 | public string UserId { get; set; } 6 | public string RoleName { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Interfaces/IApiResourceservice.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.Entities; 2 | using System.Threading.Tasks; 3 | using WQLIdentity.Application.Dtos.ApiResources; 4 | using WQLIdentityServer.Infra.Dto; 5 | 6 | namespace WQLIdentity.Application.Interfaces 7 | { 8 | public interface IApiResourceService 9 | { 10 | Pagelist GetApiResources(PageInputDto pageInput); 11 | Task GetApiResource(int Id); 12 | Task CreateApiResource(CreateApiResouce model); 13 | Task Update(UpdateApiResource model); 14 | Task Remove(int Id); 15 | 16 | Pagelist GetScopes(PageInputDto pageInput, int apiresourceId); 17 | 18 | Task AddScope(ApiScopeResourceDto apiScope); 19 | Task RemoveScope(ApiScopeResourceDto apiScope); 20 | 21 | 22 | Pagelist GetSecrets(PageInputDto pageInput, int apiresourceId); 23 | Task RemoveSecret(int secretId); 24 | Task AddSecret(CreateApiSecretDto apiScope); 25 | 26 | Pagelist GetProperties(PageInputDto pageInput, int apiresourceId); 27 | Task RemovePropertiest(int secretId); 28 | Task AddProperties(CreateApiPropertiesDto apiScope); 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Interfaces/IApiScopeService.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.Entities; 2 | using System.Threading.Tasks; 3 | using WQLIdentity.Application.Dtos.ApiResources; 4 | 5 | namespace WQLIdentity.Application.Interfaces 6 | { 7 | public interface IApiScopeService 8 | { 9 | Task GetScope(string scopeName); 10 | Task AddApiScope(ApiScopeDto apiScope); 11 | 12 | Task UpdateApiScope(ApiScopeDto apiScope); 13 | 14 | Task RemoveApiScope(ApiScopeDto apiScope); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Interfaces/IApplicationBaseService.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading.Tasks; 3 | using WQLIdentity.Domain.Entities; 4 | using WQLIdentityServer.Infra.Dto; 5 | 6 | namespace WQLIdentity.Application.Interfaces 7 | { 8 | public interface IApplicationBaseService where TEntity : Entity 9 | { 10 | bool Add(TEntity obj); 11 | TEntity GetById(T id); 12 | IQueryable GetAll(); 13 | Pagelist GetAll(PageInputDto input); 14 | bool Update(TEntity obj); 15 | bool Remove(T id); 16 | int SaveChanges(); 17 | Task AddAsync(TEntity obj); 18 | Task GetByIdAsync(T id); 19 | Task SaveChangesAsync(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Interfaces/IClientAppService.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using WQLIdentity.Application.Dtos.Clients; 3 | using WQLIdentityServer.Infra.Dto; 4 | 5 | namespace WQLIdentity.Application.Interfaces 6 | { 7 | public interface IClientAppService 8 | { 9 | Pagelist GetClients(PageInputDto pageInput); 10 | Task GetClient(int Id); 11 | 12 | Task AddClient(CreateClientDto client); 13 | 14 | Task UpdateClient(UpdateClientDto client); 15 | Task RemoveClient(int Id); 16 | 17 | Task AddClientSecretAsync(ClientSecretDto clientSecret); 18 | Task DeleteClientSecretAsync(int secretId); 19 | 20 | Pagelist GetClientSecrets(PageInputDto pageInput, int clientId); 21 | Task AddClientPropertyAsync(ClientPropertyDto clientSecret); 22 | Task DeleteClientPropertyAsync(int propertyId); 23 | Pagelist GetClientProperties(PageInputDto pageInput, int clientId); 24 | 25 | //Task> GetSecrets(string clientId); 26 | //Task RemoveSecret(RemoveClientSecretViewModel model); 27 | //Task SaveSecret(SaveClientSecretViewModel model); 28 | //Task> GetProperties(string clientId); 29 | //Task RemoveProperty(RemovePropertyViewModel model); 30 | //Task SaveProperty(SaveClientPropertyViewModel model); 31 | //Task> GetClaims(string clientId); 32 | //Task RemoveClaim(RemoveClientClaimViewModel model); 33 | //Task SaveClaim(SaveClientClaimViewModel model); 34 | ////Task Save(SaveClientViewModel client); 35 | //Task Save(SaveClientViewModel client); 36 | //Task Remove(RemoveClientViewModel client); 37 | //Task Copy(CopyClientViewModel client); 38 | //Task GetClientDefaultDetails(string clientId); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Interfaces/IIdentityResourceService.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.Entities; 2 | using System.Threading.Tasks; 3 | using WQLIdentity.Application.Dtos.IdentityResources; 4 | using WQLIdentityServer.Infra.Dto; 5 | 6 | namespace WQLIdentity.Application.Interfaces 7 | { 8 | public interface IIdentityResourceService 9 | { 10 | Pagelist GetIdentityResourcesAsync(PageInputDto pageInput); 11 | 12 | Task GetIdentityResourceAsync(int Id); 13 | 14 | Task CanInsertIdentityResourceAsync(IdentityResourceDto identityResource); 15 | 16 | Task AddIdentityResourceAsync(CreateIdentityResourceDto identityResource); 17 | 18 | Task UpdateIdentityResourceAsync(CreateIdentityResourceDto identityResource); 19 | 20 | Task DeleteIdentityResourceAsync(int Id); 21 | 22 | 23 | Pagelist GetIdentityResourcePropertiesAsync(PageInputDto pageInput, int identityResourceId); 24 | 25 | 26 | Task AddIdentityResourcePropertyAsync(IdentityResourcePropertyDto identityResourceProperties); 27 | 28 | Task DeleteIdentityResourcePropertyAsync(int id); 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Interfaces/IRoleAppService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using WQLIdentity.Application.Dtos; 5 | using WQLIdentity.Application.Dtos.Roles; 6 | using WQLIdentityServer.Infra.Dto; 7 | 8 | namespace WQLIdentity.Application.Interfaces 9 | { 10 | public interface IRoleAppService 11 | { 12 | Pagelist GetRoles(PageInputDto input); 13 | Task CreateRoleAsync(CreateRoleDto roleDto); 14 | Task UpdateRoleAsync(UpdateRoleDto roleDto); 15 | Task DeleteRoleAsync(string roleId); 16 | 17 | Task CreateRoleClaim(CreateUserOrRoleClaimDto dto); 18 | Task RemoveRoleClaim(CreateUserOrRoleClaimDto dto); 19 | Task> GetRoleClaims(string roleId); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WQLIdentity.Application/Interfaces/IUserManagerService.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Application.Interfaces 2 | { 3 | public interface IUserManagerService 4 | { 5 | 6 | //Task UpdateProfile(UserViewModel model); 7 | //Task UpdateProfilePicture(ProfilePictureViewModel model); 8 | //Task ChangePassword(ChangePasswordViewModel model); 9 | //Task CreatePassword(SetPasswordViewModel model); 10 | //Task RemoveAccount(RemoveAccountViewModel model); 11 | //Task HasPassword(Guid userId); 12 | //Task> GetHistoryLogs(string username); 13 | //Task> GetUsers(); 14 | //Task GetUserDetails(string username); 15 | //Task GetUserAsync(Guid value); 16 | //Task UpdateUser(UserViewModel model); 17 | 18 | //Task> GetClaims(string userName); 19 | //Task SaveClaim(SaveUserClaimViewModel model); 20 | //Task RemoveClaim(RemoveUserClaimViewModel model); 21 | //Task> GetRoles(string userName); 22 | //Task RemoveRole(RemoveUserRoleViewModel model); 23 | //Task SaveRole(SaveUserRoleViewModel model); 24 | //Task> GetLogins(string userName); 25 | //Task RemoveLogin(RemoveUserLoginViewModel model); 26 | //Task> GetUsersInRole(string[] role); 27 | //Task ResetPassword(AdminChangePasswordViewodel model); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /WQLIdentity.Application/WQLIdentity.Application.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | 6 | 7 | 8 | bin\Debug\ 9 | bin\Debug\WQLIdentity.Application.xml 10 | 1701;1702;1591 11 | 12 | 13 | 14 | bin\Release\WQLIdentity.Application.xml 15 | bin\Release\ 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.identity.core\2.2.0\lib\netstandard2.0\Microsoft.Extensions.Identity.Core.dll 31 | 32 | 33 | C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\ref\netcoreapp2.2\System.ComponentModel.Annotations.dll 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /WQLIdentity.Domain/Entities/Claims.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentity.Domain.Entities 2 | { 3 | public class Claims : Entity 4 | { 5 | /// 6 | /// 声明类型 7 | /// 8 | public string Type { get; set; } 9 | /// 10 | /// 声明值 11 | /// 12 | public string Value { get; set; } 13 | /// 14 | /// 描述 15 | /// 16 | public string Description { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /WQLIdentity.Domain/Entities/Entity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | 5 | namespace WQLIdentity.Domain.Entities 6 | { 7 | public class Entity 8 | { 9 | public Entity() 10 | { 11 | CreatedOn = DateTime.Now; 12 | } 13 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 14 | [Key] 15 | public int Id { get; set; } 16 | public DateTime CreatedOn { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /WQLIdentity.Domain/Interface/IApplicationRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading.Tasks; 3 | using WQLIdentity.Domain.Entities; 4 | 5 | namespace WQLIdentity.Domain.Interface 6 | { 7 | public interface IApplicationRepository where TEntity : Entity 8 | { 9 | void Add(TEntity obj); 10 | TEntity GetById(T id); 11 | IQueryable GetAll(); 12 | void Update(TEntity obj); 13 | void Remove(TEntity id); 14 | int SaveChanges(); 15 | Task AddAsync(TEntity obj); 16 | Task GetByIdAsync(T id); 17 | Task SaveChangesAsync(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WQLIdentity.Domain/Interface/IConfigurationRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading.Tasks; 3 | 4 | namespace WQLIdentity.Domain.Interface 5 | { 6 | public interface IConfigurationRepository where TEntity : class 7 | { 8 | void Add(TEntity obj); 9 | TEntity GetById(T id); 10 | IQueryable GetAll(); 11 | void Update(TEntity obj); 12 | void Remove(TEntity id); 13 | int SaveChanges(); 14 | Task AddAsync(TEntity obj); 15 | Task GetByIdAsync(T id); 16 | Task SaveChangesAsync(); 17 | 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /WQLIdentity.Domain/Interface/IScopeRepository.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.Entities; 2 | 3 | namespace WQLIdentity.Domain.Interface 4 | { 5 | public interface IScopeRepository : IConfigurationRepository 6 | { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WQLIdentity.Domain/WQLIdentity.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\ref\netcoreapp2.2\System.ComponentModel.Annotations.dll 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data.Mysql/Migrations/Application/Mysql/20201012034049_IdentityServer4_v4.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace WQLIdentity.Infra.Data.Mysql.Migrations.Application.Mysql 4 | { 5 | public partial class IdentityServer4_v4 : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | 10 | } 11 | 12 | protected override void Down(MigrationBuilder migrationBuilder) 13 | { 14 | 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data.Mysql/MysqlApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using Microsoft.EntityFrameworkCore; 3 | using WQLIdentity.Infra.Data.Entities; 4 | 5 | 6 | namespace WQLIdentity.Infra.Data 7 | { 8 | public class MysqlApplicationDbContext : ApplicationDbContext 9 | { 10 | public MysqlApplicationDbContext(DbContextOptions options) : base(options) 11 | { 12 | } 13 | 14 | protected override void OnModelCreating(ModelBuilder builder) 15 | { 16 | 17 | base.OnModelCreating(builder); 18 | //mysql字段编辑 19 | builder.Entity().Property(d => d.NormalizedUserName).HasMaxLength(128); 20 | builder.Entity().Property(d => d.NormalizedName).HasMaxLength(128); 21 | builder.Entity>().Property(d => d.LoginProvider).HasMaxLength(128); 22 | builder.Entity>().Property(d => d.ProviderKey).HasMaxLength(128); 23 | builder.Entity>().Property(d => d.LoginProvider).HasMaxLength(128); 24 | builder.Entity>().Property(d => d.Name).HasMaxLength(128); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data.Mysql/MysqlConfigurationDbcontext.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.DbContexts; 2 | using IdentityServer4.EntityFramework.Options; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace WQLIdentity.Infra.Data 6 | { 7 | public class MysqlConfigurationDbContext : ConfigurationDbContext 8 | { 9 | 10 | 11 | public MysqlConfigurationDbContext(DbContextOptions options, ConfigurationStoreOptions storeOptions) : base(options, storeOptions) 12 | { 13 | 14 | } 15 | protected override void OnModelCreating(ModelBuilder modelBuilder) 16 | { 17 | base.OnModelCreating(modelBuilder); 18 | } 19 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 20 | { 21 | base.OnConfiguring(optionsBuilder); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data.Mysql/MysqlPersistedGrantDbContext.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.DbContexts; 2 | using IdentityServer4.EntityFramework.Entities; 3 | using IdentityServer4.EntityFramework.Options; 4 | using Microsoft.EntityFrameworkCore; 5 | 6 | namespace WQLIdentity.Infra.Data 7 | { 8 | public class MysqlPersistedGrantDbContext : PersistedGrantDbContext 9 | { 10 | public MysqlPersistedGrantDbContext(DbContextOptions options, OperationalStoreOptions storeOptions) : base(options, storeOptions) 11 | { 12 | 13 | } 14 | protected override void OnModelCreating(ModelBuilder modelBuilder) 15 | { 16 | base.OnModelCreating(modelBuilder); 17 | 18 | 19 | modelBuilder.Entity().Property(d => d.Data).HasColumnType("text"); 20 | modelBuilder.Entity().Property(d => d.Data).HasColumnType("text"); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data.Mysql/Repositorys/MysqlApiScopeRepository.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.Entities; 2 | using WQLIdentity.Domain.Interface; 3 | using WQLIdentity.Infra.Data.Repository; 4 | 5 | namespace WQLIdentity.Infra.Data.Mysql.Repositorys 6 | { 7 | public class MysqlApiScopeRepository : BaseRepository, IScopeRepository 8 | { 9 | public MysqlApiScopeRepository(MysqlConfigurationDbContext applicationDb) : base(applicationDb) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data.Mysql/Repositorys/MysqlApplicationRepository.cs: -------------------------------------------------------------------------------- 1 | using WQLIdentity.Domain.Entities; 2 | using WQLIdentity.Domain.Interface; 3 | using WQLIdentity.Infra.Data.Repository; 4 | 5 | namespace WQLIdentity.Infra.Data.Mysql.Repositorys 6 | { 7 | public class MysqlApplicationRepository : BaseRepository, IApplicationRepository where TEntity : Entity 8 | { 9 | public MysqlApplicationRepository(MysqlApplicationDbContext applicationDb) : base(applicationDb) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data.Mysql/Repositorys/MysqlConfigurationRepository.cs: -------------------------------------------------------------------------------- 1 | using WQLIdentity.Domain.Interface; 2 | using WQLIdentity.Infra.Data.Repository; 3 | 4 | namespace WQLIdentity.Infra.Data.Mysql.Repositorys 5 | { 6 | public class MysqlConfigurationRepository : BaseRepository, IConfigurationRepository where TEntity : class 7 | { 8 | public MysqlConfigurationRepository(MysqlConfigurationDbContext applicationDb) : base(applicationDb) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data.Mysql/WQLIdentity.Infra.Data.Mysql.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.identity.entityframeworkcore\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Identity.EntityFrameworkCore.dll 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using WQLIdentity.Domain.Entities; 4 | using WQLIdentity.Infra.Data.Entities; 5 | 6 | 7 | namespace WQLIdentity.Infra.Data 8 | { 9 | public class ApplicationDbContext : IdentityDbContext where TDbcontext : DbContext 10 | { 11 | 12 | public ApplicationDbContext(DbContextOptions options) : base(options) 13 | { 14 | 15 | } 16 | 17 | //protected override void OnModelCreating(ModelBuilder builder) 18 | //{ 19 | 20 | // base.OnModelCreating(builder); 21 | // //mysql字段编辑 22 | // builder.Entity().Property(d => d.NormalizedUserName).HasMaxLength(128); 23 | // builder.Entity().Property(d => d.NormalizedName).HasMaxLength(128); 24 | // builder.Entity>().Property(d => d.LoginProvider).HasMaxLength(128); 25 | // builder.Entity>().Property(d => d.ProviderKey).HasMaxLength(128); 26 | // builder.Entity>().Property(d => d.LoginProvider).HasMaxLength(128); 27 | // builder.Entity>().Property(d => d.Name).HasMaxLength(128); 28 | //} 29 | public DbSet Claims { get; set; } 30 | } 31 | public class ApplicationDbContext : ApplicationDbContext 32 | { 33 | public ApplicationDbContext(DbContextOptions options) : base(options) 34 | { 35 | } 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/CustomConfigurationDbContext.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.DbContexts; 2 | using IdentityServer4.EntityFramework.Options; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace WQLIdentity.Infra.Data 6 | { 7 | public class CustomConfigurationDbContext : ConfigurationDbContext 8 | { 9 | 10 | 11 | public CustomConfigurationDbContext(DbContextOptions options, ConfigurationStoreOptions storeOptions) : base(options, storeOptions) 12 | { 13 | 14 | } 15 | protected override void OnModelCreating(ModelBuilder modelBuilder) 16 | { 17 | base.OnModelCreating(modelBuilder); 18 | } 19 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 20 | { 21 | base.OnConfiguring(optionsBuilder); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/CustomPersistedGrantDbContext.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.DbContexts; 2 | using IdentityServer4.EntityFramework.Entities; 3 | using IdentityServer4.EntityFramework.Options; 4 | using Microsoft.EntityFrameworkCore; 5 | 6 | namespace WQLIdentity.Infra.Data 7 | { 8 | public class CustomPersistedGrantDbContext : PersistedGrantDbContext 9 | { 10 | public CustomPersistedGrantDbContext(DbContextOptions options, OperationalStoreOptions storeOptions) : base(options, storeOptions) 11 | { 12 | 13 | } 14 | protected override void OnModelCreating(ModelBuilder modelBuilder) 15 | { 16 | base.OnModelCreating(modelBuilder); 17 | 18 | 19 | modelBuilder.Entity().Property(d => d.Data).HasColumnType("text"); 20 | modelBuilder.Entity().Property(d => d.Data).HasColumnType("text"); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/Entities/ApplicationRole.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WQLIdentity.Infra.Data.Entities 7 | { 8 | public class ApplicationRole : IdentityRole 9 | { 10 | public ApplicationRole() 11 | { 12 | CreatedOn = DateTime.Now; 13 | } 14 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 15 | [Key] 16 | public override int Id { get; set; } 17 | 18 | public DateTime CreatedOn { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/Entities/ApplicationUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WQLIdentity.Infra.Data.Entities 7 | { 8 | public class ApplicationUser : IdentityUser 9 | { 10 | 11 | public ApplicationUser() 12 | { 13 | CreatedOn = DateTime.Now; 14 | } 15 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 16 | [Key] 17 | public override int Id { get; set; } 18 | 19 | public string Password { get; set; } 20 | public string Name { get; set; } 21 | public DateTime CreatedOn { get; set; } 22 | public string Department { get; set; } 23 | public string Picture { get; set; } 24 | 25 | 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/Migrations/Application/SqlServer/20201012010031_IdentityServer4_v4.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace WQLIdentity.Infra.Data.Migrations.Application.SqlServer 4 | { 5 | public partial class IdentityServer4_v4 : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | 10 | } 11 | 12 | protected override void Down(MigrationBuilder migrationBuilder) 13 | { 14 | 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/Repository/ApiScopeRepository.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.EntityFramework.DbContexts; 2 | using IdentityServer4.EntityFramework.Entities; 3 | using WQLIdentity.Domain.Interface; 4 | 5 | namespace WQLIdentity.Infra.Data.Repository 6 | { 7 | public class ApiScopeRepository : BaseRepository, IScopeRepository 8 | { 9 | public ApiScopeRepository(ConfigurationDbContext applicationDb) : base(applicationDb) 10 | { 11 | } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/Repository/ApplicationRepository.cs: -------------------------------------------------------------------------------- 1 | using WQLIdentity.Domain.Entities; 2 | using WQLIdentity.Domain.Interface; 3 | 4 | namespace WQLIdentity.Infra.Data.Repository 5 | { 6 | public class ApplicationRepository : BaseRepository, IApplicationRepository where TEntity : Entity 7 | { 8 | public ApplicationRepository(ApplicationDbContext applicationDb) : base(applicationDb) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/Repository/BaseRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | 5 | namespace WQLIdentity.Infra.Data.Repository 6 | { 7 | public class BaseRepository 8 | where TEntity : class 9 | where TDbcontext : DbContext 10 | { 11 | protected readonly TDbcontext Db; 12 | protected readonly DbSet DbSet; 13 | public BaseRepository(TDbcontext applicationDb) 14 | { 15 | Db = applicationDb; 16 | DbSet = Db.Set(); 17 | } 18 | public virtual void Add(TEntity obj) 19 | { 20 | DbSet.Add(obj); 21 | } 22 | 23 | public virtual TEntity GetById(T id) 24 | { 25 | return DbSet.Find(id); 26 | } 27 | 28 | public virtual IQueryable GetAll() 29 | { 30 | return DbSet; 31 | } 32 | 33 | public virtual void Update(TEntity obj) 34 | { 35 | DbSet.Update(obj); 36 | } 37 | 38 | public virtual void Remove(TEntity entity) 39 | { 40 | DbSet.Remove(entity); 41 | } 42 | 43 | public virtual int SaveChanges() 44 | { 45 | return Db.SaveChanges(); 46 | } 47 | 48 | public virtual async Task AddAsync(TEntity obj) 49 | { 50 | await DbSet.AddAsync(obj); 51 | } 52 | 53 | public virtual async Task GetByIdAsync(T id) 54 | { 55 | return await DbSet.FindAsync(id); 56 | } 57 | 58 | public virtual async Task SaveChangesAsync() 59 | { 60 | return await Db.SaveChangesAsync(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/Repository/ConfigurationRepository.cs: -------------------------------------------------------------------------------- 1 |  2 | using IdentityServer4.EntityFramework.DbContexts; 3 | using WQLIdentity.Domain.Interface; 4 | 5 | namespace WQLIdentity.Infra.Data.Repository 6 | { 7 | public class ConfigurationRepository : BaseRepository, IConfigurationRepository where TEntity : class 8 | { 9 | public ConfigurationRepository(CustomConfigurationDbContext applicationDb) : base(applicationDb) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WQLIdentity.Infra.Data/WQLIdentity.Infra.Data.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.identity.entityframeworkcore\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Identity.EntityFrameworkCore.dll 26 | 27 | 28 | C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore\2.2.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /WQLIdentityServer.Infra/Dto/ClientType.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServer.Infra.Dto 2 | { 3 | public enum ClientType 4 | { 5 | Empty = 0, 6 | WebImplicit = 1, 7 | WebHybrid = 2, 8 | Spa = 3, 9 | Native = 4, 10 | Machine = 5 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WQLIdentityServer.Infra/Dto/HashType.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServer.Infra.Dto 2 | { 3 | public enum HashType 4 | { 5 | Sha256, 6 | Sha512 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WQLIdentityServer.Infra/Dto/PageInputDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServer.Infra.Dto 2 | { 3 | /// 4 | /// 分页输入 5 | /// 6 | public class PageInputDto 7 | { 8 | public string Search { get; set; } 9 | public bool Isdesc { get; set; } = true; 10 | private int page; 11 | 12 | /// 13 | /// 页码 14 | /// 15 | public int Page 16 | { 17 | get 18 | { 19 | return page; 20 | } 21 | set 22 | { 23 | page = value; 24 | if (page <= 0) page = 1; 25 | 26 | } 27 | } 28 | 29 | /// 30 | /// 每页大小 31 | /// 32 | public int PageSize 33 | { 34 | get; set; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /WQLIdentityServer.Infra/Dto/Pagelist.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WQLIdentityServer.Infra.Dto 4 | { 5 | /// 6 | /// 分页输出 7 | /// 8 | /// 9 | public class Pagelist 10 | { 11 | public Pagelist() 12 | { 13 | Data = new List(); 14 | } 15 | /// 16 | /// 数据 17 | /// 18 | public List Data { get; set; } 19 | /// 20 | /// 数据总数 21 | /// 22 | public long TotalCount { get; set; } 23 | /// 24 | /// 每页大小 25 | /// 26 | public int PageSize { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WQLIdentityServer.Infra/Dto/SelectItemDto.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServer.Infra.Dto 2 | { 3 | public class SelectItemDto 4 | { 5 | public SelectItemDto(string id, string text) 6 | { 7 | Id = id; 8 | Text = text; 9 | } 10 | 11 | public string Id { get; set; } 12 | 13 | public string Text { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /WQLIdentityServer.Infra/Helpers/EnumHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using WQLIdentityServer.Infra.Dto; 5 | 6 | namespace WQLIdentityServer.Infra.Helpers 7 | { 8 | public class EnumHelpers 9 | { 10 | public static List ToSelectList() where T : struct, IComparable 11 | { 12 | var selectItems = Enum.GetValues(typeof(T)) 13 | .Cast() 14 | .Select(x => new SelectItemDto(Convert.ToInt16(x).ToString(), x.ToString())).ToList(); 15 | 16 | return selectItems; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WQLIdentityServer.Infra/WQLIdentityServer.Infra.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | 6 | 7 | 8 | 9 | C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.identity.core\2.2.0\lib\netstandard2.0\Microsoft.Extensions.Identity.Core.dll 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /WQLIdentityServer/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using System.Diagnostics; 3 | using WQLIdentityServer.Models; 4 | 5 | namespace WQLIdentityServer.Controllers 6 | { 7 | public class HomeController : Controller 8 | { 9 | public IActionResult Index() 10 | { 11 | return View(); 12 | } 13 | 14 | public IActionResult Privacy() 15 | { 16 | return View(); 17 | } 18 | 19 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 20 | public IActionResult Error() 21 | { 22 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /WQLIdentityServer/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServer.Models 2 | { 3 | public class ErrorViewModel 4 | { 5 | public string RequestId { get; set; } 6 | 7 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 8 | } 9 | } -------------------------------------------------------------------------------- /WQLIdentityServer/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | 4 | namespace WQLIdentityServer 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateWebHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 14 | WebHost.CreateDefaultBuilder(args) 15 | .UseStartup(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WQLIdentityServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:42549", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "WQLIdentityServer": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /WQLIdentityServer/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome

7 |

Learn about building Web apps with ASP.NET Core.

8 |
9 | -------------------------------------------------------------------------------- /WQLIdentityServer/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /WQLIdentityServer/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /WQLIdentityServer/Views/Shared/_CookieConsentPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Features 2 | 3 | @{ 4 | var consentFeature = Context.Features.Get(); 5 | var showBanner = !consentFeature?.CanTrack ?? false; 6 | var cookieString = consentFeature?.CreateConsentCookie(); 7 | } 8 | 9 | @if (showBanner) 10 | { 11 | 17 | 25 | } 26 | -------------------------------------------------------------------------------- /WQLIdentityServer/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /WQLIdentityServer/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using WQLIdentityServer 2 | @using WQLIdentityServer.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /WQLIdentityServer/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WQLIdentityServer/WQLIdentityServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | InProcess 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /WQLIdentityServer/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WQLIdentityServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /WQLIdentityServer/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Sticky footer styles 11 | -------------------------------------------------- */ 12 | html { 13 | font-size: 14px; 14 | } 15 | @media (min-width: 768px) { 16 | html { 17 | font-size: 16px; 18 | } 19 | } 20 | 21 | .border-top { 22 | border-top: 1px solid #e5e5e5; 23 | } 24 | .border-bottom { 25 | border-bottom: 1px solid #e5e5e5; 26 | } 27 | 28 | .box-shadow { 29 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 30 | } 31 | 32 | button.accept-policy { 33 | font-size: 1rem; 34 | line-height: inherit; 35 | } 36 | 37 | /* Sticky footer styles 38 | -------------------------------------------------- */ 39 | html { 40 | position: relative; 41 | min-height: 100%; 42 | } 43 | 44 | body { 45 | /* Margin bottom by footer height */ 46 | margin-bottom: 60px; 47 | } 48 | .footer { 49 | position: absolute; 50 | bottom: 0; 51 | width: 100%; 52 | white-space: nowrap; 53 | /* Set the fixed height of the footer here */ 54 | height: 60px; 55 | line-height: 60px; /* Vertically center the text there */ 56 | } 57 | -------------------------------------------------------------------------------- /WQLIdentityServer/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/WQLIdentityServer/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WQLIdentityServer/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /WQLIdentityServer/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WQLIdentityServer/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/WQLIdentityServer/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt -------------------------------------------------------------------------------- /WQLIdentityServer/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WQLIdentityServer/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/WQLIdentityServer/wwwroot/lib/jquery/LICENSE.txt -------------------------------------------------------------------------------- /WQLIdentityServerAPI/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "5.0.3", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Configurations/AutoMapperConfig.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System.Reflection; 4 | using WQLIdentity.Application.Dtos.UserManager; 5 | using WQLIdentity.Infra.Data.Entities; 6 | using WQLIdentityServer.Infra.Dto; 7 | 8 | namespace WQLIdentityServerAPI.Configurations 9 | { 10 | public static class AutoMapperConfig 11 | { 12 | public static void ConfigAutoMapper(this IServiceCollection services) 13 | { 14 | var temp = Assembly.GetEntryAssembly(); 15 | services.AddAutoMapper(Assembly.Load("WQLIdentity.Infra.Data"), Assembly.Load("WQLIdentityServer.Infra"), Assembly.Load("WQLIdentity.Domain"), Assembly.Load("WQLIdentity.Application"), Assembly.Load("WQLIdentityServerAPI")); 16 | 17 | 18 | 19 | } 20 | } 21 | 22 | public class AutoMapping : Profile 23 | { 24 | public AutoMapping() 25 | { 26 | CreateMap(typeof( Pagelist<>),typeof( Pagelist<>)); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Configurations/ConfigurePolicy.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using WQLIdentityServerAPI.Configurations.Consts; 3 | 4 | namespace WQLIdentityServerAPI.Configurations 5 | { 6 | public static class ConfigurePolicy 7 | { 8 | public static void AddPolicies(this IServiceCollection services) 9 | { 10 | services.AddAuthorization(options => 11 | { 12 | options.AddPolicy(PolicyConst.Admin, 13 | policy => policy.RequireAssertion(c => c.User.IsInRole("Administrator"))); 14 | options.AddPolicy(PolicyConst.Manager, 15 | policy => policy.RequireAuthenticatedUser()); 16 | 17 | 18 | }); 19 | 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Configurations/Consts/DatabaseConst.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServerAPI.Configurations.Consts 2 | { 3 | public static class DatabaseConst 4 | { 5 | public const string SqlServer = "sqlserver"; 6 | public const string Mysql = "mysql"; 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Configurations/Consts/PolicyConst.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServerAPI.Configurations.Consts 2 | { 3 | public class PolicyConst 4 | { 5 | public const string Admin = "Administrator"; 6 | public const string Manager = "Manager"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Configurations/CorsConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace WQLIdentityServerAPI.Configurations 4 | { 5 | public static class CorsConfig 6 | { 7 | public static void ConfigCors(this IServiceCollection services, string name) 8 | { 9 | services.AddCors(opt => 10 | { 11 | opt.AddPolicy(name, builder => builder 12 | //.WithOrigins("10.53.28.165") 13 | .AllowAnyOrigin() 14 | .AllowAnyMethod() 15 | .AllowAnyHeader() 16 | 17 | 18 | .SetIsOriginAllowed((host) => true) 19 | //.SetIsOriginAllowedToAllowWildcardSubdomains() 20 | //.AllowCredentials() 21 | ); 22 | }); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Configurations/DataBaseConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Options; 4 | using WQLIdentityServerAPI.Configurations.Consts; 5 | using WQLIdentityServerAPI.Models; 6 | 7 | namespace WQLIdentityServerAPI.Configurations 8 | { 9 | public static class DataBaseConfig 10 | { 11 | public static void ConfigDataBase(this IServiceCollection services,SettingOptions option) 12 | { 13 | 14 | var databaseType = option.DatabaseType; 15 | if (databaseType.ToLower() == DatabaseConst.Mysql) 16 | { 17 | 18 | string connectionString = option.MySqlConnection; 19 | //注册asp.net Identity 20 | services.ConfigIdentityByMysql(connectionString); 21 | //注册Identityserver4认证服务 22 | services.ConfigIdentityServerByMysql( connectionString); 23 | 24 | } 25 | else 26 | { 27 | string connectionString = option.SqlServerConnection; 28 | //注册asp.net Identity 29 | services.ConfigIdentityBySqlServer(connectionString); 30 | //注册Identityserver4认证服务 31 | services.ConfigIdentityServerBySqlServer( connectionString); 32 | } 33 | 34 | 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Configurations/MiniProfilerConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using WQLIdentityServerAPI.Models; 7 | 8 | namespace WQLIdentityServerAPI.Configurations 9 | { 10 | public static class MiniProfilerConfig 11 | { 12 | 13 | public static void ConfigMiniProfiler(this IServiceCollection services,SettingOptions options) 14 | { 15 | 16 | if (options.UseMinProfiler) 17 | { 18 | services.AddMiniProfiler(opt => 19 | { 20 | opt.RouteBasePath = "/profiler"; 21 | }) 22 | .AddEntityFramework(); 23 | } 24 | 25 | 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/BaseApiController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using WQLIdentityServerAPI.Middleware.Exceptions; 6 | using WQLIdentityServerAPI.Models; 7 | 8 | namespace WQLIdentityServerAPI.Controllers 9 | { 10 | [ApiController] 11 | //[Authorize(Roles ="Administrator")] 12 | public class BaseApiController : ControllerBase 13 | { 14 | 15 | protected IEnumerable ModelStateErrors 16 | { 17 | get 18 | { 19 | var erros = ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage); 20 | return erros; 21 | } 22 | } 23 | protected IActionResult IdentityResponse(IdentityResult result, T msg) 24 | { 25 | if (result.Succeeded) 26 | { 27 | return Ok(msg); 28 | } 29 | else 30 | { 31 | return BadRequest(result.Errors); 32 | } 33 | } 34 | 35 | protected IActionResult ResultResponse(bool result, string msg) 36 | { 37 | var content = new DefaultResponse(); 38 | if (result) 39 | { 40 | content.StatusCode = 0; 41 | content.Data = msg + "成功"; 42 | content.Result = true; 43 | return Ok(content); 44 | } 45 | else 46 | { 47 | content.StatusCode = -1; 48 | content.Data = msg + "失败"; 49 | content.Result = false; 50 | return BadRequest(content); 51 | } 52 | } 53 | 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Account/AccountOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System; 6 | 7 | namespace IdentityServerHost.Quickstart.UI 8 | { 9 | public class AccountOptions 10 | { 11 | public static bool AllowLocalLogin = true; 12 | public static bool AllowRememberLogin = true; 13 | public static TimeSpan RememberMeLoginDuration = TimeSpan.FromDays(30); 14 | 15 | public static bool ShowLogoutPrompt = true; 16 | public static bool AutomaticRedirectAfterSignOut = true; 17 | 18 | // specify the Windows authentication scheme being used 19 | public static readonly string WindowsAuthenticationSchemeName = Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme; 20 | // if user uses windows auth, should we load the groups from windows 21 | public static bool IncludeWindowsGroups = false; 22 | 23 | public static string InvalidCredentialsErrorMessage = "Invalid username or password"; 24 | public static string AccountNotConfirmedMessage = "Confirm your account"; 25 | public static string AccountBlocked = "Temporary blocked. Wait 5 minutes and try again"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Account/ExternalProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServerHost.Quickstart.UI 6 | { 7 | public class ExternalProvider 8 | { 9 | public string DisplayName { get; set; } 10 | public string AuthenticationScheme { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Account/LoggedOutViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServerHost.Quickstart.UI 6 | { 7 | public class LoggedOutViewModel 8 | { 9 | public string PostLogoutRedirectUri { get; set; } 10 | public string ClientName { get; set; } 11 | public string SignOutIframeUrl { get; set; } 12 | 13 | public bool AutomaticRedirectAfterSignOut { get; set; } 14 | 15 | public string LogoutId { get; set; } 16 | public bool TriggerExternalSignout => ExternalAuthenticationScheme != null; 17 | public string ExternalAuthenticationScheme { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Account/LoginInputModel.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/WQLIdentityServerAPI/Controllers/Quickstart/Account/LoginInputModel.cs -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Account/LoginViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | 9 | namespace IdentityServerHost.Quickstart.UI 10 | { 11 | public class LoginViewModel : LoginInputModel 12 | { 13 | public bool AllowRememberLogin { get; set; } = true; 14 | public bool EnableLocalLogin { get; set; } = true; 15 | 16 | public IEnumerable ExternalProviders { get; set; } = Enumerable.Empty(); 17 | public IEnumerable VisibleExternalProviders => ExternalProviders.Where(x => !String.IsNullOrWhiteSpace(x.DisplayName)); 18 | 19 | public bool IsExternalLoginOnly => EnableLocalLogin == false && ExternalProviders?.Count() == 1; 20 | public string ExternalLoginScheme => IsExternalLoginOnly ? ExternalProviders?.SingleOrDefault()?.AuthenticationScheme : null; 21 | } 22 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Account/LogoutInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServerHost.Quickstart.UI 6 | { 7 | public class LogoutInputModel 8 | { 9 | public string LogoutId { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Account/LogoutViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServerHost.Quickstart.UI 6 | { 7 | public class LogoutViewModel : LogoutInputModel 8 | { 9 | public bool ShowLogoutPrompt { get; set; } = true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Account/RedirectViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | 6 | namespace IdentityServerHost.Quickstart.UI 7 | { 8 | public class RedirectViewModel 9 | { 10 | public string RedirectUrl { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Consent/ConsentInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace IdentityServerHost.Quickstart.UI 8 | { 9 | public class ConsentInputModel 10 | { 11 | public string Button { get; set; } 12 | public IEnumerable ScopesConsented { get; set; } 13 | public bool RememberConsent { get; set; } 14 | public string ReturnUrl { get; set; } 15 | public string Description { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Consent/ConsentOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServerHost.Quickstart.UI 6 | { 7 | public class ConsentOptions 8 | { 9 | public static bool EnableOfflineAccess = true; 10 | public static string OfflineAccessDisplayName = "Offline Access"; 11 | public static string OfflineAccessDescription = "Access to your applications and resources, even when you are offline"; 12 | 13 | public static readonly string MustChooseOneErrorMessage = "You must pick at least one permission"; 14 | public static readonly string InvalidSelectionErrorMessage = "Invalid selection"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Consent/ConsentViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace IdentityServerHost.Quickstart.UI 8 | { 9 | public class ConsentViewModel : ConsentInputModel 10 | { 11 | public string ClientName { get; set; } 12 | public string ClientUrl { get; set; } 13 | public string ClientLogoUrl { get; set; } 14 | public bool AllowRememberConsent { get; set; } 15 | 16 | public IEnumerable IdentityScopes { get; set; } 17 | public IEnumerable ApiScopes { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Consent/ProcessConsentResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityServer4.Models; 6 | 7 | namespace IdentityServerHost.Quickstart.UI 8 | { 9 | public class ProcessConsentResult 10 | { 11 | public bool IsRedirect => RedirectUri != null; 12 | public string RedirectUri { get; set; } 13 | public Client Client { get; set; } 14 | 15 | public bool ShowView => ViewModel != null; 16 | public ConsentViewModel ViewModel { get; set; } 17 | 18 | public bool HasValidationError => ValidationError != null; 19 | public string ValidationError { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Consent/ScopeViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServerHost.Quickstart.UI 6 | { 7 | public class ScopeViewModel 8 | { 9 | public string Value { get; set; } 10 | public string DisplayName { get; set; } 11 | public string Description { get; set; } 12 | public bool Emphasize { get; set; } 13 | public bool Required { get; set; } 14 | public bool Checked { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Device/DeviceAuthorizationInputModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServerHost.Quickstart.UI 6 | { 7 | public class DeviceAuthorizationInputModel : ConsentInputModel 8 | { 9 | public string UserCode { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Device/DeviceAuthorizationViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | namespace IdentityServerHost.Quickstart.UI 6 | { 7 | public class DeviceAuthorizationViewModel : ConsentViewModel 8 | { 9 | public string UserCode { get; set; } 10 | public bool ConfirmUserCode { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Diagnostics/DiagnosticsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using Microsoft.AspNetCore.Authentication; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Microsoft.AspNetCore.Mvc; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace IdentityServerHost.Quickstart.UI 12 | { 13 | [SecurityHeaders] 14 | [Authorize] 15 | public class DiagnosticsController : Controller 16 | { 17 | public async Task Index() 18 | { 19 | var localAddresses = new string[] { "127.0.0.1", "::1", HttpContext.Connection.LocalIpAddress.ToString() }; 20 | if (!localAddresses.Contains(HttpContext.Connection.RemoteIpAddress.ToString())) 21 | { 22 | return NotFound(); 23 | } 24 | 25 | var model = new DiagnosticsViewModel(await HttpContext.AuthenticateAsync()); 26 | return View(model); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Diagnostics/DiagnosticsViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityModel; 6 | using Microsoft.AspNetCore.Authentication; 7 | using Newtonsoft.Json; 8 | using System.Collections.Generic; 9 | using System.Text; 10 | 11 | namespace IdentityServerHost.Quickstart.UI 12 | { 13 | public class DiagnosticsViewModel 14 | { 15 | public DiagnosticsViewModel(AuthenticateResult result) 16 | { 17 | AuthenticateResult = result; 18 | 19 | if (result.Properties.Items.ContainsKey("client_list")) 20 | { 21 | var encoded = result.Properties.Items["client_list"]; 22 | var bytes = Base64Url.Decode(encoded); 23 | var value = Encoding.UTF8.GetString(bytes); 24 | 25 | Clients = JsonConvert.DeserializeObject(value); 26 | } 27 | } 28 | 29 | public AuthenticateResult AuthenticateResult { get; } 30 | public IEnumerable Clients { get; } = new List(); 31 | } 32 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Extensions.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | 5 | namespace IdentityServerHost.Quickstart.UI 6 | { 7 | public static class Extensions 8 | { 9 | /// 10 | /// Checks if the redirect URI is for a native client. 11 | /// 12 | /// 13 | public static bool IsNativeClient(this AuthorizationRequest context) 14 | { 15 | return !context.RedirectUri.StartsWith("https", StringComparison.Ordinal) 16 | && !context.RedirectUri.StartsWith("http", StringComparison.Ordinal); 17 | } 18 | 19 | public static IActionResult LoadingPage(this Controller controller, string viewName, string redirectUri) 20 | { 21 | controller.HttpContext.Response.StatusCode = 200; 22 | controller.HttpContext.Response.Headers["Location"] = ""; 23 | 24 | return controller.View(viewName, new RedirectViewModel { RedirectUrl = redirectUri }); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Grants/GrantsViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace IdentityServerHost.Quickstart.UI 9 | { 10 | public class GrantsViewModel 11 | { 12 | public IEnumerable Grants { get; set; } 13 | } 14 | 15 | public class GrantViewModel 16 | { 17 | public string ClientId { get; set; } 18 | public string ClientName { get; set; } 19 | public string ClientUrl { get; set; } 20 | public string ClientLogoUrl { get; set; } 21 | public string Description { get; set; } 22 | public DateTime Created { get; set; } 23 | public DateTime? Expires { get; set; } 24 | public IEnumerable IdentityGrantNames { get; set; } 25 | public IEnumerable ApiGrantNames { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Home/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityServer4.Models; 6 | 7 | namespace IdentityServerHost.Quickstart.UI 8 | { 9 | public class ErrorViewModel 10 | { 11 | public ErrorViewModel() 12 | { 13 | } 14 | 15 | public ErrorViewModel(string error) 16 | { 17 | Error = new ErrorMessage { Error = error }; 18 | } 19 | 20 | public ErrorMessage Error { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Controllers/Quickstart/Home/HomeController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | 5 | using IdentityServer4.Services; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Extensions.Hosting; 10 | using Microsoft.Extensions.Logging; 11 | using System.Threading.Tasks; 12 | 13 | namespace IdentityServerHost.Quickstart.UI 14 | { 15 | [SecurityHeaders] 16 | [AllowAnonymous] 17 | public class HomeController : Controller 18 | { 19 | private readonly IIdentityServerInteractionService _interaction; 20 | private readonly IWebHostEnvironment _environment; 21 | private readonly ILogger _logger; 22 | 23 | public HomeController(IIdentityServerInteractionService interaction, IWebHostEnvironment environment, ILogger logger) 24 | { 25 | _interaction = interaction; 26 | _environment = environment; 27 | _logger = logger; 28 | } 29 | 30 | public IActionResult Index() 31 | { 32 | return View(); 33 | } 34 | 35 | /// 36 | /// Shows the error page 37 | /// 38 | public async Task Error(string errorId) 39 | { 40 | var vm = new ErrorViewModel(); 41 | 42 | // retrieve error details from identityserver 43 | var message = await _interaction.GetErrorContextAsync(errorId); 44 | if (message != null) 45 | { 46 | vm.Error = message; 47 | 48 | if (!_environment.IsDevelopment()) 49 | { 50 | // only show in development 51 | message.ErrorDescription = null; 52 | } 53 | } 54 | 55 | return View("Error", vm); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Filters/PermissionAuthorize.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.Filters; 3 | using System; 4 | using System.Linq; 5 | 6 | namespace WQLIdentityServerAPI.Filters 7 | { 8 | public class PermissionAuthorize 9 | { 10 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] 11 | public class PermissionAuthorzize : Attribute, IAuthorizationFilter 12 | { 13 | //权限名称 14 | public string Permission { get; set; } 15 | //作用域 16 | public string Area { get; set; } 17 | public void OnAuthorization(AuthorizationFilterContext context) 18 | { 19 | 20 | if (context.HttpContext.User != null) 21 | { 22 | var AreaClaim = context.HttpContext.User.FindAll(_ => _.Type == Area); 23 | //查找是否包含该域 24 | if (AreaClaim != null) 25 | { 26 | var AreaPermission = AreaClaim.Select(d => d.Value); 27 | //查找在该域是否具有权限 28 | if (AreaPermission == null || !AreaPermission.Contains(Permission)) 29 | { 30 | context.Result = new UnauthorizedResult(); 31 | } 32 | } 33 | 34 | } 35 | 36 | 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/IdentityServers/Services/AuthCodeService.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServerAPI.IdentityServers.Services 2 | { 3 | public class AuthCodeService : IAuthCodeService 4 | { 5 | public bool Validate(string phone, string code) 6 | { 7 | return true; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/IdentityServers/Services/IAuthCodeService.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServerAPI.IdentityServers.Services 2 | { 3 | public interface IAuthCodeService 4 | { 5 | /// 6 | /// 验证手机验证码是否正确 7 | /// 8 | /// 9 | /// 10 | /// 11 | bool Validate(string phone, string code); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/IdentityServers/SmsAuthCodeValidator.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.Models; 2 | using IdentityServer4.Validation; 3 | using System.Threading.Tasks; 4 | using WQLIdentity.Application.Interfaces; 5 | using WQLIdentityServerAPI.IdentityServers.Services; 6 | 7 | namespace WQLIdentityServerAPI.IdentityServers 8 | { 9 | /// 10 | /// 短信验证 11 | /// 12 | public class SmsAuthCodeValidator : IExtensionGrantValidator 13 | { 14 | public string GrantType => "sms"; 15 | private readonly IAuthCodeService _authCodeService; 16 | private readonly IUserAppService _userAppService; 17 | public SmsAuthCodeValidator(IAuthCodeService authCodeService, IUserAppService userAppService) 18 | { 19 | _authCodeService = authCodeService; 20 | _userAppService = userAppService; 21 | } 22 | 23 | public async Task ValidateAsync(ExtensionGrantValidationContext context) 24 | { 25 | var phone = context.Request.Raw["phone"]; 26 | var code = context.Request.Raw["auth_code"]; 27 | var errResult = new GrantValidationResult(TokenRequestErrors.InvalidGrant); 28 | if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(code)) 29 | { 30 | context.Result = errResult; 31 | return; 32 | } 33 | if (!_authCodeService.Validate(phone, code)) 34 | { 35 | context.Result = errResult; 36 | return; 37 | } 38 | var user = await _userAppService.CheckUserByPhone(phone); 39 | //if (user) 40 | //{ 41 | // context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant,"该手机号未注册信息"); ; 42 | // return; 43 | //} 44 | var userId = await _userAppService.CheckOrCreate(phone); 45 | if (userId <= 0) 46 | { 47 | context.Result = errResult; 48 | return; 49 | } 50 | context.Result = new GrantValidationResult(userId.ToString(), GrantType); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Middleware/DateTimeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json; 3 | using System.Text.Json.Serialization; 4 | 5 | namespace AntennaKnowledgeBase.Api.Middleware 6 | { 7 | public class DateTimeConverter : JsonConverter 8 | { 9 | public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 10 | { 11 | return DateTime.Parse(reader.GetString()); 12 | } 13 | 14 | public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) 15 | { 16 | writer.WriteStringValue(value.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ssZ")); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Middleware/Exceptions/CustomExceptionMiddlewareExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.Extensions.Logging; 3 | 4 | namespace WQLIdentityServerAPI.Middleware.Exceptions 5 | { 6 | public static class CustomExceptionMiddlewareExtensions 7 | { 8 | public static void UseCustomException(this IApplicationBuilder app, ILogger logger) 9 | { 10 | app.UseMiddleware(logger); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Middleware/Exceptions/CustomExceptionMidlleware.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Net; 5 | using System.Threading.Tasks; 6 | using WQLIdentityServerAPI.Models; 7 | 8 | namespace WQLIdentityServerAPI.Middleware.Exceptions 9 | { 10 | public class CustomExceptionMidlleware 11 | { 12 | private readonly RequestDelegate next; 13 | private readonly ILogger _logger; 14 | public CustomExceptionMidlleware(RequestDelegate next, ILogger logger) 15 | { 16 | this.next = next; 17 | _logger = logger; 18 | } 19 | public async Task InvokeAsync(HttpContext context) 20 | { 21 | try 22 | { 23 | await next(context); 24 | } 25 | catch (Exception ex) 26 | { 27 | _logger.LogError(ex, ex.Message); 28 | await HandleExceptionAsync(context, ex); 29 | } 30 | } 31 | private Task HandleExceptionAsync(HttpContext context, Exception exception) 32 | { 33 | 34 | string result = null; 35 | 36 | 37 | context.Response.ContentType = "application/json;charset=UTF-8"; 38 | result = new DefaultResponse() { Data = exception.Message, StatusCode = (int)HttpStatusCode.BadRequest, Result = false }.ToString(); 39 | context.Response.StatusCode = (int)HttpStatusCode.BadRequest; 40 | return context.Response.WriteAsync(result); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Models/DefaultReponse.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Serialization; 3 | using System.Collections.Generic; 4 | 5 | namespace WQLIdentityServerAPI.Models 6 | { 7 | public class DefaultResponse 8 | { 9 | /// 10 | /// 结果 11 | /// 12 | public bool Result { get; set; } 13 | /// 14 | /// 状态码 15 | /// 16 | public int StatusCode { get; set; } 17 | /// 18 | /// 数据 19 | /// 20 | public T Data { get; set; } 21 | /// 22 | /// 错误信息 23 | /// 24 | 25 | public IEnumerable Errors { get; set; } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject(this, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); ; 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Models/Identity/AuthorizeClaims.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WQLIdentityServerAPI.Models.Identity 4 | { 5 | public class AuthorizeClaims 6 | { 7 | public static List GetClaimTypes 8 | { 9 | get 10 | { 11 | return new List { Area, Permission }; 12 | } 13 | } 14 | 15 | public static List GetAreaValue 16 | { 17 | get 18 | { 19 | return new List { PartDesin, Simulation, ProductFault, Config, Image, Log }; 20 | } 21 | } 22 | 23 | public static List GetPermissionValue 24 | { 25 | get 26 | { 27 | return new List { Create, Read, Update, Delete }; 28 | } 29 | } 30 | 31 | ///Type 32 | public const string Area = "Area"; 33 | public const string Permission = "Permission"; 34 | 35 | //PermissionValue 36 | public const string Create = "Create"; 37 | public const string Read = "Read"; 38 | public const string Update = "Update"; 39 | public const string Delete = "Delete"; 40 | 41 | //AreaValue 42 | public const string PartDesin = "PartDesin"; 43 | public const string Simulation = "Simulation"; 44 | public const string ProductFault = "ProductFault"; 45 | public const string Config = "Config"; 46 | public const string Image = "Image"; 47 | public const string Log = "Log"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Models/SettingOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WQLIdentityServerAPI.Models 7 | { 8 | public class SettingOptions 9 | { 10 | public const string Name = "Settings"; 11 | 12 | public string DatabaseType { get; set; } 13 | 14 | public string SqlServerConnection { get; set; } 15 | 16 | 17 | public string MySqlConnection { get; set; } 18 | 19 | public bool UseMinProfiler { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Properties/PublishProfiles/FolderProfile.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | FileSystem 9 | FileSystem 10 | Release 11 | Any CPU 12 | 13 | True 14 | False 15 | netcoreapp2.2 16 | 22396d0b-6cef-412f-a7bc-6a2914cc5ee2 17 | false 18 | <_IsPortable>true 19 | bin\Release\netcoreapp2.2\publish\ 20 | True 21 | 22 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Properties/PublishProfiles/FolderProfile.pubxml.user: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | <_PublishTargetUrl>E:\studydemo\WQLIdentityServer\WQLIdentityServer\WQLIdentityServerAPI\bin\Release\netcoreapp2.2\publish\ 10 | 11 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Properties/PublishProfiles/FolderProfile1.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | FileSystem 9 | FileSystem 10 | Release 11 | Any CPU 12 | 13 | True 14 | False 15 | 22396d0b-6cef-412f-a7bc-6a2914cc5ee2 16 | bin\Release\net5.0\publish\ 17 | True 18 | net5.0 19 | linux-x64 20 | false 21 | <_IsPortable>true 22 | 23 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Properties/PublishProfiles/FolderProfile1.pubxml.user: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | <_PublishTargetUrl>D:\WorkSpace\web\Identityserver4\WQLIdentityServerAPI\bin\Release\net5.0\publish\ 10 | True|2021-03-29T01:57:33.1032352Z;True|2021-03-29T09:46:20.1174624+08:00;True|2021-03-29T09:10:53.4287019+08:00;True|2021-03-26T20:51:25.1357000+08:00;True|2021-03-26T19:52:15.9225835+08:00;True|2021-03-26T17:58:51.3409280+08:00;True|2021-03-26T17:43:21.8630460+08:00;False|2021-03-26T17:42:44.5297110+08:00;False|2021-03-26T17:42:14.6232636+08:00;True|2021-03-26T17:37:11.5104343+08:00;False|2021-03-26T17:36:30.9270425+08:00;True|2021-03-26T16:15:02.8341091+08:00;True|2021-03-26T15:50:59.9081085+08:00; 11 | 12 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:42717", 7 | "sslPort": 0 8 | } 9 | }, 10 | "$schema": "http://json.schemastore.org/launchsettings.json", 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "api/values", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development", 18 | "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" 19 | } 20 | }, 21 | "WQLIdentityServerAPI": { 22 | "commandName": "Project", 23 | "launchBrowser": true, 24 | "launchUrl": "http://localhost:5001/doc", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development", 27 | "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/SeedData/AuthorizationConsts.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityServerAPI.SeedData 2 | { 3 | public class AuthorizationConsts 4 | { 5 | public const string AdministrationUser = "administrator"; 6 | public const string AdministrationRole = "Administrator"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Services/ProfileService.cs: -------------------------------------------------------------------------------- 1 | using IdentityServer4.Models; 2 | using IdentityServer4.Services; 3 | using System; 4 | using System.Threading.Tasks; 5 | 6 | namespace WQLIdentityServerAPI.Services 7 | { 8 | public class ProfileService : IProfileService 9 | { 10 | public Task GetProfileDataAsync(ProfileDataRequestContext context) 11 | { 12 | throw new NotImplementedException(); 13 | } 14 | 15 | public Task IsActiveAsync(IsActiveContext context) 16 | { 17 | throw new NotImplementedException(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Account/AccessDenied.cshtml: -------------------------------------------------------------------------------- 1 |  2 |
3 |
4 |

Access Denied

5 |

You do not have access to that resource.

6 |
7 |
-------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Account/LoggedOut.cshtml: -------------------------------------------------------------------------------- 1 | @model LoggedOutViewModel 2 | 3 | @{ 4 | // set this so the layout rendering sees an anonymous user 5 | ViewData["signed-out"] = true; 6 | } 7 | 8 |
9 |

10 | Logout 11 | You are now logged out 12 |

13 | 14 | @if (Model.PostLogoutRedirectUri != null) 15 | { 16 |
17 | Click here to return to the 18 | @Model.ClientName application. 19 |
20 | } 21 | 22 | @if (Model.SignOutIframeUrl != null) 23 | { 24 | 25 | } 26 |
27 | 28 | @section scripts 29 | { 30 | @if (Model.AutomaticRedirectAfterSignOut) 31 | { 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Account/Logout.cshtml: -------------------------------------------------------------------------------- 1 | @model LogoutViewModel 2 | 3 |
4 |
5 |

Logout

6 |

Would you like to logut of IdentityServer?

7 |
8 | 9 |
10 | 11 |
12 | 13 |
14 |
15 |
16 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Device/Success.cshtml: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |

Success

5 |

You have successfully authorized the device

6 |
7 |
8 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Device/UserCodeCapture.cshtml: -------------------------------------------------------------------------------- 1 | @model string 2 | 3 |
4 |
5 |

User Code

6 |

Please enter the code displayed on your device.

7 |
8 | 9 | 10 | 11 |
12 |
13 |
14 |
15 | 16 | 17 |
18 | 19 | 20 |
21 |
22 |
23 |
24 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Diagnostics/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model DiagnosticsViewModel 2 | 3 |
4 |
5 |

Authentication Cookie

6 |
7 | 8 |
9 |
10 |
11 |
12 |

Claims

13 |
14 |
15 |
16 | @foreach (var claim in Model.AuthenticateResult.Principal.Claims) 17 | { 18 |
@claim.Type
19 |
@claim.Value
20 | } 21 |
22 |
23 |
24 |
25 | 26 |
27 |
28 |
29 |

Properties

30 |
31 |
32 |
33 | @foreach (var prop in Model.AuthenticateResult.Properties.Items) 34 | { 35 |
@prop.Key
36 |
@prop.Value
37 | } 38 | @if (Model.Clients.Any()) 39 | { 40 |
Clients
41 |
42 | @{ 43 | var clients = Model.Clients.ToArray(); 44 | for(var i = 0; i < clients.Length; i++) 45 | { 46 | @clients[i] 47 | if (i < clients.Length - 1) 48 | { 49 | , 50 | } 51 | } 52 | } 53 |
54 | } 55 |
56 |
57 |
58 |
59 |
60 |
61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Diagnostics 2 | 3 | @{ 4 | var version = FileVersionInfo.GetVersionInfo(typeof(IdentityServer4.Hosting.IdentityServerMiddleware).Assembly.Location).ProductVersion.Split('+').First(); 5 | } 6 | 7 |
8 |

9 | 10 | 欢迎来到IdentityServer4授权中心 11 | (version @version) 12 |

13 | 14 | 15 |
16 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | 3 | @{ 4 | var error = Model?.Error?.Error; 5 | var errorDescription = Model?.Error?.ErrorDescription; 6 | var request_id = Model?.Error?.RequestId; 7 | } 8 | 9 |
10 |
11 |

Error

12 |
13 | 14 |
15 |
16 |
17 | Sorry, there was an error 18 | 19 | @if (error != null) 20 | { 21 | 22 | 23 | : @error 24 | 25 | 26 | 27 | if (errorDescription != null) 28 | { 29 |
@errorDescription
30 | } 31 | } 32 |
33 | 34 | @if (request_id != null) 35 | { 36 |
Request Id: @request_id
37 | } 38 |
39 |
40 |
41 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Shared/Redirect.cshtml: -------------------------------------------------------------------------------- 1 | @model RedirectViewModel 2 | 3 |
4 |
5 |

You are now being returned to the application

6 |

Once complete, you may close this tab.

7 |
8 |
9 | 10 | 11 | @**@ 12 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | IdentityServer4 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | @RenderBody() 24 |
25 | 26 | 27 | 28 | 29 | @RenderSection("scripts", required: false) 30 | 31 | 32 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Shared/_Nav.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityServer4.Extensions 2 | 3 | @{ 4 | string name = null; 5 | if (!true.Equals(ViewData["signed-out"])) 6 | { 7 | name = Context.User?.GetDisplayName(); 8 | } 9 | } 10 | 11 | 57 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Shared/_ScopeListItem.cshtml: -------------------------------------------------------------------------------- 1 | @model ScopeViewModel 2 | 3 |
  • 4 | 24 | @if (Model.Required) 25 | { 26 | (required) 27 | } 28 | @if (Model.Description != null) 29 | { 30 | 33 | } 34 |
  • -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/Shared/_ValidationSummary.cshtml: -------------------------------------------------------------------------------- 1 | @if (ViewContext.ModelState.IsValid == false) 2 | { 3 |
    4 | Error 5 |
    6 |
    7 | } -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using StackExchange.Profiling 2 | @addTagHelper *, MiniProfiler.AspNetCore.Mvc 3 | @using IdentityServerHost.Quickstart.UI 4 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 5 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/WQLIdentityServerAPI.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ProjectDebugger 5 | 6 | 7 | WQLIdentityServerAPI 8 | ApiControllerEmptyScaffolder 9 | root/Controller 10 | 600 11 | False 12 | False 13 | False 14 | False 15 | 600 16 | D:\WorkSpace\web\Identityserver4\WQLIdentityServerAPI\Properties\PublishProfiles\FolderProfile1.pubxml 17 | 18 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "urls": "http://localhost:5001;https://localhost:5002", 3 | "IdentityServer4": { 4 | "authUrls": "http://localhost:5001",//swagger认证地址,如果nginx更改了,需要配置为服务端发布地址 5 | "Audience": "IdentityServer4" 6 | }, 7 | "Logging": { 8 | "LogLevel": { 9 | "Default": "Warning" 10 | } 11 | }, 12 | "AllowedHosts": "*", 13 | 14 | //切换数据库地址 15 | "Settings": { 16 | //mysql or sqlserver 17 | "DatabaseType": "mysql", 18 | 19 | //数据库连接字符串 20 | "SqlServerConnection": "Server=.;Database=IdentityServer ;Trusted_Connection=True;MultipleActiveResultSets=true", 21 | "MySqlConnection": "Server=localhost;Port=3306;Database=IdentityServer;Uid=root;Pwd=xiucaibbx0528;", 22 | //"MySqlConnection": "Server=localhost;Port=3306;Database=IdentityServer;Uid=root;Pwd=asdfghjkl;", 23 | "UseMinProfiler": false 24 | 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/getmaster.ps1: -------------------------------------------------------------------------------- 1 | $source = "https://github.com/IdentityServer/IdentityServer4.Quickstart.UI/archive/master.zip" 2 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 3 | Invoke-WebRequest $source -OutFile ui.zip 4 | 5 | Expand-Archive ui.zip 6 | 7 | if (!(Test-Path -Path Quickstart)) { mkdir Quickstart } 8 | if (!(Test-Path -Path Views)) { mkdir Views } 9 | if (!(Test-Path -Path wwwroot)) { mkdir wwwroot } 10 | 11 | copy .\ui\IdentityServer4.Quickstart.UI-master\Quickstart\* Quickstart -recurse -force 12 | copy .\ui\IdentityServer4.Quickstart.UI-master\Views\* Views -recurse -force 13 | copy .\ui\IdentityServer4.Quickstart.UI-master\wwwroot\* wwwroot -recurse -force 14 | 15 | del ui.zip 16 | del ui -recurse 17 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/getmaster.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | SOURCE="https://github.com/IdentityServer/IdentityServer4.Quickstart.UI/archive/master.zip" 6 | curl -L -o ui.zip "$SOURCE" 7 | 8 | unzip -d ui ui.zip 9 | 10 | [[ -d Quickstart ]] || mkdir Quickstart 11 | [[ -d Views ]] || mkdir Views 12 | [[ -d wwwroot ]] || mkdir wwwroot 13 | 14 | cp -r ./ui/IdentityServer4.Quickstart.UI-master/Quickstart/* Quickstart 15 | cp -r ./ui/IdentityServer4.Quickstart.UI-master/Views/* Views 16 | cp -r ./ui/IdentityServer4.Quickstart.UI-master/wwwroot/* wwwroot 17 | 18 | rm -rf ui ui.zip 19 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "name": "asp.net", 4 | "private": true, 5 | "dependencies": { 6 | "bootstrap": "4.6.0", 7 | "jquery": "3.6.0" 8 | }, 9 | "devDependencies": { 10 | "gulp": "^4.0.2", 11 | "gulp-watch": "5.0.1", 12 | "gulp-concat": "2.6.1", 13 | "gulp-clean-css": "^4.2.0", 14 | "gulp-concat-css": "^3.1.0", 15 | "gulp-less": "^4.0.1", 16 | "gulp-rename": "^2.0.0", 17 | "gulp-sourcemaps": "^2.6.5", 18 | "gulp-uglify": "^3.0.2", 19 | "del": "6.0.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/tempkey.jwk: -------------------------------------------------------------------------------- 1 | {"alg":"RS256","d":"CqYBl8hg0oje1pcU3c5jZAaMDODEmQ6fli2plzxykzmAqvA7nhBCAUQaDmS06qUiGDi7U003VL72EVeBHxiRhnWX-tr7Kes7ZKHe-5iMJ2kNseSg8JnaAgGBRrBJs7JdU2dy94DvbiNC2ubeqiUidLZV2J8KONyzQKMMFJfTIMP8Z5wDXA9BtgjcjoHnDkYKa2jQox9xZVD-q40FVr_FTRPiB4yUEOTlqXLGA1SjTt7hVCQBNYQtF_3uPsN-LjByIxnGYwSfh-8DRpFJ4EFSrgBid7jXiJslT_VBIu9spauD9cZ8G4AuqiIxPsGYjgXlr8ZoYzf7elZGlcAktLKeEQ","dp":"gV--rYS6BfCTdeAdhqm3uM4sxQC5DOw4xHTkcHOLMEdbpEFmOVkDXjDz_FcunNx8Kds3ICT5Nrak4ZBSu7a2SQ_ym9w33ADOWHSGpz0L8VUqQaSm6B2U93weXbirJzT0HbdVEclm3VtVVpVGgbQJIJ-jKHYyFj0mv4ldmGc0_Ls","dq":"sgE5k2y_dpykpX08enP2jJccwMTKzE9ffuOz999PJPXPZjtD5KSaRrqJmVoxlxjcyVasY0Y6WqC0UwvxcHMcSqoimvzTlqG51qwFc6qAIfmCDLQ0sFZRrrmmtPv8s2kslowC1A5kSxHLn8w-1MznzlQuQaka9fL1VM6RmQk4StE","e":"AQAB","kid":"DF6D62F3C64EB499EBBB466EE4CC21AB","kty":"RSA","n":"sS0nZ7IiI0WOjPdrAU47oFMyc7h5AdhUoXuMlgIh7VoQTH3HEB8HN0M2uXoh_jR_hPSQayUkS-6MQTndIycBEv8sPGBzv2DkxQN5TE4FC4zF0PGdWq91QCDMAbRwAU3f_H9TTugydi6fLjmqKm2NwKOaq_djkzeF5gARe0xLpd4Pq1uVSO9BrcFVeQ9Pag2zMB74yLjrRiZ6Dl9Us0Jr9LHbNTGSwJ17ur0J04CUzEn3dzlXbth_QY4cTrBoXPOe1iwFhGlbv5Ftm4vwRsbSYifp78_iZSZb5sz1ErAiNP7Nj3FFedEb2prp5UNu41OFqn5jbxRv3Dnq9GkNZCAcsw","p":"4f-axiqI96GuM7vCm1cegwMMF7OeBlPKlvZgx_U3X0EFcwu0qMFijCUNnzHyv7j8u9zFD3g_WREvkYxXq2XGCf3F9RaCUW_jdXJLq_xyNy7XTYrey371wF7qNhO54U7sdHz_5EIxb2Vsa0_LpH_koNm5n1G3Tfs-bv42j0lwHiM","q":"yLJdv-UGKtpT-pmZVoD7_YF5he6-HUeP6mGC-2B6NSCGttz7sBxkqIYiXFYj-E_2Eu05UdzV7BALSohYhm9HTDu50gbogqIDW5MqSqrxGBNuZBS9qaXbH87oqks9NethOGpW__c6fTgbhi4_EC8gh7NaTm9iOLmfeARcpNnVyDE","qi":"NrPTfRhnKuSttF7pkAkUAQL2dSLMw3c0JuFbNrIrpZPctysltx5Ntqro3_yD-pISBAfJN108Awv4jr0PFsytgexrzM4r1oFgEaDTG0w12XCNBsqXTrszm8_3QaXII_T0Ex3trAzma3SUz-LQ6YClzVjfTJyjETDBdNUjXRv9msw"} -------------------------------------------------------------------------------- /WQLIdentityServerAPI/tempkey.rsa: -------------------------------------------------------------------------------- 1 | {"KeyId":"35033588f80297844900d2c2311cd1a5","Parameters":{"D":"B7W6yp86Z4Op/VI0pXoTjiu7vTm76N5i/z0vmTF2YpIzWt49cK+L2/xnULmE3MXHyTb9D/liimEZe9Sc2vPPOMyHkmJYDQoYxTY5Xde4FJBb8jsP3wdQLFXHN9Zblbh7Ojy65hdDMo1h9LGQDR92rZCn8aeNJq5VaCKIc6zT26R4xBK5sBnOqAHVVICTs6meJ9jVyEwWRQhu0iLErXCpTEb2Z2K3iEeXCqaA34+HdTa0XnZ33+cgeqg7LOK5mDY2qqDch+SPnUCw39alzrgM9kTqzmPgsYfb6TjgLjRqmnK+prlQr8KbeQEH1toZPXkKOKWnieXFDgoq+jAYuQlbgQ==","DP":"HORXNZZUzwc4t/b6D0eGoo9NhGswiX3WBc5q92lA5B5ke7rxmt64ZiqHVLUbX4tdIcuRfy4m3aPkr1EhHKPp/zFqnjPPgmtj8ApPqjIdtP2nBh8ZavHomuWfYXPLn2vx+j7R3NA2SAuEEux7JboHSKfpxl1767DTgTycblT0uS0=","DQ":"o6ofZWlybfNFoMARqyPzXZLEr0bQY6DJ8C4YvBNmpPs7YCdm6KUdvHv/xz9e1byiYrv+r813mxnh3K7lTjL8js8S8sdcTmdPx3HvpQJ0s4GDKNBTcl06izft94Qlf275GhMVAZyi8vXIkjpq4NjCrvApFMd97bh1dglN1lUCNeE=","Exponent":"AQAB","InverseQ":"TUUipJ8G5wHMrepM5874Ow6eLhESPrQDYSklWPCfe6ElTSIggD9IPanmN2A/j7wOCVbAfPVhPwHiPCXgullPhQynasi/Ihs33VwH0LkP3wT5TpVCa0jJyvQZQu+TDqnQGzRExWxaI1vtvMcNVit1vBus/Pi/lB8TZLPCPsPvxSg=","Modulus":"1kOf7ftVvl30uHhyHlqHBc8XdK1Utxs+wNDhhlbMnswNxR5VLz6iyKQDWuRVZ7qiAHIotF9qpiw6Vd3RoqpbG8/LAMl0mE779/pxJad7ZiOQu8RmzPZcQkMo8b7BVdbNoq9n2EkvrBzb2NG3GbYcoDSDGO/y4LpjgzndKfgiHRZ64I781viRHgPJwnBZ9WIrkEnBlPedcn/l0CYfxP09vGMiuAfGgN9djRLBdRRFKxExruGxBQmaJzwCPElWfR+N1ho74o18T5asArGKWg+idPNga8OLk5La/QQTd5HZr3EAyQw69iWrWsnl82V4ncVHkf5lvC7Ka1+xnO+fZpwBZw==","P":"+u01drkKstrgjr9FfNS1XgnopmS4+85RIxf6OhZmovPgC+wY5RMKjAHQnUrXg+0pFsDxXqO5kGliBGdrMi0kZ8qYYRvPFmvTm0Ab1f47it5HXv6x+TEtJd5Jp362oIUI07h9PVbiw+CoN2KFeBFEsBzZ4KC/YNkYKCvjVMrXS08=","Q":"2pim3bd1Yo1ioIMnRXXhlLk+uNWHo+6f0eEzvt5aPVKp+YuLzTnRzexnxxCfYd9x66pHDtFazdFc4WOePAVQqwT/Mh5WuErI9kNcQZ+Cu8/JIG2AQQgEt/52Pah1uEaU7TgHSXJSw6vqlqXkuGreIMd3SsbP7JVa6xqLcdrwgmk="}} -------------------------------------------------------------------------------- /WQLIdentityServerAPI/wwwroot/css/app.min.css: -------------------------------------------------------------------------------- 1 | .body-container{margin-top:60px;padding-bottom:40px}.welcome-page li{list-style:none;padding:4px}.logged-out-page iframe{display:none;width:0;height:0}.grants-page .card{margin-top:20px;border-bottom:1px solid #d3d3d3}.grants-page .card .card-title{font-size:120%;font-weight:700}.grants-page .card .card-title img{width:100px;height:100px}.grants-page .card label{font-weight:700} -------------------------------------------------------------------------------- /WQLIdentityServerAPI/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | .body-container { 2 | margin-top: 60px; 3 | padding-bottom: 40px; } 4 | 5 | .welcome-page li { 6 | list-style: none; 7 | padding: 4px; } 8 | 9 | .logged-out-page iframe { 10 | display: none; 11 | width: 0; 12 | height: 0; } 13 | 14 | .grants-page .card { 15 | margin-top: 20px; 16 | border-bottom: 1px solid lightgray; } 17 | .grants-page .card .card-title { 18 | font-size: 120%; 19 | font-weight: bold; } 20 | .grants-page .card .card-title img { 21 | width: 100px; 22 | height: 100px; } 23 | .grants-page .card label { 24 | font-weight: bold; } 25 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/wwwroot/css/site.scss: -------------------------------------------------------------------------------- 1 | .body-container { 2 | margin-top: 60px; 3 | padding-bottom:40px; 4 | } 5 | 6 | .welcome-page { 7 | li { 8 | list-style: none; 9 | padding: 4px; 10 | } 11 | } 12 | 13 | .logged-out-page { 14 | iframe { 15 | display: none; 16 | width: 0; 17 | height: 0; 18 | } 19 | } 20 | 21 | .grants-page { 22 | .card { 23 | margin-top: 20px; 24 | border-bottom: 1px solid lightgray; 25 | 26 | .card-title { 27 | img { 28 | width: 100px; 29 | height: 100px; 30 | } 31 | 32 | font-size: 120%; 33 | font-weight: bold; 34 | } 35 | 36 | label { 37 | font-weight: bold; 38 | } 39 | } 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/WQLIdentityServerAPI/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WQLIdentityServerAPI/wwwroot/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/WQLIdentityServerAPI/wwwroot/icon.jpg -------------------------------------------------------------------------------- /WQLIdentityServerAPI/wwwroot/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/WQLIdentityServerAPI/wwwroot/icon.png -------------------------------------------------------------------------------- /WQLIdentityServerAPI/wwwroot/js/app.min.js: -------------------------------------------------------------------------------- 1 | window.location.href=document.querySelector("meta[http-equiv=refresh]").getAttribute("data-url"),window.addEventListener("load",function(){var e=document.querySelector("a.PostLogoutRedirectUri");e&&(window.location=e.href)}); -------------------------------------------------------------------------------- /WQLIdentityServerAPI/wwwroot/js/signin-redirect.js: -------------------------------------------------------------------------------- 1 | window.location.href = document.querySelector("meta[http-equiv=refresh]").getAttribute("data-url"); 2 | -------------------------------------------------------------------------------- /WQLIdentityServerAPI/wwwroot/js/signout-redirect.js: -------------------------------------------------------------------------------- 1 | window.addEventListener("load", function () { 2 | var a = document.querySelector("a.PostLogoutRedirectUri"); 3 | if (a) { 4 | window.location = a.href; 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /WQLIdentityTestFaker/ApiResourceFaker.cs: -------------------------------------------------------------------------------- 1 | using Bogus; 2 | using IdentityServer4.EntityFramework.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace WQLIdentityTestFaker 8 | { 9 | public class ApiResourceFaker 10 | { 11 | public static Faker GenerateApiResource(string name = null, bool addApiSecrets = true, bool addUserClaims = true) 12 | { 13 | return new Faker() 14 | .RuleFor(a => a.Secrets, f => addApiSecrets ? GenerateSecret().Generate(f.Random.Int(0, 2)) : new List()) 15 | .RuleFor(a => a.Enabled, f => f.Random.Bool()) 16 | .RuleFor(a => a.Name, f => name ?? f.Internet.DomainName()) 17 | .RuleFor(a => a.DisplayName, f => f.Lorem.Word()) 18 | .RuleFor(a => a.Scopes, f => GenerateScope().Generate(f.Random.Int(0, 2))) 19 | .RuleFor(a => a.Description, f => f.Lorem.Word()) 20 | .RuleFor(a => a.UserClaims,f=> GenerateUserCliam().Generate(f.Random.Int(0,3))); 21 | } 22 | 23 | public static Faker GenerateSecret() 24 | { 25 | return new Faker() 26 | .RuleFor(s => s.Description, f => f.Lorem.Word()) 27 | .RuleFor(s => s.Value, f => f.Lorem.Word()) 28 | .RuleFor(s => s.Type, f => f.PickRandom(IdentityHelpers.SecretTypes)); 29 | } 30 | public static Faker GenerateScope() 31 | { 32 | return new Faker() 33 | .RuleFor(s => s.Scope, f => f.Lorem.Word()); 34 | 35 | } 36 | public static Faker GenerateUserCliam() 37 | { 38 | return new Faker() 39 | .RuleFor(s => s.Type, f => f.Lorem.Word()); 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /WQLIdentityTestFaker/IdentityHelpers.cs: -------------------------------------------------------------------------------- 1 | namespace WQLIdentityTestFaker 2 | { 3 | public class IdentityHelpers 4 | { 5 | public static string[] Providers = 6 | { 7 | "facebook", 8 | "google" 9 | }; 10 | 11 | public static string[] Scopes = 12 | { 13 | "openid", 14 | "profile", 15 | "email", 16 | "username", 17 | "roles", 18 | }; 19 | 20 | public static string[] Claims = 21 | { 22 | "sub", 23 | "name", 24 | "given_name", 25 | "family_name", 26 | "middle_name", 27 | "nickname", 28 | "preferred_username", 29 | "profile", 30 | "picture", 31 | "website", 32 | "email", 33 | "email_verified", 34 | "gender", 35 | "birthdate", 36 | "zoneinfo", 37 | "locale", 38 | "phone_number", 39 | "phone_number_verified", 40 | "address", 41 | "updated_at" 42 | }; 43 | public static string[] Grantypes = 44 | { 45 | "implicit", 46 | "client_credentials", 47 | "authorization_code", 48 | "hybrid", 49 | "password", 50 | "urn:ietf:params:oauth:grant-type:device_code" 51 | }; 52 | 53 | public static string[] SecretTypes = 54 | { 55 | "SharedSecret", 56 | "X509Thumbprint", 57 | "X509Name", 58 | "X509CertificateBase64" 59 | }; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /WQLIdentityTestFaker/WQLIdentityTestFaker.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/.env: -------------------------------------------------------------------------------- 1 | VUE_APP_OIDC_CONFIG={"authority": "http://47.119.119.183:8081", "clientId": "IdentityServer4", "redirectUri": "http://localhost:8082/oidc-callback", "popupRedirectUri": "http://localhost:8082/oidc-popup-callback", "responseType": "id_token token", "scope": "openid profile offline_access IdentityServer.API", "automaticSilentRenew": true, "automaticSilentSignin": false, "silentRedirectUri": "http://localhost:8082/silent-renew-oidc.html" , "post_logout_redirect_uri": "http://localhost:8082" } -------------------------------------------------------------------------------- /Web/IdentityServerSites/.env.production: -------------------------------------------------------------------------------- 1 | VUE_APP_OIDC_CONFIG={"authority": "http://47.119.119.183:8081", "clientId": "IdentityServer4", "redirectUri": "http://47.119.119.183:8082/oidc-callback", "popupRedirectUri": "http://47.119.119.183:8082/oidc-popup-callback", "responseType": "id_token token", "scope": "openid profile offline_access IdentityServer.API", "automaticSilentRenew": true, "automaticSilentSignin": false, "silentRedirectUri": "http://47.119.119.183:8082/silent-renew-oidc.html" , "post_logout_redirect_uri": "http://47.119.119.183:8082" } -------------------------------------------------------------------------------- /Web/IdentityServerSites/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/README.md: -------------------------------------------------------------------------------- 1 | # identityserversites 2 | 3 | ## Project setup 4 | ``` 5 | yarn install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | yarn run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | yarn run build 16 | ``` 17 | 18 | ### Run your tests 19 | ``` 20 | yarn run test 21 | ``` 22 | 23 | ### Lints and fixes files 24 | ``` 25 | yarn run lint 26 | ``` 27 | 28 | ### Customize configuration 29 | See [Configuration Reference](https://cli.vuejs.org/config/). 30 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/app"] 3 | }; 4 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/Web/IdentityServerSites/public/favicon.ico -------------------------------------------------------------------------------- /Web/IdentityServerSites/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | identityserversites 9 | 10 | 11 | 14 |
    15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/App.vue: -------------------------------------------------------------------------------- 1 | 8 | 14 | 15 | 20 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/assets/imgs/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/Web/IdentityServerSites/src/assets/imgs/back.jpg -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/assets/imgs/wqlapi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/Web/IdentityServerSites/src/assets/imgs/wqlapi.png -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/components/Hamburger/index.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 32 | 33 | 45 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/components/SignedInUser.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 53 | 54 | 66 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/components/SvgIcon/index.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 47 | 48 | 63 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/components/modules/ClaimCreate.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 77 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/components/modules/RoleEdit.vue: -------------------------------------------------------------------------------- 1 | 21 | 83 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/config/oidc.js: -------------------------------------------------------------------------------- 1 | export const oidcSettings = JSON.parse(process.env.VUE_APP_OIDC_CONFIG) 2 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import SvgIcon from '@/components/SvgIcon'// svg component 3 | 4 | // register globally 5 | Vue.component('svg-icon', SvgIcon) 6 | 7 | const req = require.context('./svg', false, /\.svg$/) 8 | const requireAll = requireContext => requireContext.keys().map(requireContext) 9 | requireAll(req) 10 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/dashboard.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/example.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/eye-open.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/eye.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/link.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/nested.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/password.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/table.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/tree.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svg/user.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/icons/svgo.yml: -------------------------------------------------------------------------------- 1 | # replace default config 2 | 3 | # multipass: true 4 | # full: true 5 | 6 | plugins: 7 | 8 | # - name 9 | # 10 | # or: 11 | # - name: false 12 | # - name: true 13 | # 14 | # or: 15 | # - name: 16 | # param1: 1 17 | # param2: 2 18 | 19 | - removeAttrs: 20 | attrs: 21 | - 'fill' 22 | - 'fill-rule' 23 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/layout/components/AppMain.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 19 | 20 | 32 | 33 | 41 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/layout/components/Sidebar/FixiOSBug.js: -------------------------------------------------------------------------------- 1 | export default { 2 | computed: { 3 | device() { 4 | return this.$store.state.app.device 5 | } 6 | }, 7 | mounted() { 8 | // In order to fix the click on menu on the ios device will trigger the mouseleave bug 9 | // https://github.com/PanJiaChen/vue-element-admin/issues/1135 10 | this.fixBugIniOS() 11 | }, 12 | methods: { 13 | fixBugIniOS() { 14 | const $subMenu = this.$refs.subMenu 15 | if ($subMenu) { 16 | const handleMouseleave = $subMenu.handleMouseleave 17 | $subMenu.handleMouseleave = (e) => { 18 | if (this.device === 'mobile') { 19 | return 20 | } 21 | handleMouseleave(e) 22 | } 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/layout/components/Sidebar/Item.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | 42 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/layout/components/Sidebar/Link.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 44 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/layout/components/Sidebar/Logo.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 33 | 34 | 83 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/layout/components/Sidebar/index.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 58 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/layout/components/index.js: -------------------------------------------------------------------------------- 1 | export { default as Navbar } from './Navbar' 2 | export { default as Sidebar } from './Sidebar' 3 | export { default as AppMain } from './AppMain' 4 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/layout/mixin/ResizeHandler.js: -------------------------------------------------------------------------------- 1 | import store from '@/store' 2 | 3 | const { body } = document 4 | const WIDTH = 992 // refer to Bootstrap's responsive design 5 | 6 | export default { 7 | watch: { 8 | $route(route) { 9 | if (this.device === 'mobile' && this.sidebar.opened) { 10 | store.dispatch('app/closeSideBar', { withoutAnimation: false }) 11 | } 12 | } 13 | }, 14 | beforeMount() { 15 | window.addEventListener('resize', this.$_resizeHandler) 16 | }, 17 | beforeDestroy() { 18 | window.removeEventListener('resize', this.$_resizeHandler) 19 | }, 20 | mounted() { 21 | const isMobile = this.$_isMobile() 22 | if (isMobile) { 23 | store.dispatch('app/toggleDevice', 'mobile') 24 | store.dispatch('app/closeSideBar', { withoutAnimation: true }) 25 | } 26 | }, 27 | methods: { 28 | // use $_ for mixins properties 29 | // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential 30 | $_isMobile() { 31 | const rect = body.getBoundingClientRect() 32 | return rect.width - 1 < WIDTH 33 | }, 34 | $_resizeHandler() { 35 | if (!document.hidden) { 36 | const isMobile = this.$_isMobile() 37 | store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop') 38 | 39 | if (isMobile) { 40 | store.dispatch('app/closeSideBar', { withoutAnimation: true }) 41 | } 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import 'normalize.css/normalize.css' // A modern alternative to CSS resets 3 | 4 | 5 | import ElementUI from 'element-ui' 6 | import 'element-ui/lib/theme-chalk/index.css' 7 | 8 | import '@/styles/index.scss' // global css 9 | 10 | import App from './App.vue' 11 | import store from './store' 12 | import router from './router' 13 | 14 | import './icons' 15 | 16 | 17 | 18 | import http from './plugin/http' 19 | 20 | Vue.use(ElementUI) 21 | Vue.use(http) 22 | 23 | Vue.config.productionTip = false 24 | 25 | new Vue({ 26 | router, 27 | store, 28 | render: (h) => h(App), 29 | }).$mount('#app') 30 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/services/uilts.js: -------------------------------------------------------------------------------- 1 | export default { 2 | CheckPermiss(requierd, currnet) { 3 | if (!currnet) return false; 4 | if (!Array.isArray(currnet)) { 5 | if (requierd.indexOf(currnet) < 0) { 6 | return false; 7 | } else { 8 | return true; 9 | } 10 | } 11 | currnet.forEach(element => { 12 | if (requierd.indexOf(element) < 0) return false; 13 | }); 14 | return true; 15 | }, 16 | 17 | distinct(a) { 18 | return Array.from(new Set([...a])) 19 | } 20 | } -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/settings.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | title: 'Vue Admin Template', 4 | 5 | /** 6 | * @type {boolean} true | false 7 | * @description Whether fix the header 8 | */ 9 | fixedHeader: false, 10 | 11 | /** 12 | * @type {boolean} true | false 13 | * @description Whether show the logo in sidebar 14 | */ 15 | sidebarLogo: true 16 | } 17 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/silent-renew-oidc.js: -------------------------------------------------------------------------------- 1 | import 'core-js/fn/promise' 2 | import { vuexOidcProcessSilentSignInCallback } from 'vuex-oidc' 3 | 4 | vuexOidcProcessSilentSignInCallback() 5 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/store/getters.js: -------------------------------------------------------------------------------- 1 | const getters = { 2 | sidebar: state => state.app.sidebar, 3 | device: state => state.app.device, 4 | token: state => state.user.token, 5 | avatar: state => state.user.avatar, 6 | name: state => state.user.name 7 | } 8 | export default getters 9 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import getters from './getters' 4 | import app from './modules/app' 5 | import settings from './modules/settings' 6 | import user from './modules/user' 7 | 8 | import { vuexOidcCreateStoreModule } from 'vuex-oidc' 9 | import { oidcSettings } from '../config/oidc' 10 | 11 | Vue.use(Vuex) 12 | 13 | const store = new Vuex.Store({ 14 | modules: { 15 | app, 16 | settings, 17 | user, 18 | oidcStore: vuexOidcCreateStoreModule( 19 | oidcSettings, 20 | // NOTE: If you do not want to use localStorage for tokens, in stead of just passing oidcSettings, you can 21 | // spread your oidcSettings and define a userStore of your choice 22 | // { 23 | // ...oidcSettings, 24 | // userStore: new WebStorageStateStore({ store: window.sessionStorage }) 25 | // }, 26 | // Optional OIDC store settings 27 | { 28 | namespaced: false, 29 | dispatchEventsOnWindow: true, 30 | }, 31 | // Optional OIDC event listeners 32 | { 33 | userLoaded: (user) => console.log('OIDC user is loaded:', user), 34 | userUnloaded: () => console.log('OIDC user is unloaded'), 35 | accessTokenExpiring: () => console.log('Access token will expire'), 36 | accessTokenExpired: () => console.log('Access token did expire'), 37 | silentRenewError: () => console.log('OIDC user is unloaded'), 38 | userSignedOut: () => console.log('OIDC user is signed out'), 39 | oidcError: (payload) => console.log('OIDC error', payload), 40 | automaticSilentRenewError: (payload) => 41 | console.log('OIDC automaticSilentRenewError', payload), 42 | } 43 | ) 44 | }, 45 | 46 | getters 47 | }) 48 | 49 | export default store 50 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/store/modules/app.js: -------------------------------------------------------------------------------- 1 | import Cookies from 'js-cookie' 2 | 3 | const state = { 4 | sidebar: { 5 | opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, 6 | withoutAnimation: false 7 | }, 8 | device: 'desktop' 9 | } 10 | 11 | const mutations = { 12 | TOGGLE_SIDEBAR: state => { 13 | state.sidebar.opened = !state.sidebar.opened 14 | state.sidebar.withoutAnimation = false 15 | if (state.sidebar.opened) { 16 | Cookies.set('sidebarStatus', 1) 17 | } else { 18 | Cookies.set('sidebarStatus', 0) 19 | } 20 | }, 21 | CLOSE_SIDEBAR: (state, withoutAnimation) => { 22 | Cookies.set('sidebarStatus', 0) 23 | state.sidebar.opened = false 24 | state.sidebar.withoutAnimation = withoutAnimation 25 | }, 26 | TOGGLE_DEVICE: (state, device) => { 27 | state.device = device 28 | } 29 | } 30 | 31 | const actions = { 32 | toggleSideBar({ commit }) { 33 | commit('TOGGLE_SIDEBAR') 34 | }, 35 | closeSideBar({ commit }, { withoutAnimation }) { 36 | commit('CLOSE_SIDEBAR', withoutAnimation) 37 | }, 38 | toggleDevice({ commit }, device) { 39 | commit('TOGGLE_DEVICE', device) 40 | } 41 | } 42 | 43 | export default { 44 | namespaced: true, 45 | state, 46 | mutations, 47 | actions 48 | } 49 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/store/modules/settings.js: -------------------------------------------------------------------------------- 1 | import defaultSettings from '@/settings' 2 | 3 | const { showSettings, fixedHeader, sidebarLogo } = defaultSettings 4 | 5 | const state = { 6 | showSettings: showSettings, 7 | fixedHeader: fixedHeader, 8 | sidebarLogo: sidebarLogo 9 | } 10 | 11 | const mutations = { 12 | CHANGE_SETTING: (state, { key, value }) => { 13 | // eslint-disable-next-line no-prototype-builtins 14 | if (state.hasOwnProperty(key)) { 15 | state[key] = value 16 | } 17 | } 18 | } 19 | 20 | const actions = { 21 | changeSetting({ commit }, data) { 22 | commit('CHANGE_SETTING', data) 23 | } 24 | } 25 | 26 | export default { 27 | namespaced: true, 28 | state, 29 | mutations, 30 | actions 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/store/modules/user.js: -------------------------------------------------------------------------------- 1 | import cookie from "js-cookie"; 2 | 3 | 4 | const SET_TOKEN = "set_token" 5 | const SET_USERNAME = "set_username" 6 | 7 | export default { 8 | state: { 9 | access_token: "", 10 | username: "", 11 | userId: "", 12 | name: "" 13 | }, 14 | 15 | mutations: { 16 | [SET_TOKEN](state, access_token) { 17 | state.access_token = access_token; 18 | }, 19 | [SET_USERNAME](state, username) { 20 | state.username = username 21 | }, 22 | 23 | }, 24 | actions: { 25 | set_token({ commit }, access_token) { 26 | commit(SET_TOKEN, access_token); 27 | cookie.set("access_token", access_token, { expires: 1 }); 28 | }, 29 | del_token({ commit }) { 30 | commit(SET_TOKEN, "") 31 | cookie.remove("access_token"); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/styles/element-ui.scss: -------------------------------------------------------------------------------- 1 | // cover some element-ui styles 2 | 3 | .el-breadcrumb__inner, 4 | .el-breadcrumb__inner a { 5 | font-weight: 400 !important; 6 | } 7 | 8 | .el-upload { 9 | input[type="file"] { 10 | display: none !important; 11 | } 12 | } 13 | 14 | .el-upload__input { 15 | display: none; 16 | } 17 | 18 | 19 | // to fixed https://github.com/ElemeFE/element/issues/2461 20 | .el-dialog { 21 | transform: none; 22 | left: 0; 23 | position: relative; 24 | margin: 0 auto; 25 | } 26 | 27 | // refine element ui upload 28 | .upload-container { 29 | .el-upload { 30 | width: 100%; 31 | 32 | .el-upload-dragger { 33 | width: 100%; 34 | height: 200px; 35 | } 36 | } 37 | } 38 | 39 | // dropdown 40 | .el-dropdown-menu { 41 | a { 42 | display: block 43 | } 44 | } 45 | 46 | // to fix el-date-picker css style 47 | .el-range-separator { 48 | box-sizing: content-box; 49 | } 50 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/styles/index.scss: -------------------------------------------------------------------------------- 1 | @import './variables.scss'; 2 | @import './mixin.scss'; 3 | @import './transition.scss'; 4 | @import './element-ui.scss'; 5 | @import './sidebar.scss'; 6 | 7 | body { 8 | height: 100%; 9 | -moz-osx-font-smoothing: grayscale; 10 | -webkit-font-smoothing: antialiased; 11 | text-rendering: optimizeLegibility; 12 | font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif; 13 | } 14 | 15 | label { 16 | font-weight: 700; 17 | } 18 | 19 | html { 20 | height: 100%; 21 | box-sizing: border-box; 22 | } 23 | 24 | #app { 25 | height: 100%; 26 | } 27 | 28 | *, 29 | *:before, 30 | *:after { 31 | box-sizing: inherit; 32 | } 33 | 34 | a:focus, 35 | a:active { 36 | outline: none; 37 | } 38 | 39 | a, 40 | a:focus, 41 | a:hover { 42 | cursor: pointer; 43 | color: inherit; 44 | text-decoration: none; 45 | } 46 | 47 | div:focus { 48 | outline: none; 49 | } 50 | 51 | .clearfix { 52 | &:after { 53 | visibility: hidden; 54 | display: block; 55 | font-size: 0; 56 | content: " "; 57 | clear: both; 58 | height: 0; 59 | } 60 | } 61 | 62 | // main-container global css 63 | .app-container { 64 | padding: 20px; 65 | 66 | } 67 | 68 | //工具栏标题 69 | .tool-header{ 70 | margin-bottom: 5px; 71 | .tool-header-right{ 72 | position: absolute; 73 | right: 5px; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/styles/mixin.scss: -------------------------------------------------------------------------------- 1 | @mixin clearfix { 2 | &:after { 3 | content: ""; 4 | display: table; 5 | clear: both; 6 | } 7 | } 8 | 9 | @mixin scrollBar { 10 | &::-webkit-scrollbar-track-piece { 11 | background: #d3dce6; 12 | } 13 | 14 | &::-webkit-scrollbar { 15 | width: 6px; 16 | } 17 | 18 | &::-webkit-scrollbar-thumb { 19 | background: #99a9bf; 20 | border-radius: 20px; 21 | } 22 | } 23 | 24 | @mixin relative { 25 | position: relative; 26 | width: 100%; 27 | height: 100%; 28 | } 29 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/styles/transition.scss: -------------------------------------------------------------------------------- 1 | // global transition css 2 | 3 | /* fade */ 4 | .fade-enter-active, 5 | .fade-leave-active { 6 | transition: opacity 0.28s; 7 | } 8 | 9 | .fade-enter, 10 | .fade-leave-active { 11 | opacity: 0; 12 | } 13 | 14 | /* fade-transform */ 15 | .fade-transform-leave-active, 16 | .fade-transform-enter-active { 17 | transition: all .5s; 18 | } 19 | 20 | .fade-transform-enter { 21 | opacity: 0; 22 | transform: translateX(-30px); 23 | } 24 | 25 | .fade-transform-leave-to { 26 | opacity: 0; 27 | transform: translateX(30px); 28 | } 29 | 30 | /* breadcrumb transition */ 31 | .breadcrumb-enter-active, 32 | .breadcrumb-leave-active { 33 | transition: all .5s; 34 | } 35 | 36 | .breadcrumb-enter, 37 | .breadcrumb-leave-active { 38 | opacity: 0; 39 | transform: translateX(20px); 40 | } 41 | 42 | .breadcrumb-move { 43 | transition: all .5s; 44 | } 45 | 46 | .breadcrumb-leave-active { 47 | position: absolute; 48 | } 49 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/styles/variables.scss: -------------------------------------------------------------------------------- 1 | // sidebar 2 | $menuText:#bfcbd9; 3 | $menuActiveText:#409EFF; 4 | $subMenuActiveText:#f4f4f5; //https://github.com/ElemeFE/element/issues/12951 5 | 6 | $menuBg:#304156; 7 | $menuHover:#263445; 8 | 9 | $subMenuBg:#1f2d3d; 10 | $subMenuHover:#001528; 11 | 12 | $sideBarWidth: 210px; 13 | 14 | // the :export directive is the magic sauce for webpack 15 | // https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass 16 | :export { 17 | menuText: $menuText; 18 | menuActiveText: $menuActiveText; 19 | subMenuActiveText: $subMenuActiveText; 20 | menuBg: $menuBg; 21 | menuHover: $menuHover; 22 | subMenuBg: $subMenuBg; 23 | subMenuHover: $subMenuHover; 24 | sideBarWidth: $sideBarWidth; 25 | } 26 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/utils/auth.js: -------------------------------------------------------------------------------- 1 | import Cookies from 'js-cookie' 2 | 3 | const TokenKey = 'vue_admin_template_token' 4 | 5 | export function getToken() { 6 | return Cookies.get(TokenKey) 7 | } 8 | 9 | export function setToken(token) { 10 | return Cookies.set(TokenKey, token) 11 | } 12 | 13 | export function removeToken() { 14 | return Cookies.remove(TokenKey) 15 | } 16 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/utils/get-page-title.js: -------------------------------------------------------------------------------- 1 | import defaultSettings from '@/settings' 2 | 3 | const title = defaultSettings.title || 'Vue Admin Template' 4 | 5 | export default function getPageTitle(pageTitle) { 6 | if (pageTitle) { 7 | return `${pageTitle} - ${title}` 8 | } 9 | return `${title}` 10 | } 11 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/utils/validate.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by PanJiaChen on 16/11/18. 3 | */ 4 | 5 | /** 6 | * @param {string} path 7 | * @returns {Boolean} 8 | */ 9 | export function isExternal(path) { 10 | return /^(https?:|mailto:|tel:)/.test(path) 11 | } 12 | 13 | /** 14 | * @param {string} str 15 | * @returns {Boolean} 16 | */ 17 | export function validUsername(str) { 18 | const valid_map = ['admin', 'editor'] 19 | return valid_map.indexOf(str.trim()) >= 0 20 | } 21 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/views/About.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/views/AccessDenied.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 19 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 34 | 35 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/views/oidcs/Callback.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 41 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/views/oidcs/OidcCallbackError.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/views/oidcs/OidcPopupCallback.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 20 | -------------------------------------------------------------------------------- /Web/IdentityServerSites/src/views/oidcs/Protected.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 24 | -------------------------------------------------------------------------------- /auth.rp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/auth.rp -------------------------------------------------------------------------------- /doc/imgs/client.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/doc/imgs/client.bmp -------------------------------------------------------------------------------- /doc/imgs/server.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w757703598/WQLIdentityServer4/de2b76371cabe0c7c0c1b915c9beb71335f15b8d/doc/imgs/server.bmp --------------------------------------------------------------------------------