Browse Source

新增IdentityServer4 Client 和 ApiResource接口

pull/6/head
WangJunZzz 5 years ago
parent
commit
e9861ea51d
  1. 7
      aspnet-core/CompanyName.ProjectName.sln
  2. 27
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/Dtos/ApiResourceOutput.cs
  3. 35
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/Dtos/CreateApiResourceInput.cs
  4. 9
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/Dtos/PagingApiRseourceListInput.cs
  5. 35
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/Dtos/UpdateApiResourceInput.cs
  6. 38
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/IApiResourceAppService.cs
  7. 13
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/AddCorsInput.cs
  8. 13
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/AddRedirectUriInput.cs
  9. 14
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientClaimOutput.cs
  10. 12
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientCorsOriginOutput.cs
  11. 11
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientGrantTypeOutput.cs
  12. 12
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientIdPRestrictionOutput.cs
  13. 105
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientOutput.cs
  14. 12
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientPostLogoutRedirectUriOutput.cs
  15. 14
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientPropertyOutput.cs
  16. 11
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientRedirectUriOutput.cs
  17. 11
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientScopeOutput.cs
  18. 15
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientSecretOutput.cs
  19. 13
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/CreateClientInput.cs
  20. 9
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/PagingClientListInput.cs
  21. 13
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/RemoveCorsInput.cs
  22. 13
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/RemoveRedirectUriInput.cs
  23. 83
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/UpdataBasicDataInput.cs
  24. 18
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/UpdateScopeInput.cs
  25. 71
      aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/IIdentityServerClientAppService.cs
  26. 92
      aspnet-core/services/src/CompanyName.ProjectName.Application/IdentityServers/ApiResources/ApiResourceAppService.cs
  27. 157
      aspnet-core/services/src/CompanyName.ProjectName.Application/IdentityServers/Clients/IdentityServerClientAppService.cs
  28. 50
      aspnet-core/services/src/CompanyName.ProjectName.Application/IdentityServers/Mappers/IdentityServerApplicationAutoMapperProfile.cs
  29. 11
      aspnet-core/services/src/CompanyName.ProjectName.Domain.Shared/IdentityServers/ApiResources/Dtos/ApiResourceClaimOutput.cs
  30. 13
      aspnet-core/services/src/CompanyName.ProjectName.Domain.Shared/IdentityServers/ApiResources/Dtos/ApiResourcePropertyOutput.cs
  31. 11
      aspnet-core/services/src/CompanyName.ProjectName.Domain.Shared/IdentityServers/ApiResources/Dtos/ApiResourceScopeOutput.cs
  32. 17
      aspnet-core/services/src/CompanyName.ProjectName.Domain.Shared/IdentityServers/ApiResources/Dtos/ApiResourceSecretOutput.cs
  33. 133
      aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerApiResourceManager.cs
  34. 260
      aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerClientManager.cs
  35. 1112
      aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/Logs/logs.txt
  36. 59
      aspnet-core/services/src/CompanyName.ProjectName.HttpApi/Controllers/IdentityServers/ApiResourceController.cs
  37. 98
      aspnet-core/services/src/CompanyName.ProjectName.HttpApi/Controllers/IdentityServers/ClientController.cs
  38. 11
      aspnet-core/services/src/CompanyName.ProjectName.HttpApi/Models/Test/TestModel.cs

7
aspnet-core/CompanyName.ProjectName.sln

@ -161,6 +161,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "host", "host", "{5AACD0EE-F
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyName.ProjectName.DataDictionaryManagement.HttpApi.Host", "modules\DataDictionaryManagement\host\CompanyName.ProjectName.DataDictionaryManagement.HttpApi.Host\CompanyName.ProjectName.DataDictionaryManagement.HttpApi.Host.csproj", "{8D196E3D-6F95-4793-B948-79669AF09017}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyName.ProjectName.DataDictionaryManagement.HttpApi.Host", "modules\DataDictionaryManagement\host\CompanyName.ProjectName.DataDictionaryManagement.HttpApi.Host\CompanyName.ProjectName.DataDictionaryManagement.HttpApi.Host.csproj", "{8D196E3D-6F95-4793-B948-79669AF09017}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "host", "host", "{8C1B8C6C-C518-4290-B070-622CCA6004DA}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -415,8 +417,6 @@ Global
{520659C8-C734-4298-A3DA-B539DB9DFC0B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {520659C8-C734-4298-A3DA-B539DB9DFC0B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{4164BDF7-F527-4E85-9CE6-E3C2D7426A27} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {4164BDF7-F527-4E85-9CE6-E3C2D7426A27} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {3B5A0094-670D-4BB1-BFDD-61B88A8773DC} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{073C361E-B8F4-49F5-93CC-72A3FF49C026} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{E6D5BF0E-DE92-4D82-A352-EF04B37CB11C} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{91853F21-9CD9-4132-BC29-A7D5D84FFFE7} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {91853F21-9CD9-4132-BC29-A7D5D84FFFE7} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{E512F4D9-9375-480F-A2F6-A46509F9D824} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {E512F4D9-9375-480F-A2F6-A46509F9D824} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
@ -476,6 +476,9 @@ Global
{6A398750-D7D8-43DC-8DF8-AA65C5766154} = {E76E35FC-B62E-48D5-A7AF-79375CFD20BD} {6A398750-D7D8-43DC-8DF8-AA65C5766154} = {E76E35FC-B62E-48D5-A7AF-79375CFD20BD}
{5AACD0EE-F2B2-49F6-868F-8FE08D7243C0} = {9C53260A-6F4B-4106-98B0-EDCC10BB3E1A} {5AACD0EE-F2B2-49F6-868F-8FE08D7243C0} = {9C53260A-6F4B-4106-98B0-EDCC10BB3E1A}
{8D196E3D-6F95-4793-B948-79669AF09017} = {5AACD0EE-F2B2-49F6-868F-8FE08D7243C0} {8D196E3D-6F95-4793-B948-79669AF09017} = {5AACD0EE-F2B2-49F6-868F-8FE08D7243C0}
{8C1B8C6C-C518-4290-B070-622CCA6004DA} = {2C861ADD-76E9-4B3B-8A3C-638EBB67D683}
{E6D5BF0E-DE92-4D82-A352-EF04B37CB11C} = {8C1B8C6C-C518-4290-B070-622CCA6004DA}
{073C361E-B8F4-49F5-93CC-72A3FF49C026} = {8C1B8C6C-C518-4290-B070-622CCA6004DA}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}

27
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/Dtos/ApiResourceOutput.cs

@ -0,0 +1,27 @@
using System.Collections.Generic;
namespace CompanyName.ProjectName.IdentityServers.Dtos
{
public class ApiResourceOutput
{
public string Name { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public bool Enabled { get; set; }
public string AllowedAccessTokenSigningAlgorithms { get; set; }
public bool ShowInDiscoveryDocument { get; set; } = true;
public List<ApiResourceSecretOutput> Secrets { get; set; }
public List<ApiResourceScopeOutput> Scopes { get; set; }
public List<ApiResourceClaimOutput> UserClaims { get; set; }
public List<ApiResourcePropertyOutput> Properties { get; set; }
}
}

35
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/Dtos/CreateApiResourceInput.cs

@ -0,0 +1,35 @@
using System.Collections.Generic;
namespace CompanyName.ProjectName.IdentityServers.Dtos
{
public class CreateApiResourceInput
{
public string Name { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public bool Enabled { get; set; }
public string AllowedAccessTokenSigningAlgorithms { get; set; }
public bool ShowInDiscoveryDocument { get; set; } = true;
public List<ApiResourceSecretOutput> Secrets { get; set; }
public List<ApiResourceScopeOutput> Scopes { get; set; }
public List<ApiResourceClaimOutput> UserClaims { get; set; }
public List<ApiResourcePropertyOutput> Properties { get; set; }
public CreateApiResourceInput()
{
Secrets = new List<ApiResourceSecretOutput>();
Scopes = new List<ApiResourceScopeOutput>();
UserClaims = new List<ApiResourceClaimOutput>();
Properties = new List<ApiResourcePropertyOutput>();
}
}
}

9
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/Dtos/PagingApiRseourceListInput.cs

@ -0,0 +1,9 @@
using CompanyName.ProjectName.Extensions.Customs;
namespace CompanyName.ProjectName.IdentityServers.Dtos
{
public class PagingApiRseourceListInput : PagingBase
{
public string Filter { get; set; }
}
}

35
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/Dtos/UpdateApiResourceInput.cs

@ -0,0 +1,35 @@
using System.Collections.Generic;
namespace CompanyName.ProjectName.IdentityServers.Dtos
{
public class UpdateApiResourceInput
{
public string Name { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public bool Enabled { get; set; }
public string AllowedAccessTokenSigningAlgorithms { get; set; }
public bool ShowInDiscoveryDocument { get; set; } = true;
public List<ApiResourceSecretOutput> Secrets { get; set; }
public List<ApiResourceScopeOutput> Scopes { get; set; }
public List<ApiResourceClaimOutput> UserClaims { get; set; }
public List<ApiResourcePropertyOutput> Properties { get; set; }
public UpdateApiResourceInput()
{
Secrets = new List<ApiResourceSecretOutput>();
Scopes = new List<ApiResourceScopeOutput>();
UserClaims = new List<ApiResourceClaimOutput>();
Properties = new List<ApiResourcePropertyOutput>();
}
}
}

38
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/ApiResources/IApiResourceAppService.cs

@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using CompanyName.ProjectName.IdentityServers.Dtos;
using CompanyName.ProjectName.Publics.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace CompanyName.ProjectName.IdentityServers
{
public interface IApiResourceAppService : IApplicationService
{
Task<PagedResultDto<ApiResourceOutput>> GetListAsync(PagingApiRseourceListInput input);
/// <summary>
/// 获取所有api resource
/// </summary>
/// <returns></returns>
Task<List<ApiResourceOutput>> GetApiResources();
/// <summary>
/// 新增 ApiResource
/// </summary>
/// <returns></returns>
Task CreateAsync(CreateApiResourceInput input);
/// <summary>
/// 删除 ApiResource
/// </summary>
/// <returns></returns>
Task DeleteAsync(IdInput input);
/// <summary>
/// 更新 ApiResource
/// </summary>
/// <returns></returns>
Task UpdateAsync(UpdateApiResourceInput input);
}
}

13
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/AddCorsInput.cs

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class AddCorsInput
{
[Required]
public string ClientId { get; set; }
[Required]
public string Origin { get; set; }
}
}

13
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/AddRedirectUriInput.cs

@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class AddRedirectUriInput
{
[Required]
public string ClientId { get; set; }
[Required]
public string Uri { get; set; }
}
}

14
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientClaimOutput.cs

@ -0,0 +1,14 @@
using System;
using Volo.Abp.Application.Dtos;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientClaimOutput
{
public Guid ClientId { get; set; }
public string Type { get; set; }
public string Value { get; set; }
}
}

12
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientCorsOriginOutput.cs

@ -0,0 +1,12 @@
using System;
using Volo.Abp.Application.Dtos;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientCorsOriginOutput
{
public Guid ClientId { get; set; }
public string Origin { get; set; }
}
}

11
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientGrantTypeOutput.cs

@ -0,0 +1,11 @@
using System;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientGrantTypeOutput
{
public Guid ClientId { get; set; }
public string GrantType { get; set; }
}
}

12
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientIdPRestrictionOutput.cs

@ -0,0 +1,12 @@
using System;
using Volo.Abp.Application.Dtos;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientIdPRestrictionOutput
{
public Guid ClientId { get; set; }
public string Provider { get; set; }
}
}

105
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientOutput.cs

@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientOutput : EntityDto<Guid>
{
public string ClientId { get; set; }
public string ClientName { get; set; }
public string Description { get; set; }
public string ClientUri { get; set; }
public string LogoUri { get; set; }
public bool Enabled { get; set; }
public string ProtocolType { get; set; }
public bool RequireClientSecret { get; set; }
public bool RequireConsent { get; set; }
public bool AllowRememberConsent { get; set; }
public bool AlwaysIncludeUserClaimsInIdToken { get; set; }
public bool RequirePkce { get; set; }
public bool AllowPlainTextPkce { get; set; }
public bool RequireRequestObject { get; set; }
public bool AllowAccessTokensViaBrowser { get; set; }
public string FrontChannelLogoutUri { get; set; }
public bool FrontChannelLogoutSessionRequired { get; set; }
public string BackChannelLogoutUri { get; set; }
public bool BackChannelLogoutSessionRequired { get; set; }
public bool AllowOfflineAccess { get; set; }
public int IdentityTokenLifetime { get; set; }
public string AllowedIdentityTokenSigningAlgorithms { get; set; }
public int AccessTokenLifetime { get; set; }
public int AuthorizationCodeLifetime { get; set; }
public int? ConsentLifetime { get; set; }
public int AbsoluteRefreshTokenLifetime { get; set; }
public int SlidingRefreshTokenLifetime { get; set; }
public int RefreshTokenUsage { get; set; }
public bool UpdateAccessTokenClaimsOnRefresh { get; set; }
public int RefreshTokenExpiration { get; set; }
public int AccessTokenType { get; set; }
public bool EnableLocalLogin { get; set; }
public bool IncludeJwtId { get; set; }
public bool AlwaysSendClientClaims { get; set; }
public string ClientClaimsPrefix { get; set; }
public string PairWiseSubjectSalt { get; set; }
public int? UserSsoLifetime { get; set; }
public string UserCodeType { get; set; }
public int DeviceCodeLifetime { get; set; }
public List<ClientScopeOutput> AllowedScopes { get; set; }
public List<ClientSecretOutput> ClientSecrets { get; set; }
public List<ClientGrantTypeOutput> AllowedGrantTypes { get; set; }
public List<ClientCorsOriginOutput> AllowedCorsOrigins { get; set; }
public List<ClientRedirectUriOutput> RedirectUris { get; set; }
public List<ClientPostLogoutRedirectUriOutput> PostLogoutRedirectUris { get; set; }
public List<ClientIdPRestrictionOutput> IdentityProviderRestrictions { get; set; }
public List<ClientClaimOutput> Claims { get; set; }
public List<ClientPropertyOutput> Properties { get; set; }
}
}

12
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientPostLogoutRedirectUriOutput.cs

@ -0,0 +1,12 @@
using System;
using Volo.Abp.Application.Dtos;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientPostLogoutRedirectUriOutput
{
public Guid ClientId { get; set; }
public string PostLogoutRedirectUri { get; set; }
}
}

14
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientPropertyOutput.cs

@ -0,0 +1,14 @@
using System;
using Volo.Abp.Application.Dtos;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientPropertyOutput
{
public Guid ClientId { get; set; }
public string Key { get; set; }
public string Value { get; set; }
}
}

11
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientRedirectUriOutput.cs

@ -0,0 +1,11 @@
using System;
using Volo.Abp.Application.Dtos;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientRedirectUriOutput
{
public virtual Guid ClientId { get; set; }
public virtual string RedirectUri { get; set; }
}
}

11
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientScopeOutput.cs

@ -0,0 +1,11 @@
using System;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientScopeOutput
{
public Guid ClientId { get; set; }
public string Scope { get; set; }
}
}

15
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/ClientSecretOutput.cs

@ -0,0 +1,15 @@
using System;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class ClientSecretOutput
{
public string Type { get; set; }
public string Value { get; set; }
public string Description { get; set; }
public DateTime? Expiration { get; set; }
}
}

13
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/CreateClientInput.cs

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class CreateClientInput
{
[Required] public string ClientId { get; set; }
[Required] public string ClientName { get; set; }
public string Description { get; set; }
}
}

9
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/PagingClientListInput.cs

@ -0,0 +1,9 @@
using CompanyName.ProjectName.Extensions.Customs;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class PagingClientListInput:PagingBase
{
public string Filter { get; set; }
}
}

13
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/RemoveCorsInput.cs

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class RemoveCorsInput
{
[Required]
public string ClientId { get; set; }
[Required]
public string Origin { get; set; }
}
}

13
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/RemoveRedirectUriInput.cs

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class RemoveRedirectUriInput
{
[Required]
public string ClientId { get; set; }
[Required]
public string Uri { get; set; }
}
}

83
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/UpdataBasicDataInput.cs

@ -0,0 +1,83 @@
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class UpdataBasicDataInput
{
public string ClientId { get; set; }
public string ClientName { get; set; }
public string Description { get; set; }
public string ClientUri { get; set; }
public string LogoUri { get; set; }
public bool Enabled { get; set; } = true;
public string ProtocolType { get; set; }
public bool RequireClientSecret { get; set; }
public bool RequireConsent { get; set; }
public bool AllowRememberConsent { get; set; }
public bool AlwaysIncludeUserClaimsInIdToken { get; set; }
public bool RequirePkce { get; set; }
public bool AllowPlainTextPkce { get; set; }
public bool RequireRequestObject { get; set; }
public bool AllowAccessTokensViaBrowser { get; set; }
public string FrontChannelLogoutUri { get; set; }
public bool FrontChannelLogoutSessionRequired { get; set; }
public string BackChannelLogoutUri { get; set; }
public bool BackChannelLogoutSessionRequired { get; set; }
public bool AllowOfflineAccess { get; set; }
public int IdentityTokenLifetime { get; set; }
public string AllowedIdentityTokenSigningAlgorithms { get; set; }
public int AccessTokenLifetime { get; set; }
public int AuthorizationCodeLifetime { get; set; }
public int? ConsentLifetime { get; set; }
public int AbsoluteRefreshTokenLifetime { get; set; }
public int SlidingRefreshTokenLifetime { get; set; }
public int RefreshTokenUsage { get; set; }
public bool UpdateAccessTokenClaimsOnRefresh { get; set; }
public int RefreshTokenExpiration { get; set; }
public int AccessTokenType { get; set; }
public bool EnableLocalLogin { get; set; }
public bool IncludeJwtId { get; set; }
public bool AlwaysSendClientClaims { get; set; }
public string ClientClaimsPrefix { get; set; }
public string PairWiseSubjectSalt { get; set; }
public int? UserSsoLifetime { get; set; }
public string UserCodeType { get; set; }
public int DeviceCodeLifetime { get; set; } = 300;
}
}

18
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/Dtos/UpdateScopeInput.cs

@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class UpdateScopeInput
{
[Required]
public string ClientId { get; set; }
public List<string> Scopes { get; set; }
public UpdateScopeInput()
{
Scopes = new List<string>();
}
}
}

71
aspnet-core/services/src/CompanyName.ProjectName.Application.Contracts/IdentityServers/Clients/IIdentityServerClientAppService.cs

