committed by
GitHub
133 changed files with 5067 additions and 7170 deletions
File diff suppressed because one or more lines are too long
@ -1,7 +0,0 @@ |
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiResourceClaimDto |
|||
{ |
|||
public string Type { get; set; } |
|||
} |
|||
} |
|||
@ -1,28 +1,12 @@ |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.ApiResources; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiResourceCreateDto |
|||
public class ApiResourceCreateDto : ApiResourceCreateOrUpdateDto |
|||
{ |
|||
[Required] |
|||
[StringLength(ApiResourceConsts.NameMaxLength)] |
|||
public string Name { get; set; } |
|||
|
|||
[StringLength(ApiResourceConsts.DisplayNameMaxLength)] |
|||
public string DisplayName { get; set; } |
|||
|
|||
[StringLength(ApiResourceConsts.DescriptionMaxLength)] |
|||
public string Description { get; set; } |
|||
|
|||
public bool Enabled { get; set; } |
|||
|
|||
public List<ApiResourceClaimDto> UserClaims { get; set; } |
|||
public ApiResourceCreateDto() |
|||
{ |
|||
Enabled = true; |
|||
UserClaims = new List<ApiResourceClaimDto>(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,33 @@ |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.ApiResources; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiResourceCreateOrUpdateDto |
|||
{ |
|||
[StringLength(ApiResourceConsts.DisplayNameMaxLength)] |
|||
public string DisplayName { get; set; } |
|||
|
|||
[StringLength(ApiResourceConsts.DescriptionMaxLength)] |
|||
public string Description { get; set; } |
|||
|
|||
public bool Enabled { get; set; } |
|||
|
|||
public List<string> UserClaims { get; set; } |
|||
|
|||
public List<ApiScopeDto> Scopes { get; set; } |
|||
|
|||
public List<ApiSecretCreateOrUpdateDto> Secrets { get; set; } |
|||
|
|||
public Dictionary<string, string> Properties { get; set; } |
|||
|
|||
protected ApiResourceCreateOrUpdateDto() |
|||
{ |
|||
UserClaims = new List<string>(); |
|||
Scopes = new List<ApiScopeDto>(); |
|||
Secrets = new List<ApiSecretCreateOrUpdateDto>(); |
|||
Properties = new Dictionary<string, string>(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiResourceGetByIdInputDto : EntityDto<Guid> |
|||
{ |
|||
} |
|||
} |
|||
@ -1,29 +1,6 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Text; |
|||
using Volo.Abp.IdentityServer.ApiResources; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiResourceUpdateDto |
|||
public class ApiResourceUpdateDto : ApiResourceCreateOrUpdateDto |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
|
|||
[StringLength(ApiResourceConsts.DisplayNameMaxLength)] |
|||
public string DisplayName { get; set; } |
|||
|
|||
[StringLength(ApiResourceConsts.DescriptionMaxLength)] |
|||
public string Description { get; set; } |
|||
|
|||
public bool Enabled { get; set; } |
|||
|
|||
public List<ApiResourceClaimDto> UserClaims { get; set; } |
|||
|
|||
public ApiResourceUpdateDto() |
|||
{ |
|||
UserClaims = new List<ApiResourceClaimDto>(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,7 +0,0 @@ |
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiScopeClaimDto |
|||
{ |
|||
public string Type { get; set; } |
|||
} |
|||
} |
|||
@ -1,16 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.ApiResources; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiScopeGetByNameInputDto |
|||
{ |
|||
[Required] |
|||
public Guid ApiResourceId { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(ApiScopeConsts.NameMaxLength)] |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiSecretCreateDto |
|||
{ |
|||
[Required] |
|||
public Guid ApiResourceId { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.TypeMaxLength))] |
|||
public string Type { get; set; } |
|||
|
|||
public HashType HashType { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.ValueMaxLength))] |
|||
public string Value { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.DescriptionMaxLength))] |
|||
public string Description { get; set; } |
|||
|
|||
public DateTime? Expiration { get; set; } |
|||
|
|||
public ApiSecretCreateDto() |
|||
{ |
|||
HashType = 0; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiSecretCreateOrUpdateDto : SecretBaseDto |
|||
{ |
|||
public HashType HashType { get; set; } |
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public class ApiSecretGetByTypeInputDto |
|||
{ |
|||
[Required] |
|||
public Guid ApiResourceId { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.TypeMaxLength))] |
|||
public string Type { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.ValueMaxLength))] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,27 +1,15 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using System; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public interface IApiResourceAppService : IApplicationService |
|||
public interface IApiResourceAppService : |
|||
ICrudAppService< |
|||
ApiResourceDto, |
|||
Guid, |
|||
ApiResourceGetByPagedInputDto, |
|||
ApiResourceCreateDto, |
|||
ApiResourceUpdateDto> |
|||
{ |
|||
Task<ApiResourceDto> GetAsync(ApiResourceGetByIdInputDto apiResourceGetById); |
|||
|
|||
Task<PagedResultDto<ApiResourceDto>> GetAsync(ApiResourceGetByPagedInputDto apiResourceGetByPaged); |
|||
|
|||
Task<ApiResourceDto> CreateAsync(ApiResourceCreateDto apiResourceCreate); |
|||
|
|||
Task<ApiResourceDto> UpdateAsync(ApiResourceUpdateDto apiResourceUpdate); |
|||
|
|||
Task DeleteAsync(ApiResourceGetByIdInputDto apiResourceGetById); |
|||
|
|||
Task<ApiSecretDto> AddSecretAsync(ApiSecretCreateDto apiSecretCreate); |
|||
|
|||
Task DeleteSecretAsync(ApiSecretGetByTypeInputDto apiSecretGetByType); |
|||
|
|||
Task<ApiScopeDto> AddScopeAsync(ApiScopeCreateDto apiScopeCreate); |
|||
|
|||
Task DeleteScopeAsync(ApiScopeGetByNameInputDto apiScopeGetByName); |
|||
} |
|||
} |
|||
|
|||
@ -1,20 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientClaimCreateDto |
|||
{ |
|||
[Required] |
|||
public Guid ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(ClientClaimConsts.TypeMaxLength)] |
|||
public string Type { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(ClientClaimConsts.ValueMaxLength)] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientClaimGetByKeyInputDto |
|||
{ |
|||
[Required] |
|||
public Guid ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(ClientClaimConsts.TypeMaxLength)] |
|||
public string Type { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(ClientClaimConsts.ValueMaxLength)] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientClaimUpdateDto |
|||
{ |
|||
[Required] |
|||
public Guid ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(ClientClaimConsts.TypeMaxLength)] |
|||
public string Type { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(ClientClaimConsts.ValueMaxLength)] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientCorsOriginDto : EntityDto |
|||
{ |
|||
public string Origin { get; set; } |
|||
} |
|||
} |
|||
@ -1,26 +1,7 @@ |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientCreateDto |
|||
public class ClientCreateDto : ClientCreateOrUpdateDto |
|||
{ |
|||
[Required] |
|||
[StringLength(ClientConsts.ClientIdMaxLength)] |
|||
public string ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(ClientConsts.ClientNameMaxLength)] |
|||
public string ClientName { get; set; } |
|||
|
|||
[StringLength(ClientConsts.DescriptionMaxLength)] |
|||
public string Description { get; set; } |
|||
|
|||
public List<ClientGrantTypeDto> AllowedGrantTypes { get; set; } |
|||
public ClientCreateDto() |
|||
{ |
|||
AllowedGrantTypes = new List<ClientGrantTypeDto>(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,27 @@ |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientCreateOrUpdateDto |
|||
{ |
|||
[Required] |
|||
[StringLength(ClientConsts.ClientIdMaxLength)] |
|||
public string ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(ClientConsts.ClientNameMaxLength)] |
|||
public string ClientName { get; set; } |
|||
|
|||
[StringLength(ClientConsts.DescriptionMaxLength)] |
|||
public string Description { get; set; } |
|||
|
|||
public List<string> AllowedGrantTypes { get; set; } |
|||
|
|||
protected ClientCreateOrUpdateDto() |
|||
{ |
|||
AllowedGrantTypes = new List<string>(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientGetByIdInputDto |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
} |
|||
} |
|||
2
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/Clients/Dto/ClientGetByPagedInputDto.cs → aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/Clients/Dto/ClientGetByPagedDto.cs
2
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/Clients/Dto/ClientGetByPagedInputDto.cs → aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/Clients/Dto/ClientGetByPagedDto.cs
@ -1,9 +0,0 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientGrantTypeDto : EntityDto |
|||
{ |
|||
public string GrantType { get; set; } |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientIdPRestrictionDto : EntityDto |
|||
{ |
|||
public string Provider { get; set; } |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientPostLogoutRedirectUriDto : EntityDto |
|||
{ |
|||
public string PostLogoutRedirectUri { get; set; } |
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientPropertyCreateDto |
|||
{ |
|||
[Required] |
|||
public Guid ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(ClientPropertyConsts), nameof(ClientPropertyConsts.KeyMaxLength))] |
|||
public string Key { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(ClientPropertyConsts), nameof(ClientPropertyConsts.ValueMaxLength))] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientPropertyDto : EntityDto |
|||
{ |
|||
public string Key { get; set; } |
|||
|
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientPropertyGetByKeyDto |
|||
{ |
|||
[Required] |
|||
public Guid ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(ClientPropertyConsts), nameof(ClientPropertyConsts.KeyMaxLength))] |
|||
public string Key { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(ClientPropertyConsts), nameof(ClientPropertyConsts.ValueMaxLength))] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientPropertyUpdateDto |
|||
{ |
|||
[Required] |
|||
public Guid ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(ClientPropertyConsts), nameof(ClientPropertyConsts.KeyMaxLength))] |
|||
public string Key { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(ClientPropertyConsts), nameof(ClientPropertyConsts.ValueMaxLength))] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientRedirectUriDto : EntityDto |
|||
{ |
|||
public string RedirectUri { get; set; } |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientScopeDto : EntityDto |
|||
{ |
|||
public string Scope { get; set; } |
|||
} |
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientSecretCreateDto |
|||
{ |
|||
[Required] |
|||
public Guid ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.TypeMaxLength))] |
|||
public string Type { get; set; } |
|||
|
|||
public HashType HashType { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.ValueMaxLength))] |
|||
public string Value { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.DescriptionMaxLength))] |
|||
public string Description { get; set; } |
|||
|
|||
public DateTime? Expiration { get; set; } |
|||
|
|||
public ClientSecretCreateDto() |
|||
{ |
|||
HashType = 0; |
|||
} |
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientSecretGetByTypeDto |
|||
{ |
|||
[Required] |
|||
public Guid ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.TypeMaxLength))] |
|||
public string Type { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.ValueMaxLength))] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientSecretUpdateDto |
|||
{ |
|||
[Required] |
|||
public Guid ClientId { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.TypeMaxLength))] |
|||
public string Type { get; set; } |
|||
|
|||
public HashType HashType { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.ValueMaxLength))] |
|||
public string Value { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(SecretConsts), nameof(SecretConsts.DescriptionMaxLength))] |
|||
public string Description { get; set; } |
|||
|
|||
public DateTime? Expiration { get; set; } |
|||
} |
|||
} |
|||
@ -1,19 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class ClientUpdateInputDto |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
|
|||
[Required] |
|||
public ClientUpdateDto Client { get; set; } |
|||
|
|||
public ClientUpdateInputDto() |
|||
{ |
|||
Client = new ClientUpdateDto(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public class SecretCreateOrUpdateDto : SecretBaseDto |
|||
{ |
|||
public HashType HashType { get; set; } |
|||
} |
|||
} |
|||
@ -1,39 +1,24 @@ |
|||
using System.Threading.Tasks; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.Clients |
|||
{ |
|||
public interface IClientAppService : IApplicationService |
|||
public interface IClientAppService : |
|||
ICrudAppService< |
|||
ClientDto, |
|||
Guid, |
|||
ClientGetByPagedDto, |
|||
ClientCreateDto, |
|||
ClientUpdateDto> |
|||
{ |
|||
Task<ClientDto> GetAsync(ClientGetByIdInputDto clientGetById); |
|||
Task<ClientDto> CloneAsync(Guid id, ClientCloneDto input); |
|||
|
|||
Task<PagedResultDto<ClientDto>> GetAsync(ClientGetByPagedInputDto clientGetByPaged); |
|||
Task<ListResultDto<string>> GetAssignableApiResourcesAsync(); |
|||
|
|||
Task<ClientDto> CreateAsync(ClientCreateDto clientCreate); |
|||
Task<ListResultDto<string>> GetAssignableIdentityResourcesAsync(); |
|||
|
|||
Task<ClientDto> UpdateAsync(ClientUpdateInputDto clientUpdateInput); |
|||
|
|||
Task<ClientDto> CloneAsync(ClientCloneInputDto clientCloneInput); |
|||
|
|||
Task DeleteAsync(ClientGetByIdInputDto clientGetByIdInput); |
|||
|
|||
Task<ClientClaimDto> AddClaimAsync(ClientClaimCreateDto clientClaimCreate); |
|||
|
|||
Task<ClientClaimDto> UpdateClaimAsync(ClientClaimUpdateDto clientClaimUpdate); |
|||
|
|||
Task DeleteClaimAsync(ClientClaimGetByKeyInputDto clientClaimGetByKey); |
|||
|
|||
Task<ClientPropertyDto> AddPropertyAsync(ClientPropertyCreateDto clientPropertyCreate); |
|||
|
|||
Task<ClientPropertyDto> UpdatePropertyAsync(ClientPropertyUpdateDto clientPropertyUpdate); |
|||
|
|||
Task DeletePropertyAsync(ClientPropertyGetByKeyDto clientPropertyGetByKey); |
|||
|
|||
Task<ClientSecretDto> AddSecretAsync(ClientSecretCreateDto clientSecretCreate); |
|||
|
|||
Task<ClientSecretDto> UpdateSecretAsync(ClientSecretUpdateDto clientSecretUpdate); |
|||
|
|||
Task DeleteSecretAsync(ClientSecretGetByTypeDto clientSecretGetByType); |
|||
Task<ListResultDto<string>> GetAllDistinctAllowedCorsOriginsAsync(); |
|||
} |
|||
} |
|||
|
|||
@ -1,7 +0,0 @@ |
|||
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
|||
{ |
|||
public class IdentityClaimDto |
|||
{ |
|||
public string Type { get; set; } |
|||
} |
|||
} |
|||
12
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/IdentityResources/Dto/IdentityResourceCreateDto.cs → aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/IdentityResources/Dto/IdentityResourceCreateOrUpdateDto.cs
12
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/IdentityResources/Dto/IdentityResourceCreateDto.cs → aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/IdentityResources/Dto/IdentityResourceCreateOrUpdateDto.cs
@ -1,9 +0,0 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
|||
{ |
|||
public class IdentityResourceGetByIdInputDto : EntityDto<Guid> |
|||
{ |
|||
} |
|||
} |
|||
2
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/IdentityResources/Dto/IdentityResourceGetByPagedInputDto.cs → aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/IdentityResources/Dto/IdentityResourceGetByPagedDto.cs
2
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/IdentityResources/Dto/IdentityResourceGetByPagedInputDto.cs → aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN/Abp/IdentityServer/IdentityResources/Dto/IdentityResourceGetByPagedDto.cs
@ -1,23 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
|||
{ |
|||
public class IdentityResourcePropertyCreateDto |
|||
{ |
|||
[Required] |
|||
public Guid IdentityResourceId { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(2000)] |
|||
public string ConcurrencyStamp { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(100)] |
|||
public string Key { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(2000)] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
|||
{ |
|||
public class IdentityResourcePropertyDto |
|||
{ |
|||
public string Key { get; set; } |
|||
|
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
@ -1,15 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
|||
{ |
|||
public class IdentityResourcePropertyGetByKeyDto |
|||
{ |
|||
[Required] |
|||
public Guid IdentityResourceId { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(100)] |
|||
public string Key { get; set; } |
|||
} |
|||
} |
|||
@ -1,45 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.IdentityServer.IdentityResources; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
|||
{ |
|||
public class IdentityResourceUpdateDto |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(2000)] |
|||
public string ConcurrencyStamp { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(IdentityResourceConsts), nameof(IdentityResourceConsts.NameMaxLength))] |
|||
public string Name { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(IdentityResourceConsts), nameof(IdentityResourceConsts.DisplayNameMaxLength))] |
|||
public string DisplayName { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(IdentityResourceConsts), nameof(IdentityResourceConsts.DescriptionMaxLength))] |
|||
public string Description { get; set; } |
|||
|
|||
public bool Enabled { get; set; } |
|||
|
|||
public bool Required { get; set; } |
|||
|
|||
public bool Emphasize { get; set; } |
|||
|
|||
public bool ShowInDiscoveryDocument { get; set; } |
|||
|
|||
public List<IdentityClaimDto> UserClaims { get; set; } |
|||
|
|||
public IdentityResourceUpdateDto() |
|||
{ |
|||
Enabled = true; |
|||
Required = false; |
|||
ShowInDiscoveryDocument = false; |
|||
UserClaims = new List<IdentityClaimDto>(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,23 +1,16 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using System; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
|||
{ |
|||
public interface IIdentityResourceAppService : IApplicationService |
|||
public interface IIdentityResourceAppService : |
|||
ICrudAppService< |
|||
IdentityResourceDto, |
|||
Guid, |
|||
IdentityResourceGetByPagedDto, |
|||
IdentityResourceCreateOrUpdateDto, |
|||
IdentityResourceCreateOrUpdateDto |
|||
> |
|||
{ |
|||
Task<IdentityResourceDto> GetAsync(IdentityResourceGetByIdInputDto identityResourceGetById); |
|||
|
|||
Task<PagedResultDto<IdentityResourceDto>> GetAsync(IdentityResourceGetByPagedInputDto identityResourceGetByPaged); |
|||
|
|||
Task<IdentityResourceDto> CreateAsync(IdentityResourceCreateDto identityResourceCreate); |
|||
|
|||
Task<IdentityResourceDto> UpdateAsync(IdentityResourceUpdateDto identityResourceUpdate); |
|||
|
|||
Task DeleteAsync(IdentityResourceGetByIdInputDto identityResourceGetById); |
|||
|
|||
Task<IdentityResourcePropertyDto> AddPropertyAsync(IdentityResourcePropertyCreateDto identityResourcePropertyCreate); |
|||
|
|||
Task DeletePropertyAsync(IdentityResourcePropertyGetByKeyDto identityResourcePropertyGetByKey); |
|||
} |
|||
} |
|||
|
|||
@ -1,13 +1,22 @@ |
|||
using Volo.Abp.Application.Services; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.IdentityServer.Localization; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer |
|||
{ |
|||
public abstract class AbpIdentityServerAppServiceBase : ApplicationService |
|||
{ |
|||
private IPermissionChecker _permissionChecker; |
|||
protected IPermissionChecker PermissionChecker => LazyGetRequiredService(ref _permissionChecker); |
|||
protected AbpIdentityServerAppServiceBase() |
|||
{ |
|||
LocalizationResource = typeof(AbpIdentityServerResource); |
|||
} |
|||
|
|||
protected virtual async Task<bool> IsGrantAsync(string policy) |
|||
{ |
|||
return await PermissionChecker.IsGrantedAsync(policy); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
public interface IApiResourceRepository : Volo.Abp.IdentityServer.ApiResources.IApiResourceRepository |
|||
{ |
|||
Task<List<string>> GetNamesAsync(CancellationToken cancellationToken = default); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
|||
{ |
|||
public interface IIdentityResourceRepository : Volo.Abp.IdentityServer.IdentityResources.IIdentityResourceRepository |
|||
{ |
|||
Task<List<string>> GetNamesAsync(CancellationToken cancellationToken = default); |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.IdentityServer.ApiResources; |
|||
using Volo.Abp.IdentityServer.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.ApiResources |
|||
{ |
|||
[Dependency(ServiceLifetime.Transient)] |
|||
[ExposeServices( |
|||
typeof(IApiResourceRepository), |
|||
typeof(ApiResourceRepository), |
|||
typeof(Volo.Abp.IdentityServer.ApiResources.IApiResourceRepository))] |
|||
public class EfCoreApiResourceRepository : ApiResourceRepository, IApiResourceRepository |
|||
{ |
|||
public EfCoreApiResourceRepository( |
|||
IDbContextProvider<IIdentityServerDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public virtual async Task<List<string>> GetNamesAsync(CancellationToken cancellationToken = default) |
|||
{ |
|||
return await DbSet |
|||
.Select(x => x.Name) |
|||
.Distinct() |
|||
.ToListAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.IdentityServer.EntityFrameworkCore; |
|||
using Volo.Abp.IdentityServer.IdentityResources; |
|||
|
|||
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
|||
{ |
|||
[Dependency(ServiceLifetime.Transient)] |
|||
[ExposeServices( |
|||
typeof(IIdentityResourceRepository), |
|||
typeof(IdentityResourceRepository), |
|||
typeof(Volo.Abp.IdentityServer.IdentityResources.IIdentityResourceRepository))] |
|||
public class EfCoreIdentityResourceRepository : IdentityResourceRepository, IIdentityResourceRepository |
|||
{ |
|||
public EfCoreIdentityResourceRepository( |
|||
IDbContextProvider<IIdentityServerDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public virtual async Task<List<string>> GetNamesAsync(CancellationToken cancellationToken = default) |
|||
{ |
|||
return await DbSet |
|||
.Select(x => x.Name) |
|||
.Distinct() |
|||
.ToListAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
} |
|||
} |
|||
Binary file not shown.
@ -0,0 +1,107 @@ |
|||
import ApiService from './serviceBase' |
|||
import { FullAuditedEntityDto, PagedAndSortedResultRequestDto, PagedResultDto, SecretBase } from './types' |
|||
|
|||
const sourceUrl = '/api/identity-server/api-resources' |
|||
const serviceUrl = process.env.VUE_APP_BASE_API |
|||
|
|||
export default class ApiResourceService { |
|||
/** |
|||
* 获取Api资源 |
|||
* @param id Api资源标识 |
|||
*/ |
|||
public static getApiResourceById(id: string) { |
|||
const _url = sourceUrl + '/' + id |
|||
return ApiService.Get<ApiResource>(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 获取Api资源列表 |
|||
* @param payload 查询参数 |
|||
*/ |
|||
public static getApiResources(payload: ApiResourceGetByPaged) { |
|||
let _url = sourceUrl + '?filter=' + payload.filter |
|||
_url += '&sorting=' + payload.sorting |
|||
_url += '&skipCount=' + payload.skipCount |
|||
_url += '&maxResultCount=' + payload.maxResultCount |
|||
return ApiService.Get<PagedResultDto<ApiResource>>(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 创建Api资源 |
|||
* @param payload api资源参数 |
|||
*/ |
|||
public static createApiResource(payload: ApiResourceCreate) { |
|||
return ApiService.Post<ApiResource>(sourceUrl, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 变更Api资源 |
|||
* @param payload api资源参数 |
|||
*/ |
|||
public static updateApiResource(id: string, payload: ApiResourceUpdate) { |
|||
const _url = sourceUrl + '/' + id |
|||
return ApiService.Put<ApiResource>(_url, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 删除Api资源 |
|||
* @param id Api资源标识 |
|||
*/ |
|||
public static deleteApiResource(id: string) { |
|||
const _url = sourceUrl + '/' + id |
|||
return ApiService.Delete(_url, serviceUrl) |
|||
} |
|||
} |
|||
|
|||
export enum HashType { |
|||
Sha256, |
|||
Sha512 |
|||
} |
|||
|
|||
export class ApiScope { |
|||
name = '' |
|||
displayName?: string = '' |
|||
description?: string = '' |
|||
required = false |
|||
emphasize = false |
|||
showInDiscoveryDocument = true |
|||
userClaims = new Array<string>() |
|||
} |
|||
|
|||
export class ApiSecret extends SecretBase {} |
|||
|
|||
export class ApiSecretCreateOrUpdate extends SecretBase { |
|||
hashType = HashType.Sha256 |
|||
} |
|||
|
|||
export class ApiResourceCreateOrUpdate { |
|||
displayName?: string = '' |
|||
description?: string = '' |
|||
enabled = true |
|||
userClaims = new Array<string>() |
|||
scopes = new Array<ApiScope>() |
|||
secrets = new Array<ApiSecretCreateOrUpdate>() |
|||
properties: {[key: string]: string} = {} |
|||
} |
|||
|
|||
export class ApiResourceCreate extends ApiResourceCreateOrUpdate { |
|||
name = '' |
|||
} |
|||
|
|||
export class ApiResourceUpdate extends ApiResourceCreateOrUpdate {} |
|||
|
|||
export class ApiResource extends FullAuditedEntityDto { |
|||
id!: string |
|||
name!: string |
|||
displayName?: string |
|||
description?: string |
|||
enabled!: boolean |
|||
userClaims = new Array<string>() |
|||
scopes = new Array<ApiScope>() |
|||
secrets = new Array<ApiSecretCreateOrUpdate>() |
|||
properties: {[key: string]: string} = {} |
|||
} |
|||
|
|||
export class ApiResourceGetByPaged extends PagedAndSortedResultRequestDto { |
|||
filter = '' |
|||
} |
|||
@ -1,279 +0,0 @@ |
|||
import ApiService from './serviceBase' |
|||
import { FullAuditedEntityDto, PagedAndSortedResultRequestDto, PagedResultDto } from './types' |
|||
|
|||
const serviceUrl = process.env.VUE_APP_BASE_API |
|||
|
|||
export default class ApiResourceService { |
|||
/** |
|||
* 获取Api资源 |
|||
* @param id Api资源标识 |
|||
*/ |
|||
public static getApiResourceById(id: string) { |
|||
let _url = '/api/IdentityServer/ApiResources/' |
|||
_url += id |
|||
return ApiService.Get<ApiResource>(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 获取Api资源列表 |
|||
* @param payload 查询参数 |
|||
*/ |
|||
public static getApiResources(payload: ApiResourceGetByPaged) { |
|||
let _url = '/api/IdentityServer/ApiResources' |
|||
_url += '?filter=' + payload.filter |
|||
_url += '&sorting=' + payload.sorting |
|||
_url += '&skipCount=' + payload.skipCount |
|||
_url += '&maxResultCount=' + payload.maxResultCount |
|||
return ApiService.Get<PagedResultDto<ApiResource>>(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 创建Api资源 |
|||
* @param payload api资源参数 |
|||
*/ |
|||
public static createApiResource(payload: ApiResourceCreate) { |
|||
const _url = '/api/IdentityServer/ApiResources' |
|||
return ApiService.Post<ApiResource>(_url, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 变更Api资源 |
|||
* @param payload api资源参数 |
|||
*/ |
|||
public static updateApiResource(payload: ApiResourceUpdate) { |
|||
const _url = '/api/IdentityServer/ApiResources' |
|||
return ApiService.Put<ApiResource>(_url, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 删除Api资源 |
|||
* @param id Api资源标识 |
|||
*/ |
|||
public static deleteApiResource(id: string) { |
|||
let _url = '/api/IdentityServer/ApiResources/' |
|||
_url += id |
|||
return ApiService.Delete(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 增加Api密钥 |
|||
* @param payload Api密钥参数 |
|||
*/ |
|||
public static addApiSecret(payload: ApiSecretCreate) { |
|||
const _url = '/api/IdentityServer/ApiResources/Secrets' |
|||
return ApiService.Post<ApiSecret>(_url, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 删除Api密钥 |
|||
* @param apiResourceId 资源标识 |
|||
* @param type 密钥类型 |
|||
* @param value 密钥值 |
|||
*/ |
|||
public static deleteApiSecret(apiResourceId: string, type: string, value: string) { |
|||
let _url = '/api/IdentityServer/ApiResources/Secrets/' |
|||
_url += '?apiResourceId=' + apiResourceId |
|||
_url += '&type=' + type |
|||
_url += '&value=' + value |
|||
return ApiService.Delete(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 增加Api授权范围 |
|||
* @param payload api授权范围参数 |
|||
*/ |
|||
public static addApiScope(payload: ApiScopeCreate) { |
|||
const _url = '/api/IdentityServer/ApiResources/Scopes' |
|||
return ApiService.Post<ApiScope>(_url, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 删除Api授权范围 |
|||
* @param apiResourceId api资源标识 |
|||
* @param name 授权范围名称 |
|||
*/ |
|||
public static deleteApiScope(apiResourceId: string, name: string) { |
|||
let _url = '/api/IdentityServer/ApiResources/Scopes' |
|||
_url += '?apiResourceId=' + apiResourceId |
|||
_url += '&name=' + name |
|||
return ApiService.Delete(_url, serviceUrl) |
|||
} |
|||
} |
|||
|
|||
export enum HashType { |
|||
Sha256, |
|||
Sha512 |
|||
} |
|||
|
|||
export class ApiSecret { |
|||
type!: string |
|||
value!: string |
|||
hashType?: HashType |
|||
description?: string |
|||
expiration?: Date |
|||
} |
|||
|
|||
export class ApiScopeClaim { |
|||
type!: string |
|||
} |
|||
|
|||
export class ApiResourceClaim { |
|||
type!: string |
|||
} |
|||
|
|||
export class ApiScope { |
|||
name!: string |
|||
displayName?: string |
|||
description?: string |
|||
required!: boolean |
|||
emphasize!: boolean |
|||
showInDiscoveryDocument!: boolean |
|||
userClaims: ApiScopeClaim[] |
|||
|
|||
constructor() { |
|||
this.userClaims = new Array<ApiScopeClaim>() |
|||
} |
|||
} |
|||
|
|||
export class ApiScopeCreate { |
|||
apiResourceId!: string |
|||
name!: string |
|||
displayName?: string |
|||
description?: string |
|||
required!: boolean |
|||
emphasize!: boolean |
|||
showInDiscoveryDocument!: boolean |
|||
userClaims: ApiScopeClaim[] |
|||
|
|||
constructor() { |
|||
this.apiResourceId = '' |
|||
this.name = '' |
|||
this.displayName = '' |
|||
this.description = '' |
|||
this.required = false |
|||
this.emphasize = false |
|||
this.showInDiscoveryDocument = false |
|||
this.userClaims = new Array<ApiScopeClaim>() |
|||
} |
|||
|
|||
public static empty() { |
|||
return new ApiScopeCreate() |
|||
} |
|||
} |
|||
|
|||
export class ApiSecretCreate { |
|||
apiResourceId!: string |
|||
type!: string |
|||
value!: string |
|||
hashType?: HashType |
|||
description?: string |
|||
expiration?: Date |
|||
|
|||
constructor() { |
|||
this.type = 'SharedSecret' |
|||
this.value = '' |
|||
this.hashType = HashType.Sha256 |
|||
this.description = '' |
|||
this.expiration = undefined |
|||
} |
|||
|
|||
public static empty() { |
|||
return new ApiSecretCreate() |
|||
} |
|||
} |
|||
|
|||
export class ApiResourceCreate { |
|||
name!: string |
|||
displayName?: string |
|||
description?: string |
|||
enabled!: boolean |
|||
userClaims!: ApiResourceClaim[] |
|||
|
|||
constructor() { |
|||
this.name = '' |
|||
this.displayName = '' |
|||
this.description = '' |
|||
this.enabled = true |
|||
this.userClaims = new Array<ApiResourceClaim>() |
|||
} |
|||
|
|||
public static empty() { |
|||
return new ApiResourceCreate() |
|||
} |
|||
|
|||
public static create(apiResource: ApiResource) { |
|||
const resource = ApiResourceCreate.empty() |
|||
resource.name = apiResource.name |
|||
resource.displayName = apiResource.displayName |
|||
resource.description = apiResource.description |
|||
resource.enabled = apiResource.enabled |
|||
resource.userClaims = apiResource.userClaims |
|||
return resource |
|||
} |
|||
} |
|||
|
|||
export class ApiResourceUpdate { |
|||
id!: string |
|||
displayName?: string |
|||
description?: string |
|||
enabled!: boolean |
|||
userClaims!: ApiResourceClaim[] |
|||
|
|||
constructor() { |
|||
this.id = '' |
|||
this.displayName = '' |
|||
this.description = '' |
|||
this.enabled = true |
|||
this.userClaims = new Array<ApiResourceClaim>() |
|||
} |
|||
|
|||
public static empty() { |
|||
return new ApiResourceUpdate() |
|||
} |
|||
|
|||
public static create(apiResource: ApiResource) { |
|||
const resource = ApiResourceUpdate.empty() |
|||
resource.id = apiResource.id |
|||
resource.displayName = apiResource.displayName |
|||
resource.description = apiResource.description |
|||
resource.enabled = apiResource.enabled |
|||
resource.userClaims = apiResource.userClaims |
|||
return resource |
|||
} |
|||
} |
|||
|
|||
export class ApiResource extends FullAuditedEntityDto { |
|||
id!: string |
|||
name!: string |
|||
displayName?: string |
|||
description?: string |
|||
enabled!: boolean |
|||
secrets!: ApiSecret[] |
|||
scopes!: ApiScope[] |
|||
userClaims!: ApiResourceClaim[] |
|||
|
|||
constructor() { |
|||
super() |
|||
this.id = '' |
|||
this.name = '' |
|||
this.displayName = '' |
|||
this.description = '' |
|||
this.enabled = true |
|||
this.scopes = new Array<ApiScope>() |
|||
this.secrets = new Array<ApiSecret>() |
|||
this.userClaims = new Array<ApiResourceClaim>() |
|||
} |
|||
|
|||
public static empty() { |
|||
return new ApiResource() |
|||
} |
|||
} |
|||
|
|||
export class ApiResourceGetByPaged extends PagedAndSortedResultRequestDto { |
|||
filter!: string |
|||
|
|||
constructor() { |
|||
super() |
|||
this.filter = '' |
|||
} |
|||
} |
|||
@ -0,0 +1,89 @@ |
|||
import ApiService from './serviceBase' |
|||
import { FullAuditedEntityDto, PagedResultDto, PagedAndSortedResultRequestDto } from './types' |
|||
|
|||
const sourceUrl = '/api/identity-server/identity-resources' |
|||
/** 远程服务地址 */ |
|||
const serviceUrl = process.env.VUE_APP_BASE_API |
|||
|
|||
/** 身份资源Api接口 */ |
|||
export default class IdentityResourceService { |
|||
/** |
|||
* 获取身份资源 |
|||
* @param id 身份资源标识 |
|||
* @returns 返回类型为 IdentityResource 的对象 |
|||
*/ |
|||
public static getIdentityResourceById(id: string) { |
|||
const _url = sourceUrl + '/' + id |
|||
return ApiService.Get<IdentityResource>(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 获取身份资源列表 |
|||
* @param payload 分页查询过滤对象 |
|||
* @returns 返回类型为 IdentityResource 的对象列表 |
|||
*/ |
|||
public static getIdentityResources(payload: IdentityResourceGetByPaged) { |
|||
let _url = sourceUrl + '?filter=' + payload.filter |
|||
_url += '&sorting=' + payload.sorting |
|||
_url += '&skipCount=' + payload.skipCount |
|||
_url += '&maxResultCount=' + payload.maxResultCount |
|||
return ApiService.Get<PagedResultDto<IdentityResource>>(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 创建身份资源 |
|||
* @param payload 类型为 IdentityResourceCreate 的对象 |
|||
* @returns 返回类型为 IdentityResource 的对象 |
|||
*/ |
|||
public static createIdentityResource(payload: IdentityResourceCreateOrUpdate) { |
|||
return ApiService.Post<IdentityResource>(sourceUrl, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 变更身份资源 |
|||
* @param payload 类型为 IdentityResourceUpdate 的对象 |
|||
* @returns 返回类型为 IdentityResource 的对象 |
|||
*/ |
|||
public static updateIdentityResource(id: string, payload: IdentityResourceCreateOrUpdate) { |
|||
const _url = sourceUrl + '/' + id |
|||
return ApiService.Put<IdentityResource>(_url, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 删除身份资源 |
|||
* @param id 身份资源标识 |
|||
*/ |
|||
public static deleteIdentityResource(id: string) { |
|||
const _url = sourceUrl + '/' + id |
|||
return ApiService.Delete(_url, serviceUrl) |
|||
} |
|||
} |
|||
|
|||
export class IdentityResource extends FullAuditedEntityDto { |
|||
id!: string |
|||
name = '' |
|||
displayName?: string = '' |
|||
description?: string = '' |
|||
enabled = true |
|||
required = false |
|||
emphasize = false |
|||
showInDiscoveryDocument = true |
|||
userClaims = new Array<string>() |
|||
properties: {[key: string]: string} = {} |
|||
} |
|||
|
|||
export class IdentityResourceGetByPaged extends PagedAndSortedResultRequestDto { |
|||
filter = '' |
|||
} |
|||
|
|||
export class IdentityResourceCreateOrUpdate { |
|||
name = '' |
|||
displayName?: string = '' |
|||
description?: string = '' |
|||
enabled = true |
|||
required = false |
|||
emphasize = false |
|||
showInDiscoveryDocument = true |
|||
userClaims = new Array<string>() |
|||
properties: {[key: string]: string} = {} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
import ApiService from './serviceBase' |
|||
|
|||
const openIdConfigurationUrl = '/.well-known/openid-configuration' |
|||
|
|||
export default class IdentityServer4Service { |
|||
public static getOpenIdConfiguration() { |
|||
return ApiService.Get<OpenIdConfiguration>(openIdConfigurationUrl) |
|||
} |
|||
} |
|||
|
|||
export class OpenIdConfiguration { |
|||
issuer!: string |
|||
jwks_uri!: string |
|||
authorization_endpoint!: string |
|||
token_endpoint!: string |
|||
userinfo_endpoint!: string |
|||
end_session_endpoint!: string |
|||
check_session_iframe!: string |
|||
revocation_endpoint!: string |
|||
introspection_endpoint!: string |
|||
device_authorization_endpoint!: string |
|||
frontchannel_logout_supported!: boolean |
|||
frontchannel_logout_session_supported!: boolean |
|||
backchannel_logout_supported!: boolean |
|||
backchannel_logout_session_supported!: boolean |
|||
scopes_supported = new Array<string>() |
|||
claims_supported = new Array<string>() |
|||
grant_types_supported = new Array<string>() |
|||
response_types_supported = new Array<string>() |
|||
response_modes_supported = new Array<string>() |
|||
token_endpoint_auth_methods_supported = new Array<string>() |
|||
id_token_signing_alg_values_supported = new Array<string>() |
|||
subject_types_supported = new Array<string>() |
|||
code_challenge_methods_supported = new Array<string>() |
|||
request_parameter_supported!: boolean |
|||
} |
|||
@ -1,244 +0,0 @@ |
|||
import ApiService from './serviceBase' |
|||
import { FullAuditedEntityDto, PagedResultDto, PagedAndSortedResultRequestDto } from './types' |
|||
|
|||
/** 远程服务地址 */ |
|||
const serviceUrl = process.env.VUE_APP_BASE_API |
|||
|
|||
/** 身份资源Api接口 */ |
|||
export default class IdentityResourceService { |
|||
/** |
|||
* 获取身份资源 |
|||
* @param id 身份资源标识 |
|||
* @returns 返回类型为 IdentityResource 的对象 |
|||
*/ |
|||
public static getIdentityResourceById(id: string) { |
|||
let _url = '/api/IdentityServer/IdentityResources/' |
|||
_url += id |
|||
return ApiService.Get<IdentityResource>(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 获取身份资源列表 |
|||
* @param payload 分页查询过滤对象 |
|||
* @returns 返回类型为 IdentityResource 的对象列表 |
|||
*/ |
|||
public static getIdentityResources(payload: IdentityResourceGetByPaged) { |
|||
let _url = '/api/IdentityServer/IdentityResources' |
|||
_url += '?filter=' + payload.filter |
|||
_url += '&sorting=' + payload.sorting |
|||
_url += '&skipCount=' + payload.skipCount |
|||
_url += '&maxResultCount=' + payload.maxResultCount |
|||
return ApiService.Get<PagedResultDto<IdentityResource>>(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 创建身份资源 |
|||
* @param payload 类型为 IdentityResourceCreate 的对象 |
|||
* @returns 返回类型为 IdentityResource 的对象 |
|||
*/ |
|||
public static createIdentityResource(payload: IdentityResourceCreate) { |
|||
const _url = '/api/IdentityServer/IdentityResources' |
|||
return ApiService.Post<IdentityResource>(_url, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 变更身份资源 |
|||
* @param payload 类型为 IdentityResourceUpdate 的对象 |
|||
* @returns 返回类型为 IdentityResource 的对象 |
|||
*/ |
|||
public static updateIdentityResource(payload: IdentityResourceUpdate) { |
|||
const _url = '/api/IdentityServer/IdentityResources' |
|||
return ApiService.Put<IdentityResource>(_url, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 删除身份资源 |
|||
* @param id 身份资源标识 |
|||
*/ |
|||
public static deleteIdentityResource(id: string) { |
|||
let _url = '/api/IdentityServer/IdentityResources' |
|||
_url += '?id=' + id |
|||
return ApiService.Delete(_url, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 创建身份资源属性 |
|||
* @param payload 类型为 IdentityPropertyCreate 的对象 |
|||
* @returns 返回类型为 IdentityProperty 的对象 |
|||
*/ |
|||
public static createProperty(payload: IdentityPropertyCreate) { |
|||
const _url = '/api/IdentityServer/IdentityResources/Properties' |
|||
return ApiService.Post<IdentityProperty>(_url, payload, serviceUrl) |
|||
} |
|||
|
|||
/** |
|||
* 删除身份资源属性 |
|||
* @param identityResourceId 身份资源标识 |
|||
* @param key 身份资源属性键 |
|||
*/ |
|||
public static deleteProperty(identityResourceId: string, key: string) { |
|||
let _url = '/api/IdentityServer/IdentityResources/Properties' |
|||
_url += '?identityResourceId=' + identityResourceId |
|||
_url += '&key=' + key |
|||
return ApiService.Delete(_url, serviceUrl) |
|||
} |
|||
} |
|||
|
|||
/** 身份资源用户声明 */ |
|||
export class IdentityClaim { |
|||
/** 用户声明 */ |
|||
type = '' |
|||
} |
|||
|
|||
/** 身份资源属性 */ |
|||
export class IdentityProperty { |
|||
/** 键 */ |
|||
key = '' |
|||
/** 值 */ |
|||
value = '' |
|||
} |
|||
|
|||
/** 身份资源属性创建对象 */ |
|||
export class IdentityPropertyCreate { |
|||
/** 身份资源标识 */ |
|||
identityResourceId = '' |
|||
/** 键 */ |
|||
key = '' |
|||
/** 值 */ |
|||
value = '' |
|||
/** 并发令牌 */ |
|||
concurrencyStamp = '' |
|||
|
|||
/** 返回一个空对象 */ |
|||
public static empty() { |
|||
return new IdentityPropertyCreate() |
|||
} |
|||
} |
|||
|
|||
/** 身份资源分页查询对象 */ |
|||
export class IdentityResourceGetByPaged extends PagedAndSortedResultRequestDto { |
|||
/** 过滤参数 */ |
|||
filter = '' |
|||
|
|||
/** 返回一个空对象 */ |
|||
public static empty() { |
|||
return new IdentityResourceGetByPaged() |
|||
} |
|||
} |
|||
|
|||
/** 身份资源创建对象 */ |
|||
export class IdentityResourceCreate { |
|||
/** 名称 */ |
|||
name = '' |
|||
/** 显示名称 */ |
|||
displayName? = '' |
|||
/** 说明 */ |
|||
description? = '' |
|||
/** 启用 */ |
|||
enabled = true |
|||
/** 必须 */ |
|||
required = false |
|||
/** 强调 */ |
|||
emphasize = false |
|||
/** 在发现文档显示 */ |
|||
showInDiscoveryDocument = false |
|||
/** 用户声明 */ |
|||
userClaims = new Array<IdentityClaim>() |
|||
|
|||
/** 返回一个空对象 */ |
|||
public static empty() { |
|||
return new IdentityResourceCreate() |
|||
} |
|||
|
|||
/** 创建身份资源 */ |
|||
public static create(identityResource: IdentityResource) { |
|||
const resource = new IdentityResourceCreate() |
|||
resource.description = identityResource.description |
|||
resource.displayName = identityResource.displayName |
|||
resource.emphasize = identityResource.emphasize |
|||
resource.enabled = identityResource.enabled |
|||
resource.name = identityResource.name |
|||
resource.required = identityResource.required |
|||
resource.showInDiscoveryDocument = identityResource.showInDiscoveryDocument |
|||
resource.userClaims = identityResource.userClaims |
|||
return resource |
|||
} |
|||
} |
|||
|
|||
/** 身份资源变更对象 */ |
|||
export class IdentityResourceUpdate { |
|||
/** 身份资源标识 */ |
|||
id = '' |
|||
/** 名称 */ |
|||
name = '' |
|||
/** 显示名称 */ |
|||
displayName? = '' |
|||
/** 说明 */ |
|||
description? = '' |
|||
/** 启用 */ |
|||
enabled = true |
|||
/** 必须 */ |
|||
required = false |
|||
/** 强调 */ |
|||
emphasize = false |
|||
/** 在发现文档显示 */ |
|||
showInDiscoveryDocument = false |
|||
/** 并发令牌 */ |
|||
concurrencyStamp = '' |
|||
/** 用户声明 */ |
|||
userClaims = new Array<IdentityClaim>() |
|||
|
|||
/** 返回一个空对象 */ |
|||
public static empty() { |
|||
return new IdentityResourceUpdate() |
|||
} |
|||
|
|||
/** 创建身份资源 */ |
|||
public static create(identityResource: IdentityResource) { |
|||
const resource = new IdentityResourceUpdate() |
|||
resource.concurrencyStamp = identityResource.concurrencyStamp |
|||
resource.description = identityResource.description |
|||
resource.displayName = identityResource.displayName |
|||
resource.emphasize = identityResource.emphasize |
|||
resource.enabled = identityResource.enabled |
|||
resource.id = identityResource.id |
|||
resource.name = identityResource.name |
|||
resource.required = identityResource.required |
|||
resource.showInDiscoveryDocument = identityResource.showInDiscoveryDocument |
|||
resource.userClaims = identityResource.userClaims |
|||
return resource |
|||
} |
|||
} |
|||
|
|||
/** 身份资源对象 */ |
|||
export class IdentityResource extends FullAuditedEntityDto { |
|||
/** 身份资源标识 */ |
|||
id!: string |
|||
/** 名称 */ |
|||
name!: string |
|||
/** 显示名称 */ |
|||
displayName?: string |
|||
/** 说明 */ |
|||
description?: string |
|||
/** 并发令牌 */ |
|||
concurrencyStamp!: string |
|||
/** 启用 */ |
|||
enabled!: boolean |
|||
/** 必须 */ |
|||
required!: boolean |
|||
/** 强调 */ |
|||
emphasize!: boolean |
|||
/** 在发现文档显示 */ |
|||
showInDiscoveryDocument!: boolean |
|||
/** 用户声明 */ |
|||
userClaims!: IdentityClaim[] |
|||
/** 属性 */ |
|||
properties!: IdentityProperty[] |
|||
|
|||
/** 返回一个空对象 */ |
|||
public static empty() { |
|||
const resource = new IdentityResource() |
|||
resource.enabled = true |
|||
return resource |
|||
} |
|||
} |
|||
@ -0,0 +1,473 @@ |
|||
<template> |
|||
<el-dialog |
|||
v-el-draggable-dialog |
|||
width="800px" |
|||
:visible="showDialog" |
|||
:title="$t('AbpPermissionManagement.Permissions') + '-' + entityDisplayName" |
|||
custom-class="modal-form" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
:show-close="false" |
|||
@close="onFormClosed" |
|||
> |
|||
<el-form> |
|||
<el-checkbox |
|||
:disabled="readonly" |
|||
:value="grantAllCheckBoxCheckAll" |
|||
:indeterminate="grantAllCheckBoxForward" |
|||
@change="onGrantAllClicked" |
|||
> |
|||
{{ $t('AbpPermissionManagement.SelectAllInAllTabs') }} |
|||
</el-checkbox> |
|||
<el-divider /> |
|||
<el-tabs |
|||
v-model="activeTabPane" |
|||
tab-position="left" |
|||
type="card" |
|||
> |
|||
<el-tab-pane |
|||
v-for="group in permissionGroups" |
|||
:key="group.name" |
|||
:label="group.displayName + ' (' + grantedCount(group) + ')'" |
|||
:name="group.name" |
|||
> |
|||
<el-card shadow="never"> |
|||
<div |
|||
slot="header" |
|||
class="clearfix" |
|||
> |
|||
<h3>{{ group.displayName }}</h3> |
|||
</div> |
|||
<el-checkbox |
|||
:disabled="readonly" |
|||
:value="scopeCheckBoxCheckAll(group)" |
|||
:indeterminate="scopeCheckBoxForward(group)" |
|||
@change="(checked) => onCheckScopeAllClicked(checked, group, 'permissionTree-' + group.name)" |
|||
> |
|||
{{ $t('AbpPermissionManagement.SelectAllInThisTab') }} |
|||
</el-checkbox> |
|||
<el-divider /> |
|||
<el-tree |
|||
:ref="'permissionTree-' + group.name" |
|||
show-checkbox |
|||
:check-strictly="true" |
|||
node-key="id" |
|||
:data="group.permissions" |
|||
:default-checked-keys="grantedPermissionKeys(group)" |
|||
@check-change="(permission, checked) => onPermissionTreeNodeCheckChanged(permission, checked, group, 'permissionTree-' + group.name)" |
|||
/> |
|||
</el-card> |
|||
</el-tab-pane> |
|||
</el-tabs> |
|||
<el-divider /> |
|||
<el-form-item> |
|||
<el-button |
|||
class="cancel" |
|||
type="info" |
|||
style="width:100px" |
|||
@click="onFormClosed" |
|||
> |
|||
{{ $t('AbpPermissionManagement.Cancel') }} |
|||
</el-button> |
|||
<el-button |
|||
:disabled="readonly" |
|||
class="confirm" |
|||
type="primary" |
|||
style="width:100px" |
|||
icon="el-icon-check" |
|||
:loading="confirmButtonBusy" |
|||
@click="onSave" |
|||
> |
|||
{{ confirmButtonTitle }} |
|||
</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { Component, Vue, Prop, Watch } from 'vue-property-decorator' |
|||
import PermissionApiService, { Permission, UpdatePermissionsDto } from '@/api/permission' |
|||
import { Tree } from 'element-ui' |
|||
|
|||
/** element权限树 */ |
|||
export class PermissionItem { |
|||
/** 权限标识 */ |
|||
id = '' |
|||
/** 显示名称 */ |
|||
label = '' |
|||
/** 是否授权 */ |
|||
isGrant = false |
|||
/** 是否禁用 */ |
|||
disabled = false |
|||
/** 子节点 */ |
|||
children = new Array<PermissionItem>() |
|||
/** 父节点 */ |
|||
parent?: PermissionItem |
|||
|
|||
constructor( |
|||
id: string, |
|||
label: string, |
|||
isGrant: boolean |
|||
) { |
|||
this.id = id |
|||
this.label = label |
|||
this.isGrant = isGrant |
|||
} |
|||
|
|||
public createChildren(permission: PermissionItem) { |
|||
permission.parent = this |
|||
this.children.push(permission) |
|||
} |
|||
|
|||
public setGrant(grant: boolean) { |
|||
this.isGrant = grant |
|||
if (this.parent) { |
|||
this.parent.setGrant(grant) |
|||
} |
|||
} |
|||
|
|||
public static setPermissionGrant(grant: boolean, permission: PermissionItem) { |
|||
permission.setGrant(grant) |
|||
if (!grant) { |
|||
permission.children.map(p => { |
|||
PermissionItem.setPermissionGrant(false, p) |
|||
}) |
|||
} |
|||
} |
|||
|
|||
public static setAllPermissionGrant(grant: boolean, permission: PermissionItem) { |
|||
permission.setGrant(grant) |
|||
permission.children.map(p => { |
|||
PermissionItem.setAllPermissionGrant(grant, p) |
|||
}) |
|||
} |
|||
} |
|||
|
|||
export class PermissionGroup { |
|||
name = '' |
|||
displayName = '' |
|||
permissions = new Array<PermissionItem>() |
|||
|
|||
constructor( |
|||
name: string, |
|||
displayName: string |
|||
) { |
|||
this.name = name |
|||
this.displayName = displayName |
|||
} |
|||
|
|||
public permissionCount() { |
|||
let count = 0 |
|||
count += this.deepPermissionCount(this.permissions) |
|||
return count |
|||
} |
|||
|
|||
public addPermission(permission: PermissionItem) { |
|||
this.permissions.push(permission) |
|||
} |
|||
|
|||
public setAllGrant(grant: boolean) { |
|||
this.permissions.map(p => { |
|||
PermissionItem.setAllPermissionGrant(grant, p) |
|||
}) |
|||
} |
|||
|
|||
public grantedPermissionKeys() { |
|||
const keys = new Array<string>() |
|||
this.deepGrantedPermissionKeys(keys, this.permissions) |
|||
return keys |
|||
} |
|||
|
|||
public grantedCount() { |
|||
let count = 0 |
|||
count += this.deepGrantedCount(this.permissions) |
|||
return count |
|||
} |
|||
|
|||
private deepGrantedCount(permissions: PermissionItem[]) { |
|||
let count = 0 |
|||
count += permissions.filter(p => p.isGrant).length |
|||
permissions.forEach(p => { |
|||
count += this.deepGrantedCount(p.children) |
|||
}) |
|||
return count |
|||
} |
|||
|
|||
private deepGrantedPermissionKeys(keys: string[], permissions: PermissionItem[]) { |
|||
permissions.forEach(p => { |
|||
if (p.isGrant) { |
|||
keys.push(p.id) |
|||
} |
|||
this.deepGrantedPermissionKeys(keys, p.children) |
|||
}) |
|||
} |
|||
|
|||
private deepPermissionCount(permissions: PermissionItem[]) { |
|||
let count = 0 |
|||
count += permissions.length |
|||
permissions.forEach(p => { |
|||
count += this.deepPermissionCount(p.children) |
|||
}) |
|||
return count |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 权限编辑组件 |
|||
* 大量的计算属性与事件响应,还能再优化 |
|||
*/ |
|||
@Component({ |
|||
name: 'PermissionForm' |
|||
}) |
|||
export default class PermissionForm extends Vue { |
|||
/** 权限提供者名称 */ |
|||
@Prop({ default: '' }) |
|||
private providerName!: string |
|||
|
|||
/** 权限提供者标识 */ |
|||
@Prop({ default: '' }) |
|||
private providerKey!: string |
|||
|
|||
/** 是否展示权限编辑组件 */ |
|||
@Prop({ default: false }) |
|||
private showDialog!: boolean |
|||
|
|||
/** 权限节点是否只读 */ |
|||
@Prop({ default: false }) |
|||
private readonly!: boolean |
|||
|
|||
/** 激活tab页 */ |
|||
private activeTabPane = '' |
|||
/** 确认按钮忙碌状态 */ |
|||
private confirmButtonBusy = false |
|||
/** 当前编辑权限实体名称 */ |
|||
private entityDisplayName = '' |
|||
/** 得到的权限组集合 */ |
|||
private permissionGroups = new Array<PermissionGroup>() |
|||
|
|||
/** 某个权限组已授权数量 |
|||
* 用于显示已授权数量 |
|||
*/ |
|||
get grantedCount() { |
|||
return (group: PermissionGroup) => { |
|||
return group.grantedCount() |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 所有已授权数量 |
|||
*/ |
|||
get grantAllCount() { |
|||
let count = 0 |
|||
this.permissionGroups.forEach(group => { |
|||
count += group.grantedCount() |
|||
}) |
|||
return count |
|||
} |
|||
|
|||
/** 某个权限组已授权节点 |
|||
* 用于勾选TreeNode |
|||
*/ |
|||
get grantedPermissionKeys() { |
|||
return (group: PermissionGroup) => { |
|||
return group.grantedPermissionKeys() |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 某个权限组权限数量 |
|||
* 用于设定单个Tree的全选CheckBox状态 |
|||
*/ |
|||
get permissionCount() { |
|||
return (group: PermissionGroup) => { |
|||
return group.permissionCount() |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 所有权限数量 |
|||
*/ |
|||
get permissionAllCount() { |
|||
let count = 0 |
|||
this.permissionGroups.forEach(group => { |
|||
count += group.permissionCount() |
|||
}) |
|||
return count |
|||
} |
|||
|
|||
/** |
|||
* 单个Tree的全选CheckBox是否为选中状态 |
|||
*/ |
|||
get scopeCheckBoxCheckAll() { |
|||
return (group: PermissionGroup) => { |
|||
const grantCount = group.grantedCount() |
|||
return grantCount === group.permissionCount() |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 单个Tree的全选CheckBox状态是否为预选状态 |
|||
*/ |
|||
get scopeCheckBoxForward() { |
|||
return (group: PermissionGroup) => { |
|||
const grantCount = group.grantedCount() |
|||
return grantCount > 0 && grantCount < group.permissionCount() |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 授权所有CheckBox是否为选中状态 |
|||
*/ |
|||
get grantAllCheckBoxCheckAll() { |
|||
return this.grantAllCount === this.permissionAllCount |
|||
} |
|||
|
|||
/** |
|||
* 授权所有CheckBox状态是否为预选状态 |
|||
*/ |
|||
get grantAllCheckBoxForward() { |
|||
const grantCount = this.grantAllCount |
|||
return grantCount > 0 && grantCount < this.permissionAllCount |
|||
} |
|||
|
|||
/** |
|||
* 确认按钮标题 |
|||
*/ |
|||
get confirmButtonTitle() { |
|||
if (this.confirmButtonBusy) { |
|||
return this.$t('AbpPermissionManagement.SavingWithThreeDot') |
|||
} |
|||
return this.$t('AbpPermissionManagement.Save') |
|||
} |
|||
|
|||
/** |
|||
* 响应组件可视事件 |
|||
*/ |
|||
@Watch('showDialog', { immediate: true }) |
|||
private onShowDialogChanged() { |
|||
this.handleGetPermissions() |
|||
} |
|||
|
|||
/** |
|||
* 获取权限集合 |
|||
*/ |
|||
private handleGetPermissions() { |
|||
this.activeTabPane = '' |
|||
this.permissionGroups.length = 0 |
|||
if (this.showDialog && this.providerName) { |
|||
PermissionApiService.getPermissionsByKey(this.providerName, this.providerKey).then(res => { |
|||
this.entityDisplayName = res.entityDisplayName |
|||
res.groups.map(g => { |
|||
const group = new PermissionGroup(g.name, g.displayName) |
|||
const parents = g.permissions.filter(p => p.parentName === null) |
|||
parents.forEach(parent => { |
|||
const permission = new PermissionItem(parent.name, parent.displayName, parent.isGranted) |
|||
permission.disabled = this.readonly |
|||
const subPermissions = g.permissions.filter(p => p.parentName?.startsWith(parent.name)) |
|||
this.generatePermission(permission, subPermissions) |
|||
group.addPermission(permission) |
|||
}) |
|||
this.permissionGroups.push(group) |
|||
}) |
|||
if (this.permissionGroups.length > 0) { |
|||
this.activeTabPane = this.permissionGroups[0].name |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
|
|||
/** 递归生成子节点 |
|||
* @param permissionTree 二级权限树 |
|||
* @param permissions 权限列表 |
|||
*/ |
|||
private generatePermission(permission: PermissionItem, permissions: Permission[]) { |
|||
const subPermissions = permissions.filter(p => p.parentName !== permission.id) |
|||
permissions = permissions.filter(p => p.parentName === permission.id) |
|||
permissions.forEach(p => { |
|||
const children = new PermissionItem(p.name, p.displayName, p.isGranted) |
|||
children.disabled = this.readonly |
|||
const itemSubPermissions = subPermissions.filter(sp => sp.parentName === p.name) |
|||
if (itemSubPermissions.length > 0) { |
|||
this.generatePermission(children, itemSubPermissions) |
|||
} |
|||
permission.createChildren(children) |
|||
}) |
|||
} |
|||
|
|||
/** |
|||
* 保存权限 |
|||
*/ |
|||
private onSave() { |
|||
const updatePermission = new UpdatePermissionsDto() |
|||
this.permissionGroups.forEach(group => { |
|||
this.updatePermissionByInput(updatePermission, group.permissions) |
|||
}) |
|||
this.confirmButtonBusy = true |
|||
PermissionApiService |
|||
.setPermissionsByKey(this.providerName, this.providerKey, updatePermission) |
|||
.then(() => { |
|||
this.$message.success(this.$t('global.successful').toString()) |
|||
}) |
|||
.finally(() => { |
|||
this.confirmButtonBusy = false |
|||
}) |
|||
} |
|||
|
|||
private updatePermissionByInput(permissions: UpdatePermissionsDto, items: PermissionItem[]) { |
|||
items.forEach(p => { |
|||
permissions.addPermission(p.id, p.isGrant) |
|||
this.updatePermissionByInput(permissions, p.children) |
|||
}) |
|||
} |
|||
|
|||
/** |
|||
* 窗口关闭事件 |
|||
*/ |
|||
private onFormClosed() { |
|||
this.$emit('closed') |
|||
} |
|||
|
|||
/** |
|||
* 授予所有权限 按钮事件 |
|||
*/ |
|||
private onGrantAllClicked(checked: boolean) { |
|||
this.permissionGroups.forEach(group => { |
|||
group.setAllGrant(checked) |
|||
const trees = this.$refs['permissionTree-' + group.name] as Tree[] |
|||
trees[0].setCheckedKeys(this.grantedPermissionKeys(group)) |
|||
}) |
|||
} |
|||
|
|||
/** |
|||
* Permission Tree 全选按钮事件 |
|||
*/ |
|||
private onCheckScopeAllClicked(checked: boolean, group: PermissionGroup, treeRef: any) { |
|||
group.setAllGrant(checked) |
|||
const trees = this.$refs[treeRef] as Tree[] |
|||
trees[0].setCheckedKeys(this.grantedPermissionKeys(group)) |
|||
} |
|||
|
|||
/** |
|||
* Permission TreeNode 变更事件 |
|||
*/ |
|||
private onPermissionTreeNodeCheckChanged(permission: PermissionItem, checked: boolean, group: PermissionGroup, treeRef: any) { |
|||
PermissionItem.setPermissionGrant(checked, permission) |
|||
if (permission.children.length > 0) { |
|||
const trees = this.$refs[treeRef] as Tree[] |
|||
trees[0].setCheckedKeys(this.grantedPermissionKeys(group)) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.confirm { |
|||
position: absolute; |
|||
right: 10px; |
|||
} |
|||
.cancel { |
|||
position: absolute; |
|||
right: 120px; |
|||
} |
|||
</style> |
|||
@ -1,236 +0,0 @@ |
|||
<template> |
|||
<el-tree |
|||
ref="tree" |
|||
show-checkbox |
|||
node-key="id" |
|||
:data="permissionTreeData" |
|||
:default-checked-keys="[]" |
|||
:render-content="renderContent" |
|||
:default-expanded-keys="permissionExpandedKeys" |
|||
@check="handlePermissionChecked" |
|||
@node-expand="handleNodeExpand" |
|||
/> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { IPermission } from '@/api/types' |
|||
import { Component, Vue, Prop, Watch } from 'vue-property-decorator' |
|||
import { PermissionDto, PermissionGroup, Permission } from '@/api/permission' |
|||
|
|||
/** element权限树 */ |
|||
export class PermissionTree { |
|||
/** 权限标识 */ |
|||
id!: string |
|||
/** 显示名称 */ |
|||
label!: string |
|||
/** 是否禁用 */ |
|||
disabled!: boolean |
|||
/** 父节点 */ |
|||
parent!: string |
|||
/** 子节点 */ |
|||
children!: PermissionTree[] |
|||
|
|||
constructor() { |
|||
this.disabled = false |
|||
this.children = new Array<PermissionTree>() |
|||
} |
|||
} |
|||
|
|||
/** 权限树组件 */ |
|||
@Component({ |
|||
name: 'PermissionTree' |
|||
}) |
|||
export default class extends Vue { |
|||
/** 是否只读 */ |
|||
@Prop({ default: false }) private readonly!: boolean |
|||
/** 是否展开权限树 */ |
|||
@Prop({ default: false }) private expanded!: boolean |
|||
/** 是否水平排列 |
|||
* @description 功能实现来自:https://www.jianshu.com/p/f740e8c9fca6 |
|||
*/ |
|||
@Prop({ default: false }) private horizontally!: boolean |
|||
/** 权限列表 */ |
|||
@Prop({ default: () => new PermissionDto() }) private permission!: PermissionDto |
|||
/** 权限树 */ |
|||
private permissionTreeData: PermissionTree[] |
|||
/** 权限树选中节点 */ |
|||
private permissionCheckedKeys: string[] |
|||
/** 权限树展开节点 */ |
|||
private permissionExpandedKeys: string[] |
|||
/** 授权接口集合 */ |
|||
private permissionEditData: IPermission[] |
|||
|
|||
constructor() { |
|||
super() |
|||
this.permissionTreeData = new Array<PermissionTree>() |
|||
this.permissionCheckedKeys = new Array<string>() |
|||
this.permissionExpandedKeys = new Array<string>() |
|||
this.permissionEditData = new Array<IPermission>() |
|||
} |
|||
|
|||
@Watch('permission', { immediate: true }) |
|||
private onPermissionChanged(permission: PermissionDto) { |
|||
this.initilzePermissionTree(permission) |
|||
setTimeout(() => { |
|||
const treeControl = this.$refs.tree as any |
|||
treeControl.setCheckedKeys(this.permissionCheckedKeys) |
|||
}, 10) |
|||
} |
|||
|
|||
/** 重置权限树 */ |
|||
public resetPermissions() { |
|||
this.permissionTreeData.splice(0) |
|||
this.permissionCheckedKeys.splice(0) |
|||
this.permissionExpandedKeys.splice(0) |
|||
this.permissionEditData.splice(0) |
|||
} |
|||
|
|||
/** 初始化权限树 |
|||
* @param permission 权限数据 |
|||
*/ |
|||
private initilzePermissionTree(permission: PermissionDto) { |
|||
this.resetPermissions() |
|||
const permissionTree = new PermissionTree() |
|||
permissionTree.id = permission.entityDisplayName |
|||
permissionTree.label = '权限设置' |
|||
permissionTree.disabled = this.readonly |
|||
this.generatePermissionGroup(permissionTree, permission.groups) |
|||
this.permissionTreeData.push(permissionTree) |
|||
this.permissionExpandedKeys.push(permissionTree.id) |
|||
} |
|||
|
|||
/** 根据权限组生成二级权限树 |
|||
* @param permissionTree 根权限树 |
|||
* @param permissionGroups 根权限组 |
|||
*/ |
|||
private generatePermissionGroup(permissionTree: PermissionTree, permissionGroups: PermissionGroup[]) { |
|||
permissionGroups.forEach((group) => { |
|||
const permissionTreeItem = new PermissionTree() |
|||
permissionTreeItem.id = group.name |
|||
permissionTreeItem.label = group.displayName |
|||
permissionTreeItem.disabled = this.readonly |
|||
// 父节点是否全部展开 |
|||
if (this.expanded) { |
|||
this.permissionExpandedKeys.push(group.name) |
|||
} |
|||
this.generatePermission(permissionTreeItem, group.permissions) |
|||
permissionTree.children.push(permissionTreeItem) |
|||
// 父权限加入编辑权限列表 |
|||
// 按照abp框架的授权规则,Group(也就是二级权限数据)是不允许赋值的,要么后台过滤,要么前台不传,这里采用前台不传 |
|||
// this.permissionEditData.push({ name: group.name, isGranted: group.permissions.some(p => p.isGranted) }) |
|||
}) |
|||
} |
|||
|
|||
/** 根据权限列表生成三级权限树 |
|||
* @param permissionTree 二级权限树 |
|||
* @param permissions 权限列表 |
|||
*/ |
|||
private generatePermission(permissionTree: PermissionTree, permissions: Permission[]) { |
|||
const parentPermissions = permissions.filter(p => !p.parentName) |
|||
parentPermissions.forEach((permission) => { |
|||
const permissionTreeItem = new PermissionTree() |
|||
permissionTreeItem.id = permission.name |
|||
permissionTreeItem.label = permission.displayName |
|||
permissionTreeItem.disabled = this.readonly |
|||
this.permissionEditData.push(permission) |
|||
const subPermissions = permissions.filter(p => p.parentName === permission.name) |
|||
// 2020-08-28 如果这个权限没有子节点且已经授权,则选中节点 |
|||
if (subPermissions.length === 0) { |
|||
if (permission.isGranted) { |
|||
this.permissionCheckedKeys.push(permissionTreeItem.id) |
|||
} |
|||
} else { |
|||
this.generateSubPermission(permissionTreeItem, subPermissions, permissions) |
|||
} |
|||
permissionTree.children.push(permissionTreeItem) |
|||
}) |
|||
} |
|||
|
|||
/** 递归生成子节点权限树 |
|||
* @param permissionTree 父权限树 |
|||
* @param permissions 当前遍历权限节点 |
|||
* @param parentPermissions 当前遍历权限的父权限节点 |
|||
* @description abp框架定义所有子节点都在第三级里面.所以需要传递父节点来判断当前循环的权限的子权限节点 |
|||
*/ |
|||
private generateSubPermission(permissionTree: PermissionTree, permissions: Permission[], parentPermissions: Permission[]) { |
|||
permissions.forEach((permission) => { |
|||
const permissionTreeItem = new PermissionTree() |
|||
permissionTreeItem.id = permission.name |
|||
permissionTreeItem.label = permission.displayName |
|||
permissionTreeItem.disabled = this.readonly |
|||
this.permissionEditData.push(permission) |
|||
// 查询当前权限里面的子节点 |
|||
const subPermissions = parentPermissions.filter(p => p.parentName === permission.name) |
|||
// 生成下一级权限树 |
|||
if (subPermissions.length > 0) { |
|||
this.generateSubPermission(permissionTreeItem, subPermissions, permissions) |
|||
} else { // 如果存在下一级权限,那么在下一级循环里面添加选中,避免选中当前根节点 |
|||
if (permission.isGranted) { |
|||
this.permissionCheckedKeys.push(permissionTreeItem.id) |
|||
} |
|||
} |
|||
permissionTree.children.push(permissionTreeItem) |
|||
}) |
|||
} |
|||
|
|||
/** 权限树选择相应事件 */ |
|||
private handlePermissionChecked(data: any, treeCheckData: any) { |
|||
this.permissionEditData.forEach((permission: IPermission) => { |
|||
permission.isGranted = treeCheckData.checkedKeys.some((k: string) => k.indexOf(permission.name) !== -1) |
|||
}) |
|||
// 传递权限变更事件,事件参数为授权接口集合 |
|||
this.$emit('onPermissionChanged', this.permissionEditData) |
|||
} |
|||
|
|||
/** 节点展开事件 |
|||
* @description 监听节点展开完毕事件,刷新子节点样式 |
|||
*/ |
|||
private handleNodeExpand() { |
|||
this.$nextTick().then(() => { |
|||
this.changeTree() |
|||
}) |
|||
} |
|||
|
|||
/** 自定义权限树子节点渲染 */ |
|||
private renderContent(h: any, context: { node: any, data: PermissionTree}) { |
|||
if (this.horizontally) { |
|||
if (context.data.children.length > 0) { |
|||
return h( |
|||
'span', |
|||
{ class: 'el-tree-node__label' }, |
|||
[context.node.label] |
|||
) |
|||
} else { |
|||
return h( |
|||
'div', |
|||
{ class: 'horizontally' }, |
|||
[context.node.label]) |
|||
} |
|||
} |
|||
return h( |
|||
'span', |
|||
{ class: 'el-tree-node__label' }, |
|||
[context.node.label] |
|||
) |
|||
} |
|||
|
|||
/** 变更权限树样式 |
|||
* @description https://www.jianshu.com/p/f740e8c9fca6 |
|||
*/ |
|||
private changeTree() { |
|||
const classDomList = document.getElementsByClassName('horizontally') |
|||
for (let i = 0; i < classDomList.length; i++) { |
|||
const parentNode = classDomList[i].parentNode as any |
|||
parentNode.style.cssText = 'float: left' |
|||
parentNode.className = 'el-tree-node__content option-wrapper' |
|||
parentNode.parentNode.style.marginLeft = '70px' |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.option-wrapper { |
|||
padding: 0 !important; |
|||
} |
|||
</style> |
|||
@ -1,45 +0,0 @@ |
|||
<template> |
|||
<div class="role-reference-pane"> |
|||
<el-table |
|||
ref="roleTable" |
|||
v-loading="userLoading" |
|||
row-key="id" |
|||
:data="userList" |
|||
border |
|||
fit |
|||
highlight-current-row |
|||
max-height="250px" |
|||
@row-click="onRowClick" |
|||
/> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { dateFormat } from '@/utils' |
|||
import { Component, Vue } from 'vue-property-decorator' |
|||
import RoleAppService, { RoleGetPagedDto } from '@/api/roles' |
|||
|
|||
@Component({ |
|||
name: 'RoleReference', |
|||
filters: { |
|||
dateTimeFilter(datetime: string) { |
|||
const date = new Date(datetime) |
|||
return dateFormat(date, 'YYYY-mm-dd HH:MM') |
|||
} |
|||
} |
|||
}) |
|||
export default class extends Vue { |
|||
private roleQueryFilter = new RoleGetPagedDto() |
|||
|
|||
private hanldGetRoles() { |
|||
// TODO 待完成 |
|||
RoleAppService.getRoles(this.roleQueryFilter).then(res => { |
|||
console.log(res) |
|||
}) |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="stylus" scoped> |
|||
|
|||
</style> |
|||
@ -1,176 +0,0 @@ |
|||
<template> |
|||
<div class="user-reference-pane"> |
|||
<el-form> |
|||
<el-form-item> |
|||
<el-button |
|||
class="confirm" |
|||
type="primary" |
|||
style="width:100px" |
|||
> |
|||
{{ $t('global.confirm') }} |
|||
</el-button> |
|||
<el-button |
|||
class="cancel" |
|||
style="width:100px" |
|||
> |
|||
{{ $t('global.cancel') }} |
|||
</el-button> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-table |
|||
ref="userTable" |
|||
v-loading="userLoading" |
|||
row-key="id" |
|||
:data="userList" |
|||
border |
|||
fit |
|||
highlight-current-row |
|||
max-height="250px" |
|||
@row-click="onRowClick" |
|||
> |
|||
<el-table-column |
|||
type="selection" |
|||
width="50" |
|||
align="center" |
|||
/> |
|||
<el-table-column |
|||
:label="$t('users.userName')" |
|||
prop="userName" |
|||
sortable |
|||
width="110px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.userName }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('users.name')" |
|||
prop="name" |
|||
width="110px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.name }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('users.email')" |
|||
prop="email" |
|||
sortable |
|||
min-width="180" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.email }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('users.phoneNumber')" |
|||
prop="phoneNumber" |
|||
width="140px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.phoneNumber }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('users.lockoutEnd')" |
|||
prop="lockoutEnd" |
|||
sortable |
|||
width="140px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.lockoutEnd | dateTimeFilter }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('users.creationTime')" |
|||
prop="creationTime" |
|||
sortable |
|||
width="140px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.creationTime | dateTimeFilter }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<pagination |
|||
v-show="userCount>0" |
|||
:total="userCount" |
|||
:page.sync="userQueryFilter.skipCount" |
|||
:limit.sync="userQueryFilter.maxResultCount" |
|||
@pagination="handleGetUserList" |
|||
/> |
|||
</el-form-item> |
|||
</el-form> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { dateFormat } from '@/utils' |
|||
import { Component, Vue } from 'vue-property-decorator' |
|||
import Pagination from '@/components/Pagination/index.vue' |
|||
import UserAppService, { UsersGetPagedDto, UserDataDto } from '@/api/users' |
|||
|
|||
@Component({ |
|||
name: 'UserReference', |
|||
components: { |
|||
Pagination |
|||
}, |
|||
filters: { |
|||
dateTimeFilter(datetime: string) { |
|||
const date = new Date(datetime) |
|||
return dateFormat(date, 'YYYY-mm-dd HH:MM') |
|||
} |
|||
} |
|||
}) |
|||
export default class extends Vue { |
|||
private userCount = 0 |
|||
private userLoading = false |
|||
private userList = new Array<UserDataDto>() |
|||
private userQueryFilter = new UsersGetPagedDto() |
|||
|
|||
mounted() { |
|||
this.handleGetUserList() |
|||
// 滚动延迟加载 |
|||
// const userTable = this.$refs.userTable as any |
|||
// userTable.bodyWrapper.addEventListener('scroll', (res: any) => this.onTableScrollChanged(res), true) |
|||
} |
|||
|
|||
private handleGetUserList() { |
|||
this.userLoading = true |
|||
UserAppService.getUsers(this.userQueryFilter).then(res => { |
|||
this.userList = res.items |
|||
this.userCount = res.totalCount |
|||
this.userLoading = false |
|||
}) |
|||
} |
|||
|
|||
private onRowClick(row: any) { |
|||
const table = this.$refs.userTable as any |
|||
table.toggleRowSelection(row) |
|||
} |
|||
|
|||
private onTableScrollChanged(dom: any) { |
|||
console.log(dom) |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.user-reference-pane .user-table { |
|||
width: 100%; |
|||
cursor: pointer; |
|||
} |
|||
.confirm { |
|||
position: relative; |
|||
} |
|||
.cancel { |
|||
position: relative; |
|||
} |
|||
</style> |
|||
@ -1,304 +0,0 @@ |
|||
<template> |
|||
<el-dialog |
|||
v-el-draggable-dialog |
|||
width="800px" |
|||
:visible="showDialog" |
|||
:title="$t('identityServer.apiResourceSecret')" |
|||
custom-class="modal-form" |
|||
:show-close="false" |
|||
@close="onFormClosed" |
|||
> |
|||
<div class="app-container"> |
|||
<el-form |
|||
v-if="checkPermission(['IdentityServer.ApiResources.Secrets.Create'])" |
|||
ref="formApiSecret" |
|||
label-width="100px" |
|||
:model="apiSecret" |
|||
:rules="apiSecretRules" |
|||
> |
|||
<el-form-item |
|||
prop="type" |
|||
:label="$t('identityServer.secretType')" |
|||
> |
|||
<el-select |
|||
v-model="apiSecret.type" |
|||
class="full-select" |
|||
:placeholder="$t('pleaseSelectBy', {key: $t('identityServer.secretType')})" |
|||
> |
|||
<el-option |
|||
key="JWK" |
|||
label="JsonWebKey" |
|||
value="JWK" |
|||
/> |
|||
<el-option |
|||
key="SharedSecret" |
|||
label="SharedSecret" |
|||
value="SharedSecret" |
|||
/> |
|||
<el-option |
|||
key="X509Name" |
|||
label="X509CertificateName" |
|||
value="X509Name" |
|||
/> |
|||
<el-option |
|||
key="X509CertificateBase64" |
|||
label="X509CertificateBase64" |
|||
value="X509CertificateBase64" |
|||
/> |
|||
<el-option |
|||
key="X509Thumbprint" |
|||
label="X509CertificateThumbprint" |
|||
value="X509Thumbprint" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="hashType" |
|||
:label="$t('identityServer.secretHashType')" |
|||
> |
|||
<el-popover |
|||
ref="popHashType" |
|||
placement="top-start" |
|||
trigger="hover" |
|||
:content="$t('identityServer.hashOnlySharedSecret')" |
|||
/> |
|||
<el-select |
|||
v-model="apiSecret.hashType" |
|||
v-popover:popHashType |
|||
:disabled="apiSecret.type !== 'SharedSecret'" |
|||
class="full-select" |
|||
:placeholder="$t('pleaseSelectBy', {key: $t('identityServer.secretHashType')})" |
|||
> |
|||
<el-option |
|||
:key="0" |
|||
label="Sha256" |
|||
:value="0" |
|||
/> |
|||
<el-option |
|||
:key="1" |
|||
label="Sha512" |
|||
:value="1" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="value" |
|||
:label="$t('identityServer.secretValue')" |
|||
> |
|||
<el-input |
|||
v-model="apiSecret.value" |
|||
:placeholder="$t('pleaseInputBy', {key: $t('identityServer.secretValue')})" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="description" |
|||
:label="$t('identityServer.secretDescription')" |
|||
> |
|||
<el-input |
|||
v-model="apiSecret.description" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="expiration" |
|||
:label="$t('identityServer.expiration')" |
|||
> |
|||
<el-date-picker |
|||
v-model="apiSecret.expiration" |
|||
class="full-select" |
|||
type="datetime" |
|||
/> |
|||
</el-form-item> |
|||
|
|||
<el-form-item |
|||
style="text-align: center;" |
|||
label-width="0px" |
|||
> |
|||
<el-button |
|||
type="primary" |
|||
style="width:180px" |
|||
@click="onSaveApiSecret" |
|||
> |
|||
{{ $t('identityServer.createApiSecret') }} |
|||
</el-button> |
|||
</el-form-item> |
|||
<el-divider /> |
|||
</el-form> |
|||
</div> |
|||
|
|||
<el-table |
|||
row-key="value" |
|||
:data="apiSecrets" |
|||
border |
|||
fit |
|||
highlight-current-row |
|||
style="width: 100%;" |
|||
> |
|||
<el-table-column |
|||
:label="$t('identityServer.secretType')" |
|||
prop="type" |
|||
sortable |
|||
width="150px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.type }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('identityServer.secretValue')" |
|||
prop="value" |
|||
sortable |
|||
width="200px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.value }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('identityServer.secretDescription')" |
|||
prop="description" |
|||
width="170px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.description }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('identityServer.expiration')" |
|||
prop="expiration" |
|||
width="170px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.expiration | dateTimeFilter }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('operaActions')" |
|||
align="center" |
|||
width="150px" |
|||
fixed="right" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<el-button |
|||
:disabled="!checkPermission(['IdentityServer.ApiResources.Secrets.Delete'])" |
|||
size="mini" |
|||
type="primary" |
|||
@click="handleDeleteApiSecret(row.type, row.value)" |
|||
> |
|||
{{ $t('identityServer.deleteApiSecret') }} |
|||
</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import ApiResourceService, { ApiSecret, ApiSecretCreate } from '@/api/apiresources' |
|||
import { Component, Vue, Prop, Watch } from 'vue-property-decorator' |
|||
import { dateFormat } from '@/utils/index' |
|||
import { checkPermission } from '@/utils/permission' |
|||
|
|||
@Component({ |
|||
name: 'ApiSecretEditForm', |
|||
filters: { |
|||
dateTimeFilter(datetime: string) { |
|||
if (datetime) { |
|||
const date = new Date(datetime) |
|||
return dateFormat(date, 'YYYY-mm-dd HH:MM') |
|||
} |
|||
return '' |
|||
} |
|||
}, |
|||
methods: { |
|||
checkPermission |
|||
} |
|||
}) |
|||
export default class extends Vue { |
|||
@Prop({ default: false }) |
|||
private showDialog!: boolean |
|||
|
|||
@Prop({ default: '' }) |
|||
private apiResourceId!: string |
|||
|
|||
@Prop({ default: () => new Array<ApiSecret>() }) |
|||
private apiSecrets!: ApiSecret[] |
|||
|
|||
private apiSecretChanged: boolean |
|||
private apiSecret: ApiSecretCreate |
|||
private apiSecretRules = { |
|||
type: [ |
|||
{ required: true, message: this.l('pleaseSelectBy', { key: this.l('identityServer.secretType') }), trigger: 'change' } |
|||
], |
|||
value: [ |
|||
{ required: true, message: this.l('pleaseInputBy', { key: this.l('identityServer.secretValue') }), trigger: 'blur' } |
|||
] |
|||
} |
|||
|
|||
constructor() { |
|||
super() |
|||
this.apiSecretChanged = false |
|||
this.apiSecret = ApiSecretCreate.empty() |
|||
} |
|||
|
|||
@Watch('apiResourceId', { immediate: true }) |
|||
private onApiResourceIdChanged() { |
|||
this.apiSecret.apiResourceId = this.apiResourceId |
|||
} |
|||
|
|||
private handleDeleteApiSecret(type: string, value: string) { |
|||
this.$confirm(this.l('identityServer.deleteApiSecretByType', { type: value }), |
|||
this.l('identityServer.deleteApiSecret'), { |
|||
callback: (action) => { |
|||
if (action === 'confirm') { |
|||
ApiResourceService.deleteApiSecret(this.apiResourceId, type, value).then(() => { |
|||
const deleteSecretIndex = this.apiSecrets.findIndex(secret => secret.type === type) |
|||
this.apiSecrets.splice(deleteSecretIndex, 1) |
|||
this.$message.success(this.l('identityServer.deleteApiSecretSuccess', { type: value })) |
|||
this.$emit('apiSecretChanged') |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
} |
|||
|
|||
private onSaveApiSecret() { |
|||
const frmApiSecret = this.$refs.formApiSecret as any |
|||
frmApiSecret.validate((valid: boolean) => { |
|||
if (valid) { |
|||
this.apiSecret.apiResourceId = this.apiResourceId |
|||
ApiResourceService.addApiSecret(this.apiSecret).then(secret => { |
|||
this.apiSecrets.push(secret) |
|||
const successMessage = this.l('identityServer.createApiSecretSuccess', { type: this.apiSecret.type }) |
|||
this.$message.success(successMessage) |
|||
this.$emit('apiSecretChanged') |
|||
this.onFormClosed() |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
|
|||
private onFormClosed() { |
|||
this.resetFields() |
|||
this.$emit('closed') |
|||
} |
|||
|
|||
private resetFields() { |
|||
const frmApiSecret = this.$refs.formApiSecret as any |
|||
frmApiSecret.resetFields() |
|||
} |
|||
|
|||
private l(name: string, values?: any[] | { [key: string]: any }) { |
|||
return this.$t(name, values).toString() |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.full-select { |
|||
width: 100%; |
|||
} |
|||
</style> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue