- @if (Model.ClientInfo.ClientLogoUrl != null)
+ @if (Model.Consent.ClientLogoUrl != null)
{
-
+
}
- @Model.ClientInfo.ClientName
+ @Model.Consent.ClientName
is requesting your permission
@@ -25,29 +25,30 @@
Uncheck the permissions you do not wish to grant.
- @if (!Model.ConsentInput.IdentityScopes.IsNullOrEmpty())
+ @if (!Model.Consent.IdentityScopes.IsNullOrEmpty())
{
Personal Information
}
- @if (!Model.ConsentInput.ApiScopes.IsNullOrEmpty())
+ @if (!Model.Consent.ApiScopes.IsNullOrEmpty())
{
Application Access
}
- @if (Model.ClientInfo.AllowRememberConsent)
+
+
+ @if (Model.Consent.AllowRememberConsent)
{
-
-
+
+
Remember My Decision
@@ -98,10 +112,10 @@
@@ -110,4 +124,4 @@
-
\ No newline at end of file
+
diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Consent.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Consent.cshtml.cs
index a0f0543765..64173917e3 100644
--- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Consent.cshtml.cs
+++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Consent.cshtml.cs
@@ -3,12 +3,13 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
+using IdentityServer4.Extensions;
using IdentityServer4.Models;
using IdentityServer4.Services;
using IdentityServer4.Stores;
+using IdentityServer4.Validation;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
-using Volo.Abp.UI;
namespace Volo.Abp.Account.Web.Pages
{
@@ -24,9 +25,7 @@ namespace Volo.Abp.Account.Web.Pages
public string ReturnUrlHash { get; set; }
[BindProperty]
- public ConsentModel.ConsentInputModel ConsentInput { get; set; }
-
- public ClientInfoModel ClientInfo { get; set; }
+ public ConsentViewModel Consent { get; set; }
private readonly IIdentityServerInteractionService _interaction;
private readonly IClientStore _clientStore;
@@ -44,37 +43,7 @@ namespace Volo.Abp.Account.Web.Pages
public virtual async Task
OnGet()
{
- var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl);
- if (request == null)
- {
- throw new ApplicationException($"No consent request matching request: {ReturnUrl}");
- }
-
- var client = await _clientStore.FindEnabledClientByIdAsync(request.ClientId);
- if (client == null)
- {
- throw new ApplicationException($"Invalid client id: {request.ClientId}");
- }
-
- var resources = await _resourceStore.FindEnabledResourcesByScopeAsync(request.ScopesRequested);
- if (resources == null || (!resources.IdentityResources.Any() && !resources.ApiResources.Any()))
- {
- throw new ApplicationException($"No scopes matching: {request.ScopesRequested.Aggregate((x, y) => x + ", " + y)}");
- }
-
- ClientInfo = new ClientInfoModel(client);
- ConsentInput = new ConsentInputModel
- {
- RememberConsent = true,
- IdentityScopes = resources.IdentityResources.Select(x => CreateScopeViewModel(x, true)).ToList(),
- ApiScopes = resources.ApiResources.SelectMany(x => x.Scopes).Select(x => CreateScopeViewModel(x, true)).ToList()
- };
-
- if (resources.OfflineAccess)
- {
- ConsentInput.ApiScopes.Add(GetOfflineAccessScope(true));
- }
-
+ Consent = await BuildViewModelAsync(ReturnUrl);
return Page();
}
@@ -96,53 +65,137 @@ namespace Volo.Abp.Account.Web.Pages
throw new ApplicationException("Unknown Error!");
}
- protected virtual async Task ProcessConsentAsync()
+ protected virtual async Task ProcessConsentAsync()
{
- var result = new ConsentModel.ProcessConsentResult();
+ var result = new ProcessConsentResult();
+
+ // validate return url is still valid
+ var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl);
+ if (request == null)
+ {
+ return result;
+ }
- ConsentResponse grantedConsent;
+ ConsentResponse grantedConsent = null;
- if (ConsentInput.UserDecision == "no")
+ // user clicked 'no' - send back the standard 'access_denied' response
+ if (Consent?.Button == "no")
{
- grantedConsent = ConsentResponse.Denied;
+ grantedConsent = new ConsentResponse { Error = AuthorizationError.AccessDenied };
+ // emit event
+ //await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues));
}
- else
+ // user clicked 'yes' - validate the data
+ else if (Consent?.Button == "yes")
{
- if (!ConsentInput.IdentityScopes.IsNullOrEmpty() || !ConsentInput.ApiScopes.IsNullOrEmpty())
+ // if the user consented to some scope, build the response model
+ if (!Consent.ScopesConsented.IsNullOrEmpty())
{
+ var scopes = Consent.ScopesConsented;
+ if (ConsentOptions.EnableOfflineAccess == false)
+ {
+ scopes = scopes.Where(x => x != IdentityServer4.IdentityServerConstants.StandardScopes.OfflineAccess);
+ }
+
grantedConsent = new ConsentResponse
{
- RememberConsent = ConsentInput.RememberConsent,
- ScopesConsented = ConsentInput.GetAllowedScopeNames()
+ RememberConsent = Consent.RememberConsent,
+ ScopesValuesConsented = scopes.ToArray(),
+ Description = Consent.Description
};
+
+ // emit event
+ //await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent));
}
else
{
- throw new UserFriendlyException("You must pick at least one permission"); //TODO: How to handle this
+ //throw new UserFriendlyException("You must pick at least one permission"); //TODO: How to handle this
+ result.ValidationError = ConsentOptions.MustChooseOneErrorMessage;
}
}
+ else
+ {
+ result.ValidationError = ConsentOptions.InvalidSelectionErrorMessage;
+ }
if (grantedConsent != null)
{
- var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl);
- if (request == null)
- {
- return result;
- }
-
+ // communicate outcome of consent back to identityserver
await _interaction.GrantConsentAsync(request, grantedConsent);
- result.RedirectUri = ReturnUrl; //TODO: ReturnUrlHash?
+ // indicate that's it ok to redirect back to authorization endpoint
+ result.RedirectUri = Consent.ReturnUrl; //TODO: ReturnUrlHash?
+ result.Client = request.Client;
+ }
+ else
+ {
+ // we need to redisplay the consent UI
+
+ result.ViewModel = await BuildViewModelAsync(ReturnUrl, Consent);
}
return result;
}
- protected virtual ConsentModel.ScopeViewModel CreateScopeViewModel(IdentityResource identity, bool check)
+ private async Task BuildViewModelAsync(string returnUrl, ConsentInputModel model = null)
+ {
+ var request = await _interaction.GetAuthorizationContextAsync(returnUrl);
+ if (request != null)
+ {
+ return CreateConsentViewModel(model, returnUrl, request);
+ }
+
+ throw new ApplicationException($"No consent request matching request: {returnUrl}");
+ }
+
+ private ConsentViewModel CreateConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request)
+ {
+ var consentViewModel = new ConsentViewModel
+ {
+ RememberConsent = model?.RememberConsent ?? true,
+ ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty(),
+ Description = model?.Description,
+
+ ReturnUrl = returnUrl,
+
+ ClientName = request.Client.ClientName ?? request.Client.ClientId,
+ ClientUrl = request.Client.ClientUri,
+ ClientLogoUrl = request.Client.LogoUri,
+ AllowRememberConsent = request.Client.AllowRememberConsent
+ };
+
+ consentViewModel.IdentityScopes = request.ValidatedResources.Resources.IdentityResources.Select(x =>
+ CreateScopeViewModel(x, consentViewModel.ScopesConsented.Contains(x.Name) || model == null))
+ .ToArray();
+
+ var apiScopes = new List();
+ foreach(var parsedScope in request.ValidatedResources.ParsedScopes)
+ {
+ var apiScope = request.ValidatedResources.Resources.FindApiScope(parsedScope.ParsedName);
+ if (apiScope != null)
+ {
+ var scopeVm = CreateScopeViewModel(parsedScope, apiScope,
+ consentViewModel.ScopesConsented.Contains(parsedScope.RawValue) || model == null);
+ apiScopes.Add(scopeVm);
+ }
+ }
+
+ if (ConsentOptions.EnableOfflineAccess && request.ValidatedResources.Resources.OfflineAccess)
+ {
+ apiScopes.Add(GetOfflineAccessScope(consentViewModel.ScopesConsented.Contains(IdentityServer4.IdentityServerConstants.StandardScopes.OfflineAccess) || model == null));
+ }
+
+ consentViewModel.ApiScopes = apiScopes;
+
+ return consentViewModel;
+ }
+
+
+ protected virtual ScopeViewModel CreateScopeViewModel(IdentityResource identity, bool check)
{
- return new ConsentModel.ScopeViewModel
+ return new ScopeViewModel
{
- Name = identity.Name,
+ Value = identity.Name,
DisplayName = identity.DisplayName,
Description = identity.Description,
Emphasize = identity.Emphasize,
@@ -151,24 +204,30 @@ namespace Volo.Abp.Account.Web.Pages
};
}
- protected virtual ConsentModel.ScopeViewModel CreateScopeViewModel(Scope scope, bool check)
+ protected virtual ScopeViewModel CreateScopeViewModel(ParsedScopeValue parsedScopeValue, ApiScope apiScope, bool check)
{
- return new ConsentModel.ScopeViewModel
- {
- Name = scope.Name,
- DisplayName = scope.DisplayName,
- Description = scope.Description,
- Emphasize = scope.Emphasize,
- Required = scope.Required,
- Checked = check || scope.Required
+ var displayName = apiScope.DisplayName ?? apiScope.Name;
+ if (!string.IsNullOrWhiteSpace(parsedScopeValue.ParsedParameter))
+ {
+ displayName += ":" + parsedScopeValue.ParsedParameter;
+ }
+
+ return new ScopeViewModel
+ {
+ Value = parsedScopeValue.RawValue,
+ DisplayName = displayName,
+ Description = apiScope.Description,
+ Emphasize = apiScope.Emphasize,
+ Required = apiScope.Required,
+ Checked = check || apiScope.Required
};
}
- protected virtual ConsentModel.ScopeViewModel GetOfflineAccessScope(bool check)
+ protected virtual ScopeViewModel GetOfflineAccessScope(bool check)
{
- return new ConsentModel.ScopeViewModel
+ return new ScopeViewModel
{
- Name = IdentityServer4.IdentityServerConstants.StandardScopes.OfflineAccess,
+ Value = IdentityServer4.IdentityServerConstants.StandardScopes.OfflineAccess,
DisplayName = "Offline Access", //TODO: Localize
Description = "Access to your applications and resources, even when you are offline",
Emphasize = true,
@@ -178,28 +237,37 @@ namespace Volo.Abp.Account.Web.Pages
public class ConsentInputModel
{
- public List IdentityScopes { get; set; }
-
- public List ApiScopes { get; set; }
-
[Required]
- public string UserDecision { get; set; }
+ public string Button { get; set; }
+ public IEnumerable ScopesConsented { get; set; }
public bool RememberConsent { get; set; }
- public List GetAllowedScopeNames()
- {
- var identityScopes = IdentityScopes ?? new List();
- var apiScopes = ApiScopes ?? new List();
- return identityScopes.Union(apiScopes).Where(s => s.Checked).Select(s => s.Name).ToList();
- }
+ public string ReturnUrl { get; set; }
+
+ public string Description { get; set; }
+ }
+
+
+ public class ConsentViewModel : ConsentInputModel
+ {
+ public string ClientName { get; set; }
+ public string ClientUrl { get; set; }
+
+ public string ClientLogoUrl { get; set; }
+
+ public bool AllowRememberConsent { get; set; }
+
+ public IEnumerable IdentityScopes { get; set; }
+
+ public IEnumerable ApiScopes { get; set; }
}
public class ScopeViewModel
{
[Required]
[HiddenInput]
- public string Name { get; set; }
+ public string Value { get; set; }
public bool Checked { get; set; }
@@ -216,29 +284,13 @@ namespace Volo.Abp.Account.Web.Pages
{
public bool IsRedirect => RedirectUri != null;
public string RedirectUri { get; set; }
+ public Client Client { get; set; }
+
+ public bool ShowView => ViewModel != null;
+ public ConsentViewModel ViewModel { get; set; }
public bool HasValidationError => ValidationError != null;
public string ValidationError { get; set; }
}
-
- public class ClientInfoModel
- {
- public string ClientName { get; set; }
-
- public string ClientUrl { get; set; }
-
- public string ClientLogoUrl { get; set; }
-
- public bool AllowRememberConsent { get; set; }
-
- public ClientInfoModel(Client client)
- {
- //TODO: Automap
- ClientName = client.ClientId;
- ClientUrl = client.ClientUri;
- ClientLogoUrl = client.LogoUri;
- AllowRememberConsent = client.AllowRememberConsent;
- }
- }
}
-}
\ No newline at end of file
+}
diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs
index a196fd7534..fcbb937bc4 100644
--- a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs
+++ b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs
@@ -53,7 +53,7 @@ namespace Volo.Abp.IdentityServer.Clients
//Assert
apiResources.ShouldNotBe(null);
- apiResources[0].Scopes.Count.ShouldBe(2);
+ apiResources[0].Scopes.Count.ShouldBe(3);
}
[Fact]
From 6f6d238bb5ff1d10b6ab1d8556d2ff5d2141cb62 Mon Sep 17 00:00:00 2001
From: maliming <6908465+maliming@users.noreply.github.com>
Date: Fri, 3 Jul 2020 12:00:16 +0800
Subject: [PATCH 004/935] Add FindByNameAsync to IApiResourceRepository.
---
.../ApiResources/IApiResourceRepository.cs | 6 ++++++
.../IdentityServer/ApiResources/ApiResourceRepository.cs | 9 +++++++++
.../IdentityServer/MongoDB/MongoApiResourceRepository.cs | 7 +++++++
3 files changed, 22 insertions(+)
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs
index af1dcd6e36..8b9057d129 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs
@@ -8,6 +8,12 @@ namespace Volo.Abp.IdentityServer.ApiResources
{
public interface IApiResourceRepository : IBasicRepository
{
+ Task FindByNameAsync(
+ string apiResourceName,
+ bool includeDetails = true,
+ CancellationToken cancellationToken = default
+ );
+
Task> FindByNameAsync(
string[] apiResourceNames,
bool includeDetails = true,
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs
index 4d0baf7702..1949238a3b 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs
@@ -19,6 +19,15 @@ namespace Volo.Abp.IdentityServer.ApiResources
}
+ public async Task FindByNameAsync(string apiResourceName, bool includeDetails = true, CancellationToken cancellationToken = default)
+ {
+ var query = from apiResource in DbSet.IncludeDetails(includeDetails)
+ where apiResource.Name == apiResourceName
+ select apiResource;
+
+ return await query.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
+ }
+
public async Task> FindByNameAsync(string[] apiResourceNames, bool includeDetails = true,
CancellationToken cancellationToken = default)
{
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs
index 20d55b3d0e..44375fce93 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs
@@ -18,6 +18,13 @@ namespace Volo.Abp.IdentityServer.MongoDB
{
}
+ public async Task FindByNameAsync(string apiResourceName, bool includeDetails = true, CancellationToken cancellationToken = default)
+ {
+ return await GetMongoQueryable()
+ .Where(ar => ar.Name == apiResourceName)
+ .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
+ }
+
public async Task> FindByNameAsync(string[] apiResourceNames, bool includeDetails = true,
CancellationToken cancellationToken = default)
{
From a40b35a089532e6d47ff1340ad13cf20b81bfa9e Mon Sep 17 00:00:00 2001
From: maliming <6908465+maliming@users.noreply.github.com>
Date: Fri, 3 Jul 2020 17:18:32 +0800
Subject: [PATCH 005/935] Use constants in EF entity configuration.
---
.../ApiResources/ApiResourceScopeConsts.cs | 7 ++
.../ApiResourceSecretConsts.cs} | 12 +--
.../ApiResources/ApiScopeConsts.cs | 7 --
.../ApiScopes/ApiResourceConsts.cs | 9 ++
.../ApiScopes/ApiScopeClaimConsts.cs | 7 ++
.../ApiScopes/ApiScopePropertyConsts.cs | 9 ++
.../Devices/DeviceFlowCodesConsts.cs | 12 +++
.../IdentityResourcePropertyConsts.cs | 9 ++
.../{ApiResources => ApiScopes}/ApiScope.cs | 2 +-
.../ApiScopeClaim.cs | 2 +-
.../ApiScopeProperty.cs | 2 +-
.../IApiScopeeRepository.cs | 2 +-
.../IdentityServerAutoMapperProfile.cs | 1 +
.../Volo/Abp/IdentityServer/ResourceStore.cs | 5 +-
.../ApiResources/ApiResourceRepository.cs | 12 ++-
.../ApiResources/ApiScopeRepository.cs | 1 +
.../IIdentityServerDbContext.cs | 28 +++++-
.../IdentityServerDbContext.cs | 28 +++++-
...yServerDbContextModelCreatingExtensions.cs | 90 +++++++++++++------
.../AbpIdentityServerMongoDbContext.cs | 3 +
20 files changed, 193 insertions(+), 55 deletions(-)
create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceScopeConsts.cs
rename modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/{SecretConsts.cs => ApiResources/ApiResourceSecretConsts.cs} (84%)
delete mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiScopeConsts.cs
create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiResourceConsts.cs
create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaimConsts.cs
create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopePropertyConsts.cs
create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesConsts.cs
create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourcePropertyConsts.cs
rename modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/{ApiResources => ApiScopes}/ApiScope.cs (97%)
rename modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/{ApiResources => ApiScopes}/ApiScopeClaim.cs (94%)
rename modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/{ApiResources => ApiScopes}/ApiScopeProperty.cs (95%)
rename modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/{ApiResources => ApiScopes}/IApiScopeeRepository.cs (89%)
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceScopeConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceScopeConsts.cs
new file mode 100644
index 0000000000..8b0d8f4769
--- /dev/null
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceScopeConsts.cs
@@ -0,0 +1,7 @@
+namespace Volo.Abp.IdentityServer.ApiResources
+{
+ public class ApiResourceScopeConsts
+ {
+ public const int ScopeMaxLength = 200;
+ }
+}
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/SecretConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceSecretConsts.cs
similarity index 84%
rename from modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/SecretConsts.cs
rename to modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceSecretConsts.cs
index 156088a97b..261f48ac2e 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/SecretConsts.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceSecretConsts.cs
@@ -1,22 +1,22 @@
-namespace Volo.Abp.IdentityServer
+namespace Volo.Abp.IdentityServer.ApiResources
{
- public class SecretConsts
+ public class ApiResourceSecretConsts
{
///
/// Default value: 250
///
public static int TypeMaxLength { get; set; } = 250;
-
+
///
/// Default value: 4000
///
public static int ValueMaxLength { get; set; } = 4000;
-
+
public static int ValueMaxLengthValue { get; set; } = ValueMaxLength;
-
+
///
/// Default value: 2000
///
public static int DescriptionMaxLength { get; set; } = 2000;
}
-}
\ No newline at end of file
+}
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiScopeConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiScopeConsts.cs
deleted file mode 100644
index b61aa097f4..0000000000
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiScopeConsts.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Volo.Abp.IdentityServer.ApiResources
-{
- public class ApiScopeConsts
- {
- public const int NameMaxLength = 200;
- }
-}
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiResourceConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiResourceConsts.cs
new file mode 100644
index 0000000000..ab268690be
--- /dev/null
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiResourceConsts.cs
@@ -0,0 +1,9 @@
+namespace Volo.Abp.IdentityServer.ApiScopes
+{
+ public class ApiScopeConsts
+ {
+ public const int NameMaxLength = 200;
+ public const int DisplayNameMaxLength = 200;
+ public const int DescriptionMaxLength = 1000;
+ }
+}
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaimConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaimConsts.cs
new file mode 100644
index 0000000000..f3175e8774
--- /dev/null
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaimConsts.cs
@@ -0,0 +1,7 @@
+namespace Volo.Abp.IdentityServer.ApiScopes
+{
+ public class ApiScopeClaimConsts
+ {
+ public const int NameMaxLength = 200;
+ }
+}
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopePropertyConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopePropertyConsts.cs
new file mode 100644
index 0000000000..5450e67030
--- /dev/null
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopePropertyConsts.cs
@@ -0,0 +1,9 @@
+namespace Volo.Abp.IdentityServer.ApiScopes
+{
+ public class ApiScopePropertyConsts
+ {
+ public const int KeyMaxLength = 250;
+ public const int ValueMaxLength = 2000;
+ public static int ValueMaxLengthValue { get; set; } = ValueMaxLength;
+ }
+}
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesConsts.cs
new file mode 100644
index 0000000000..b0c87fe89d
--- /dev/null
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesConsts.cs
@@ -0,0 +1,12 @@
+namespace Volo.Abp.IdentityServer.Devices
+{
+ public class DeviceFlowCodesConsts
+ {
+ public const int DeviceCodeMaxLength = 200;
+ public const int UserCodeMaxLength = 200;
+ public const int SubjectIdMaxLength = 200;
+ public const int ClientIdMaxLength = 200;
+ public const int DataMaxLength = 50000;
+ public static int DataMaxLengthValue { get; set; } = DataMaxLength;
+ }
+}
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourcePropertyConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourcePropertyConsts.cs
new file mode 100644
index 0000000000..2c9ccbb0c4
--- /dev/null
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourcePropertyConsts.cs
@@ -0,0 +1,9 @@
+namespace Volo.Abp.IdentityServer.IdentityResources
+{
+ public class IdentityResourcePropertyConsts
+ {
+ public const int KeyMaxLength = 250;
+ public const int ValueMaxLength = 2000;
+ public static int ValueMaxLengthValue { get; set; } = ValueMaxLength;
+ }
+}
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScope.cs
similarity index 97%
rename from modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs
rename to modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScope.cs
index 8e8605afa1..d35294c27f 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScope.cs
@@ -4,7 +4,7 @@ using System.Linq;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities.Auditing;
-namespace Volo.Abp.IdentityServer.ApiResources
+namespace Volo.Abp.IdentityServer.ApiScopes
{
public class ApiScope : FullAuditedAggregateRoot
{
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaim.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaim.cs
similarity index 94%
rename from modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaim.cs
rename to modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaim.cs
index e4444cbc8c..0bb6704a22 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaim.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaim.cs
@@ -1,7 +1,7 @@
using System;
using JetBrains.Annotations;
-namespace Volo.Abp.IdentityServer.ApiResources
+namespace Volo.Abp.IdentityServer.ApiScopes
{
public class ApiScopeClaim : UserClaim
{
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeProperty.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScopeProperty.cs
similarity index 95%
rename from modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeProperty.cs
rename to modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScopeProperty.cs
index 38f34567a8..b6e5d7fbe8 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeProperty.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScopeProperty.cs
@@ -2,7 +2,7 @@
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
-namespace Volo.Abp.IdentityServer.ApiResources
+namespace Volo.Abp.IdentityServer.ApiScopes
{
public class ApiScopeProperty : Entity
{
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiScopeeRepository.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/IApiScopeeRepository.cs
similarity index 89%
rename from modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiScopeeRepository.cs
rename to modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/IApiScopeeRepository.cs
index 184b8d1b67..1cbc48499e 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiScopeeRepository.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/IApiScopeeRepository.cs
@@ -3,7 +3,7 @@ using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
-namespace Volo.Abp.IdentityServer.ApiResources
+namespace Volo.Abp.IdentityServer.ApiScopes
{
public interface IApiScopeRepository : IBasicRepository
{
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs
index 17aae1b084..99d24e617d 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs
@@ -2,6 +2,7 @@
using System.Security.Claims;
using AutoMapper;
using Volo.Abp.IdentityServer.ApiResources;
+using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ResourceStore.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ResourceStore.cs
index 975fc7f801..5afaaf4400 100644
--- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ResourceStore.cs
+++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ResourceStore.cs
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
using IdentityServer4.Models;
using IdentityServer4.Stores;
using Volo.Abp.IdentityServer.ApiResources;
+using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.ObjectMapping;
@@ -43,7 +44,7 @@ namespace Volo.Abp.IdentityServer
public virtual async Task> FindApiScopesByNameAsync(IEnumerable scopeNames)
{
var scopes = await ApiScopeRepository.GetListByNameAsync(scopeNames.ToArray(), includeDetails: true);
- return ObjectMapper.Map, List>(scopes);
+ return ObjectMapper.Map, List>(scopes);
}
///
@@ -76,7 +77,7 @@ namespace Volo.Abp.IdentityServer
return new Resources(
ObjectMapper.Map