@ -0,0 +1,71 @@
using System.Threading.Tasks;
using CompanyName.ProjectName.Publics.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public interface IIdentityServerClientAppService : IApplicationService
{
/// <summary>
/// 分页查询Client
/// </summary>
/// <returns></returns>
Task<PagedResultDto<ClientOutput>> GetListAsync(PagingClientListInput input);
/// <summary>
/// 创建Client
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task CreateAsync(CreateClientInput input);
/// <summary>
/// 删除client
/// </summary>
/// <returns></returns>
Task DeleteAsync(IdInput input);
/// <summary>
/// 更新基本信息
/// </summary>
/// <returns></returns>
Task UpdateBasicDataAsync(UpdataBasicDataInput input);
/// <summary>
/// 更新client scopes
/// </summary>
/// <returns></returns>
Task UpdateScopesAsync(UpdateScopeInput input);
/// <summary>
/// 新增回调地址
/// </summary>
Task AddRedirectUriAsync(AddRedirectUriInput input);
/// <summary>
/// 删除回调地址
/// </summary>
Task RemoveRedirectUriAsync(RemoveRedirectUriInput input);
/// <summary>
/// 新增Logout回调地址
/// </summary>
Task AddLogoutRedirectUriAsync(AddRedirectUriInput input);
/// <summary>
/// 删除Logout回调地址
/// </summary>
Task RemoveLogoutRedirectUriAsync(RemoveRedirectUriInput input);
/// <summary>
/// 添加cors
/// </summary>
Task AddCorsAsync(AddCorsInput input);
/// <summary>
/// 删除cors
/// </summary>
Task RemoveCorsAsync(RemoveCorsInput input);
}
}

92
aspnet-core/services/src/CompanyName.ProjectName.Application/IdentityServers/ApiResources/ApiResourceAppService.cs

@ -0,0 +1,92 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using CompanyName.ProjectName.IdentityServer;
using CompanyName.ProjectName.IdentityServers.Dtos;
using CompanyName.ProjectName.Publics.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.IdentityServer.ApiResources;
namespace CompanyName.ProjectName.IdentityServers.ApiResources
{
public class ApiResourceAppService : ProjectNameAppService, IApiResourceAppService
{
private readonly IdenityServerApiResourceManager _idenityServerApiResourceManager;
public ApiResourceAppService(IdenityServerApiResourceManager idenityServerApiResourceManager)
{
_idenityServerApiResourceManager = idenityServerApiResourceManager;
}
public async Task<PagedResultDto<ApiResourceOutput>> GetListAsync(PagingApiRseourceListInput input)
{
var list = await _idenityServerApiResourceManager.GetListAsync(
input.SkipCount,
input.PageSize,
input.Filter,
true);
var totalCount = await _idenityServerApiResourceManager.GetCountAsync(input.Filter);
return new PagedResultDto<ApiResourceOutput>(totalCount,
ObjectMapper.Map<List<ApiResource>, List<ApiResourceOutput>>(list));
}
/// <summary>
/// 获取所有api resource
/// </summary>
/// <returns></returns>
public async Task<List<ApiResourceOutput>> GetApiResources()
{
var list = await _idenityServerApiResourceManager.GetResources(false);
return ObjectMapper.Map<List<ApiResource>, List<ApiResourceOutput>>(list);
}
/// <summary>
/// 新增 ApiResource
/// </summary>
/// <returns></returns>
public Task CreateAsync(CreateApiResourceInput input)
{
return _idenityServerApiResourceManager.CreateAsync(
GuidGenerator.Create(),
input.Name,
input.DisplayName,
input.Description,
input.Enabled,
input.AllowedAccessTokenSigningAlgorithms,
input.ShowInDiscoveryDocument,
input.Secrets,
input.Scopes,
input.UserClaims,
input.Properties
);
}
/// <summary>
/// 删除 ApiResource
/// </summary>
/// <returns></returns>
public async Task DeleteAsync(IdInput input)
{
await _idenityServerApiResourceManager.DeleteAsync(input.Id);
}
/// <summary>
/// 更新 ApiResource
/// </summary>
/// <returns></returns>
public Task UpdateAsync(UpdateApiResourceInput input)
{
return _idenityServerApiResourceManager.UpdateAsync(
input.Name,
input.DisplayName,
input.Description,
input.Enabled,
input.AllowedAccessTokenSigningAlgorithms,
input.ShowInDiscoveryDocument,
input.Secrets,
input.Scopes,
input.UserClaims,
input.Properties
);
}
}
}

157
aspnet-core/services/src/CompanyName.ProjectName.Application/IdentityServers/Clients/IdentityServerClientAppService.cs

@ -0,0 +1,157 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using CompanyName.ProjectName.IdentityServer;
using CompanyName.ProjectName.Publics.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.IdentityServer.Clients;
namespace CompanyName.ProjectName.IdentityServers.Clients
{
public class IdentityServerClientAppService : ProjectNameAppService, IIdentityServerClientAppService
{
private readonly IdenityServerClientManager _idenityServerClientManager;
public IdentityServerClientAppService(IdenityServerClientManager idenityServerClientManager)
{
_idenityServerClientManager = idenityServerClientManager;
}
public async Task<PagedResultDto<ClientOutput>> GetListAsync(PagingClientListInput input)
{
var list = await _idenityServerClientManager.GetListAsync(
input.SkipCount,
input.PageSize,
input.Filter,
true);
var totalCount = await _idenityServerClientManager.GetCountAsync(input.Filter);
return new PagedResultDto<ClientOutput>(totalCount,
ObjectMapper.Map<List<Client>, List<ClientOutput>>(list));
}
/// <summary>
/// 创建Client
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public Task CreateAsync(CreateClientInput input)
{
return _idenityServerClientManager.CreateAsync(input.ClientId, input.ClientName, input.Description);
}
/// <summary>
/// 删除client
/// </summary>
/// <returns></returns>
public Task DeleteAsync(IdInput input)
{
return _idenityServerClientManager.DeleteAsync(input.Id);
}
/// <summary>
/// 更新基本信息
/// </summary>
/// <returns></returns>
public Task UpdateBasicDataAsync(UpdataBasicDataInput input)
{
return _idenityServerClientManager.UpdateBasicDataAsync(
input.ClientId,
input.ClientName,
input.Description,
input.ClientUri,
input.LogoUri,
input.Enabled,
input.ProtocolType,
input.RequireClientSecret,
input.RequireConsent,
input.AllowRememberConsent,
input.AlwaysIncludeUserClaimsInIdToken,
input.RequirePkce,
input.AllowPlainTextPkce,
input.RequireRequestObject,
input.AllowAccessTokensViaBrowser,
input.FrontChannelLogoutUri,
input.FrontChannelLogoutSessionRequired,
input.BackChannelLogoutUri,
input.BackChannelLogoutSessionRequired,
input.AllowOfflineAccess,
input.IdentityTokenLifetime,
input.AllowedIdentityTokenSigningAlgorithms,
input.AccessTokenLifetime,
input.AuthorizationCodeLifetime,
input.ConsentLifetime,
input.AbsoluteRefreshTokenLifetime,
input.RefreshTokenUsage,
input.UpdateAccessTokenClaimsOnRefresh,
input.RefreshTokenExpiration,
input.AccessTokenType,
input.EnableLocalLogin,
input.IncludeJwtId,
input.AlwaysSendClientClaims,
input.ClientClaimsPrefix,
input.PairWiseSubjectSalt,
input.UserSsoLifetime,
input.UserCodeType,
input.DeviceCodeLifetime,
input.SlidingRefreshTokenLifetime
);
}
/// <summary>
/// 更新client scopes
/// </summary>
/// <returns></returns>
public Task UpdateScopesAsync(UpdateScopeInput input)
{
return _idenityServerClientManager.UpdateScopesAsync(input.ClientId, input.Scopes);
}
/// <summary>
/// 新增回调地址
/// </summary>
public Task AddRedirectUriAsync(AddRedirectUriInput input)
{
return _idenityServerClientManager.AddRedirectUriAsync(input.ClientId, input.Uri);
}
/// <summary>
/// 删除回调地址
/// </summary>
public Task RemoveRedirectUriAsync(RemoveRedirectUriInput input)
{
return _idenityServerClientManager.RemoveRedirectUriAsync(input.ClientId, input.Uri);
}
/// <summary>
/// 新增Logout回调地址
/// </summary>
public Task AddLogoutRedirectUriAsync(AddRedirectUriInput input)
{
return _idenityServerClientManager.AddLogoutRedirectUriAsync(input.ClientId, input.Uri);
}
/// <summary>
/// 删除Logout回调地址
/// </summary>
public Task RemoveLogoutRedirectUriAsync(RemoveRedirectUriInput input)
{
return _idenityServerClientManager.RemoveLogoutRedirectUriAsync(input.ClientId, input.Uri);
}
/// <summary>
/// 添加cors
/// </summary>
public Task AddCorsAsync(AddCorsInput input)
{
return _idenityServerClientManager.AddCorsAsync(input.ClientId, input.Origin);
}
/// <summary>
/// 删除cors
/// </summary>
public Task RemoveCorsAsync(RemoveCorsInput input)
{
return _idenityServerClientManager.RemoveCorsAsync(input.ClientId, input.Origin);
}
}
}

50
aspnet-core/services/src/CompanyName.ProjectName.Application/IdentityServers/Mappers/IdentityServerApplicationAutoMapperProfile.cs

@ -0,0 +1,50 @@
using AutoMapper;
using CompanyName.ProjectName.IdentityServers.Clients;
using CompanyName.ProjectName.IdentityServers.Dtos;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.IdentityResources;
namespace CompanyName.ProjectName.IdentityServers.Mappers
{
public class IdentityServerApplicationAutoMapperProfile : Profile
{
public IdentityServerApplicationAutoMapperProfile()
{
#region id4 model to Output
CreateMap<ApiResource, ApiResourceOutput>();
CreateMap<ApiResourceClaim, ApiResourceClaimOutput>();
CreateMap<ApiResourceProperty, ApiResourcePropertyOutput>();
CreateMap<ApiResourceSecret, ApiResourceSecretOutput>();
CreateMap<ApiResourceScope, ApiResourceScopeOutput>();
CreateMap<Client, ClientOutput>();
CreateMap<ClientClaim, ClientClaimOutput>();
CreateMap<ClientCorsOrigin, ClientCorsOriginOutput>();
CreateMap<ClientGrantType, ClientGrantTypeOutput>();
CreateMap<ClientIdPRestriction, ClientIdPRestrictionOutput>();
CreateMap<ClientPostLogoutRedirectUri, ClientPostLogoutRedirectUriOutput>();
CreateMap<ClientProperty, ClientPropertyOutput>();
CreateMap<ClientRedirectUri, ClientRedirectUriOutput>();
CreateMap<ClientScope, ClientScopeOutput>();
CreateMap<ClientSecret, ClientSecretOutput>();
// CreateMap<DeviceFlowCodes, DeviceFlowCodesOutput>();
// CreateMap<DeviceFlowCodes, DeviceFlowCodesOutput>();
//
// CreateMap<IdentityResourceClaim, IdentityResourceClaimOutput>();
// CreateMap<IdentityResource, IdentityResourceOutput>();
// CreateMap<IdentityResourceProperty, IdentityResourcePropertyOutput>();
//
//
// CreateMap<ApiScope, ApiScopeOutput>();
// CreateMap<ApiScopeClaim, ApiScopeClaimOutput>();
// CreateMap<ApiScopeProperty, ApiScopePropertyOutput>();
#endregion
}
}
}

11
aspnet-core/services/src/CompanyName.ProjectName.Domain.Shared/IdentityServers/ApiResources/Dtos/ApiResourceClaimOutput.cs

@ -0,0 +1,11 @@
using System;
namespace CompanyName.ProjectName.IdentityServers.Dtos
{
public class ApiResourceClaimOutput
{
public Guid ApiResourceId { get; set; }
public string Type { get; set; }
}
}

13
aspnet-core/services/src/CompanyName.ProjectName.Domain.Shared/IdentityServers/ApiResources/Dtos/ApiResourcePropertyOutput.cs

@ -0,0 +1,13 @@
using System;
namespace CompanyName.ProjectName.IdentityServers.Dtos
{
public class ApiResourcePropertyOutput
{
public Guid ApiResourceId { get; set; }
public string Key { get; set; }
public string Value { get; set; }
}
}

11
aspnet-core/services/src/CompanyName.ProjectName.Domain.Shared/IdentityServers/ApiResources/Dtos/ApiResourceScopeOutput.cs

@ -0,0 +1,11 @@
using System;
namespace CompanyName.ProjectName.IdentityServers.Dtos
{
public class ApiResourceScopeOutput
{
public Guid ApiResourceId { get; set; }
public string Scope { get; set; }
}
}

17
aspnet-core/services/src/CompanyName.ProjectName.Domain.Shared/IdentityServers/ApiResources/Dtos/ApiResourceSecretOutput.cs

@ -0,0 +1,17 @@
using System;
namespace CompanyName.ProjectName.IdentityServers.Dtos
{
public class ApiResourceSecretOutput
{
public Guid ApiResourceId { get; set; }
public string Type { get; set; }
public string Value { get; set; }
public string Description { get; set; }
public DateTime? Expiration { get; set; }
}
}

133
aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerApiResourceManager.cs

@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CompanyName.ProjectName.IdentityServers.Dtos;
using Volo.Abp;
using Volo.Abp.Domain.Services;
using Volo.Abp.IdentityServer.ApiResources;
using IdentityModel;
namespace CompanyName.ProjectName.IdentityServer
{
public class IdenityServerApiResourceManager : DomainService
{
private readonly IApiResourceRepository _apiResourceRepository;
public IdenityServerApiResourceManager(IApiResourceRepository apiResourceRepository)
{
_apiResourceRepository = apiResourceRepository;
}
public Task<List<ApiResource>> GetListAsync(
int skipCount,
int maxResultCount,
string filter = null,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return _apiResourceRepository.GetListAsync("CreationTime", skipCount, maxResultCount, filter,
includeDetails,
cancellationToken);
}
public Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return _apiResourceRepository.GetCountAsync(filter,
cancellationToken);
}
/// <summary>
/// 获取所有api resource
/// </summary>
/// <returns></returns>
public async Task<List<ApiResource>> GetResources(
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await _apiResourceRepository.GetListAsync(includeDetails, cancellationToken);
}
public async Task<ApiResource> CreateAsync(
Guid id,
string name,
string displayName,
string description,
bool enabled,
string allowedAccessTokenSigningAlgorithms,
bool showInDiscoveryDocument,
List<ApiResourceSecretOutput> secrets = null,
List<ApiResourceScopeOutput> scopes = null,
List<ApiResourceClaimOutput> claims = null,
List<ApiResourcePropertyOutput> properties = null,
CancellationToken cancellationToken = default)
{
var apiResource =
await _apiResourceRepository.FindByNameAsync(name.Trim(), false, cancellationToken);
if (null != apiResource) throw new UserFriendlyException(message: "ApiResource已存在");
apiResource = new ApiResource(id, name, displayName, description)
{
AllowedAccessTokenSigningAlgorithms = allowedAccessTokenSigningAlgorithms,
ShowInDiscoveryDocument = showInDiscoveryDocument,
Enabled = enabled
};
secrets?.Distinct().ToList().ForEach(item =>
{
apiResource.AddSecret(item.Value.ToSha256(), item.Expiration, item.Type, item.Description);
});
scopes?.Distinct().ToList().ForEach(item => { apiResource.AddScope(item.Scope); });
claims?.Distinct().ToList().ForEach(item => { apiResource.AddUserClaim(item.Type); });
properties?.Distinct().ToList().ForEach(item => { apiResource.AddProperty(item.Key, item.Value); });
return await _apiResourceRepository.InsertAsync(apiResource, cancellationToken: cancellationToken);
}
public async Task DeleteAsync(
Guid id,
bool autoSave = false,
CancellationToken cancellationToken = default)
{
await _apiResourceRepository.DeleteAsync(id, autoSave, cancellationToken);
}
public async Task<ApiResource> UpdateAsync(
string name,
string displayName,
string description,
bool enabled,
string allowedAccessTokenSigningAlgorithms,
bool showInDiscoveryDocument,
List<ApiResourceSecretOutput> secrets = null,
List<ApiResourceScopeOutput> scopes = null,
List<ApiResourceClaimOutput> claims = null,
List<ApiResourcePropertyOutput> properties = null,
CancellationToken cancellationToken = default
)
{
var apiResource =
await _apiResourceRepository.FindByNameAsync(name.Trim(), false, cancellationToken);
if (null == apiResource) throw new UserFriendlyException(message: "ApiResource不存在");
apiResource.DisplayName = displayName;
apiResource.Description = description;
apiResource.Enabled = enabled;
apiResource.AllowedAccessTokenSigningAlgorithms = allowedAccessTokenSigningAlgorithms;
apiResource.ShowInDiscoveryDocument = showInDiscoveryDocument;
secrets?.Distinct().ToList().ForEach(item =>
{
apiResource.AddSecret(item.Value.ToSha256(), item.Expiration, item.Type, item.Description);
});
scopes?.Distinct().ToList().ForEach(item => { apiResource.AddScope(item.Scope); });
claims?.Distinct().ToList().ForEach(item => { apiResource.AddUserClaim(item.Type); });
properties?.Distinct().ToList().ForEach(item => { apiResource.AddProperty(item.Key, item.Value); });
return await _apiResourceRepository.UpdateAsync(apiResource, cancellationToken: cancellationToken);
}
}
}

260
aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerClientManager.cs

@ -0,0 +1,260 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Services;
using Volo.Abp.IdentityServer.Clients;
namespace CompanyName.ProjectName.IdentityServer
{
public class IdenityServerClientManager : DomainService
{
private readonly IClientRepository _clientRepository;
public IdenityServerClientManager(
IClientRepository clientRepository)
{
_clientRepository = clientRepository;
}
public Task<List<Client>> GetListAsync(
int skipCount,
int maxResultCount,
string filter = null,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return _clientRepository.GetListAsync("CreationTime", skipCount, maxResultCount, filter, includeDetails,
cancellationToken);
}
public Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return _clientRepository.GetCountAsync(filter,
cancellationToken);
}
public Task DeleteAsync(Guid id, bool autoSave = false, CancellationToken cancellationToken = default)
{
return _clientRepository.DeleteAsync(id, autoSave, default);
}
public async Task<Client> CreateAsync(string clientId, string clientName, string description)
{
var entity = new Client(GuidGenerator.Create(), clientId)
{
ClientName = clientName, Description = description
};
return await _clientRepository.InsertAsync(entity);
}
public async Task<Client> UpdateBasicDataAsync(
string clientId,
string clientName,
string description,
string clientUri,
string logoUri,
bool enabled,
string protocolType,
bool requireClientSecret,
bool requireConsent,
bool allowRememberConsent,
bool alwaysIncludeUserClaimsInIdToken,
bool requirePkce,
bool allowPlainTextPkce,
bool requireRequestObject,
bool allowAccessTokensViaBrowser,
string frontChannelLogoutUri,
bool frontChannelLogoutSessionRequired,
string backChannelLogoutUri,
bool backChannelLogoutSessionRequired,
bool allowOfflineAccess,
int identityTokenLifetime,
string allowedIdentityTokenSigningAlgorithms,
int accessTokenLifetime,
int authorizationCodeLifetime,
int? consentLifetime,
int absoluteRefreshTokenLifetime,
int refreshTokenUsage,
bool updateAccessTokenClaimsOnRefresh,
int refreshTokenExpiration,
int accessTokenType,
bool enableLocalLogin,
bool includeJwtId,
bool alwaysSendClientClaims,
string clientClaimsPrefix,
string pairWiseSubjectSalt,
int? userSsoLifetime,
string userCodeType,
int deviceCodeLifetime,
int slidingRefreshTokenLifetime
)
{
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client != null)
{
throw new UserFriendlyException(message: "当前ClientId已存在");
}
client.ClientName = clientName;
client.Description = description;
client.ClientUri = clientUri;
client.LogoUri = logoUri;
client.FrontChannelLogoutUri = frontChannelLogoutUri;
client.BackChannelLogoutUri = backChannelLogoutUri;
client.AllowedIdentityTokenSigningAlgorithms = allowedIdentityTokenSigningAlgorithms;
client.Enabled = enabled;
client.RequireConsent = requireConsent;
client.RequireRequestObject = requireRequestObject;
client.AllowRememberConsent = allowRememberConsent;
client.AllowOfflineAccess = allowOfflineAccess;
client.FrontChannelLogoutSessionRequired = frontChannelLogoutSessionRequired;
client.BackChannelLogoutSessionRequired = backChannelLogoutSessionRequired;
client.IncludeJwtId = includeJwtId;
client.RequirePkce = requirePkce;
client.RequireClientSecret = requireClientSecret;
client.AccessTokenLifetime = accessTokenLifetime;
client.ConsentLifetime = consentLifetime;
client.IdentityTokenLifetime = identityTokenLifetime;
client.AuthorizationCodeLifetime = authorizationCodeLifetime;
client.AbsoluteRefreshTokenLifetime = absoluteRefreshTokenLifetime;
client.SlidingRefreshTokenLifetime = slidingRefreshTokenLifetime;
client.RefreshTokenExpiration = refreshTokenExpiration;
client.DeviceCodeLifetime = deviceCodeLifetime;
client.ProtocolType = protocolType;
client.AlwaysIncludeUserClaimsInIdToken = alwaysIncludeUserClaimsInIdToken;
client.AllowPlainTextPkce = allowPlainTextPkce;
client.AllowOfflineAccess = allowOfflineAccess;
client.AllowAccessTokensViaBrowser = allowAccessTokensViaBrowser;
client.RefreshTokenUsage = refreshTokenUsage;
client.UpdateAccessTokenClaimsOnRefresh = updateAccessTokenClaimsOnRefresh;
client.AccessTokenType = accessTokenType;
client.AlwaysSendClientClaims = alwaysSendClientClaims;
client.ClientClaimsPrefix = clientClaimsPrefix;
client.PairWiseSubjectSalt = pairWiseSubjectSalt;
client.UserSsoLifetime = userSsoLifetime;
client.UserCodeType = userCodeType;
client.EnableLocalLogin = enableLocalLogin;
return await _clientRepository.UpdateAsync(client);
}
/// <summary>
/// 更新client scopes
/// </summary>
/// <returns></returns>
public async Task<Client> UpdateScopesAsync(string clientId, List<string> scopes)
{
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: "Client不存在");
client.RemoveAllScopes();
scopes.ForEach(item => { client.AddScope(item.Trim()); });
return await _clientRepository.UpdateAsync(client);
}
/// <summary>
/// 新增回调地址
/// </summary>
public async Task<Client> AddRedirectUriAsync(string clientId, string uri)
{
uri = uri.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: "Client不存在");
if (client.RedirectUris.Any(e => e.RedirectUri != uri.Trim()))
{
client.AddRedirectUri(uri);
return await _clientRepository.UpdateAsync(client);
}
return client;
}
/// <summary>
/// 删除回调地址
/// </summary>
public async Task<Client> RemoveRedirectUriAsync(string clientId, string uri)
{
uri = uri.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: "Client不存在");
if (client.RedirectUris.Any(e => e.RedirectUri == uri.Trim()))
{
client.RemoveRedirectUri(uri);
return await _clientRepository.UpdateAsync(client);
}
return client;
}
/// <summary>
/// 新增Logout回调地址
/// </summary>
public async Task<Client> AddLogoutRedirectUriAsync(string clientId, string uri)
{
uri = uri.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: "Client不存在");
if (client.PostLogoutRedirectUris.Any(e => e.PostLogoutRedirectUri != uri))
{
client.AddPostLogoutRedirectUri(uri);
await _clientRepository.UpdateAsync(client);
}
return client;
}
/// <summary>
/// 删除Logout回调地址
/// </summary>
public async Task<Client> RemoveLogoutRedirectUriAsync(string clientId, string uri)
{
uri = uri.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: "Client不存在");
if (client.PostLogoutRedirectUris.Any(e => e.PostLogoutRedirectUri == uri))
{
client.RemovePostLogoutRedirectUri(uri);
await _clientRepository.UpdateAsync(client);
}
return client;
}
/// <summary>
/// 添加cors
/// </summary>
public async Task<Client> AddCorsAsync(string clientId, string origin)
{
origin = origin.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: "Client不存在");
if (client.AllowedCorsOrigins.Any(e => e.Origin != origin))
{
client.AddCorsOrigin(origin);
return await _clientRepository.UpdateAsync(client);
}
return client;
}
/// <summary>
/// 删除cors
/// </summary>
public async Task<Client> RemoveCorsAsync(string clientId, string origin)
{
origin = origin.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: "Client不存在");
if (client.AllowedCorsOrigins.Any(e => e.Origin == origin))
{
client.RemoveCorsOrigin(origin);
return await _clientRepository.UpdateAsync(client);
}
return client;
}
}
}

1112
aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/Logs/logs.txt

File diff suppressed because it is too large

59
aspnet-core/services/src/CompanyName.ProjectName.HttpApi/Controllers/IdentityServers/ApiResourceController.cs

@ -0,0 +1,59 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using CompanyName.ProjectName.IdentityServers;
using CompanyName.ProjectName.IdentityServers.Dtos;
using CompanyName.ProjectName.Publics.Dtos;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using Volo.Abp.Application.Dtos;
namespace CompanyName.ProjectName.Controllers.IdentityServers
{
[Route("IdentityServer/ApiResource")]
public class ApiResourceController : ProjectNameController
{
private readonly IApiResourceAppService _apiResourceAppService;
public ApiResourceController(IApiResourceAppService apiResourceAppService)
{
_apiResourceAppService = apiResourceAppService;
}
[HttpPost("page")]
[SwaggerOperation(summary: "分页获取ApiResource信息", Tags = new[] {"IdentityServers"})]
public Task<PagedResultDto<ApiResourceOutput>> GetListAsync(PagingApiRseourceListInput input)
{
return _apiResourceAppService.GetListAsync(input);
}
[HttpPost("all")]
[SwaggerOperation(summary: "获取ApiResource信息", Tags = new[] {"IdentityServers"})]
public Task<List<ApiResourceOutput>> GetApiResources()
{
return _apiResourceAppService.GetApiResources();
}
[HttpPost("create")]
[SwaggerOperation(summary: "新增ApiResource", Tags = new[] {"IdentityServers"})]
public Task CreateAsync(CreateApiResourceInput input)
{
return _apiResourceAppService.CreateAsync(input);
}
[HttpPost("delete")]
[SwaggerOperation(summary: "删除ApiResource", Tags = new[] {"IdentityServers"})]
public async Task DeleteAsync(IdInput input)
{
await _apiResourceAppService.DeleteAsync(input);
}
[HttpPost("update")]
[SwaggerOperation(summary: "删除ApiResource", Tags = new[] {"IdentityServers"})]
public Task UpdateAsync(UpdateApiResourceInput input)
{
return _apiResourceAppService.UpdateAsync(input);
}
}
}

98
aspnet-core/services/src/CompanyName.ProjectName.HttpApi/Controllers/IdentityServers/ClientController.cs

@ -0,0 +1,98 @@
using System.Threading.Tasks;
using CompanyName.ProjectName.IdentityServers.Clients;
using CompanyName.ProjectName.Publics.Dtos;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using Volo.Abp.Application.Dtos;
namespace CompanyName.ProjectName.Controllers.IdentityServers
{
[Route("IdentityServer/Client")]
public class ClientController : ProjectNameController
{
private readonly IIdentityServerClientAppService _identityServerClientAppService;
public ClientController(IIdentityServerClientAppService identityServerClientAppService)
{
_identityServerClientAppService = identityServerClientAppService;
}
[HttpPost("page")]
[SwaggerOperation(summary: "分页获取Client信息", Tags = new[] {"IdentityServers"})]
public Task<PagedResultDto<ClientOutput>> GetListAsync(PagingClientListInput input)
{
return _identityServerClientAppService.GetListAsync(input);
}
[HttpPost("create")]
[SwaggerOperation(summary: "创建Client", Tags = new[] {"IdentityServers"})]
public Task CreateAsync(CreateClientInput input)
{
return _identityServerClientAppService.CreateAsync(input);
}
[HttpPost("delete")]
[SwaggerOperation(summary: "删除client", Tags = new[] {"IdentityServers"})]
public Task DeleteAsync(IdInput input)
{
return _identityServerClientAppService.DeleteAsync(input);
}
[HttpPost("basic/update")]
[SwaggerOperation(summary: "更新基本信息", Tags = new[] {"IdentityServers"})]
public Task UpdateBasicDataAsync(UpdataBasicDataInput input)
{
return _identityServerClientAppService.UpdateBasicDataAsync(input);
}
[HttpPost("scopes/update")]
[SwaggerOperation(summary: "更新client scopes", Tags = new[] {"IdentityServers"})]
public Task UpdateScopesAsync(UpdateScopeInput input)
{
return _identityServerClientAppService.UpdateScopesAsync(input);
}
[HttpPost("redirect/uri/add")]
[SwaggerOperation(summary: "新增回调地址", Tags = new[] {"IdentityServers"})]
public Task AddRedirectUriAsync(AddRedirectUriInput input)
{
return _identityServerClientAppService.AddRedirectUriAsync(input);
}
[HttpPost("redirect/uri/remove")]
[SwaggerOperation(summary: "删除回调地址", Tags = new[] {"IdentityServers"})]
public Task RemoveRedirectUriAsync(RemoveRedirectUriInput input)
{
return _identityServerClientAppService.RemoveRedirectUriAsync(input);
}
[HttpPost("logout/redirect/uri/add")]
[SwaggerOperation(summary: "新增Logout回调地址", Tags = new[] {"IdentityServers"})]
public Task AddLogoutRedirectUriAsync(AddRedirectUriInput input)
{
return _identityServerClientAppService.AddLogoutRedirectUriAsync(input);
}
[HttpPost("logout/redirect/uri/remove")]
[SwaggerOperation(summary: "删除Logout回调地址", Tags = new[] {"IdentityServers"})]
public Task RemoveLogoutRedirectUriAsync(RemoveRedirectUriInput input)
{
return _identityServerClientAppService.RemoveLogoutRedirectUriAsync(input);
}
[HttpPost("cors/add")]
[SwaggerOperation(summary: "添加cors", Tags = new[] {"IdentityServers"})]
public Task AddCorsAsync(AddCorsInput input)
{
return _identityServerClientAppService.AddCorsAsync(input);
}
[HttpPost("cors/remove")]
[SwaggerOperation(summary: "删除cors", Tags = new[] {"IdentityServers"})]
public Task RemoveCorsAsync(RemoveCorsInput input)
{
return _identityServerClientAppService.RemoveCorsAsync(input);
}
}
}

11
aspnet-core/services/src/CompanyName.ProjectName.HttpApi/Models/Test/TestModel.cs

@ -1,11 +0,0 @@
using System;
namespace CompanyName.ProjectName.Models.Test
{
public class TestModel
{
public string Name { get; set; }
public DateTime BirthDate { get; set; }
}
}
Loading…
Cancel
Save