Browse Source

Merge branch 'master' of https://github.com/volosoft/abp

pull/1070/head
Halil ibrahim Kalkan 8 years ago
parent
commit
ae152d5a80
  1. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperLocalizer.cs
  2. 40
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs
  3. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceClaim.cs
  4. 18
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs
  5. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaim.cs
  6. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecret.cs
  7. 105
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs
  8. 17
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientClaim.cs
  9. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientCorsOrigin.cs
  10. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientGrantType.cs
  11. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientIdPRestriction.cs
  12. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUri.cs
  13. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientProperty.cs
  14. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientRedirectUri.cs
  15. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScope.cs
  16. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityClaim.cs
  17. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResource.cs
  18. 69
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs
  19. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperLocalizer.cs

@ -20,14 +20,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers
public string GetLocalizedText(string text, ModelExplorer explorer)
{
var localizer = GetLocalizer(explorer);
var localizer = GetStringLocalizer(explorer);
return localizer == null ? text : localizer[text].Value;
}
public IStringLocalizer GetLocalizer(ModelExplorer explorer)
{
return GetLocalizer(explorer);
return GetStringLocalizer(explorer);
}
private IStringLocalizer GetStringLocalizer(ModelExplorer explorer)

40
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using IdentityServer4;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
@ -57,16 +58,27 @@ namespace Volo.Abp.IdentityServer.ApiResources
Secrets.Add(new ApiSecret(Id, value, expiration, type, description));
}
public virtual void AddScope(
public virtual void RemoveSecret([NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
{
Secrets.RemoveAll(s => s.Value == value && s.Type == type);
}
public virtual ApiSecret FindSecret([NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
{
return Secrets.FirstOrDefault(s => s.Type == type && s.Value == value);
}
public virtual ApiScope AddScope(
[NotNull] string name,
string displayName = null,
string description = null,
bool required = false,
bool emphasize = false,
bool showInDiscoveryDocument = true,
ApiScopeClaim[] userClaims = null)
bool showInDiscoveryDocument = true)
{
Scopes.Add(new ApiScope(Id, name, displayName, description, required, emphasize, showInDiscoveryDocument));
var scope = new ApiScope(Id, name, displayName, description, required, emphasize, showInDiscoveryDocument);
Scopes.Add(scope);
return scope;
}
public virtual void AddUserClaim([NotNull] string type)
@ -79,6 +91,16 @@ namespace Volo.Abp.IdentityServer.ApiResources
UserClaims.Clear();
}
public virtual void RemoveClaim(string type)
{
UserClaims.RemoveAll(c => c.Type == type);
}
public virtual ApiResourceClaim FindClaim(string type)
{
return UserClaims.FirstOrDefault(c => c.Type == type);
}
public virtual void RemoveAllSecrets()
{
Secrets.Clear();
@ -92,5 +114,15 @@ namespace Volo.Abp.IdentityServer.ApiResources
}
Scopes.Clear();
}
public virtual void RemoveScope(string name)
{
Scopes.RemoveAll(r => r.Name == name);
}
public virtual ApiScope FindScope(string name)
{
return Scopes.FirstOrDefault(r => r.Name == name);
}
}
}

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceClaim.cs

@ -9,7 +9,12 @@ namespace Volo.Abp.IdentityServer.ApiResources
protected ApiResourceClaim()
{
}
public virtual bool Equals(Guid apiResourceId, [NotNull] string type)
{
return ApiResourceId == apiResourceId && Type == type;
}
protected internal ApiResourceClaim(Guid apiResourceId, [NotNull] string type)

18
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
@ -26,7 +27,12 @@ namespace Volo.Abp.IdentityServer.ApiResources
protected ApiScope()
{
}
public virtual bool Equals(Guid apiResourceId, [NotNull] string name)
{
return ApiResourceId == apiResourceId && Name == name;
}
protected internal ApiScope(
@ -61,6 +67,16 @@ namespace Volo.Abp.IdentityServer.ApiResources
UserClaims.Clear();
}
public virtual void RemoveClaim(string name, string type)
{
UserClaims.RemoveAll(r => r.Name == name && r.Type == type);
}
public virtual ApiScopeClaim FindClaim(string name, string type)
{
return UserClaims.FirstOrDefault(r => r.Name == name && r.Type == type);
}
public override object[] GetKeys()
{
return new object[] { ApiResourceId, Name };

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaim.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.ApiResources
}
public virtual bool Equals(Guid apiResourceId, [NotNull] string name, [NotNull] string type)
{
return ApiResourceId == apiResourceId && Name == name && Type == type;
}
protected internal ApiScopeClaim(Guid apiResourceId, [NotNull] string name, [NotNull] string type)
: base(type)
{

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecret.cs

@ -10,7 +10,12 @@ namespace Volo.Abp.IdentityServer.ApiResources
protected ApiSecret()
{
}
public virtual bool Equals(Guid apiResourceId, [NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
{
return ApiResourceId == apiResourceId && Value == value && Type == type;
}
protected internal ApiSecret(

105
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs

@ -144,18 +144,19 @@ namespace Volo.Abp.IdentityServer.Clients
AllowedGrantTypes.Add(new ClientGrantType(Id, grantType));
}
public virtual void AddGrantTypes(IEnumerable<string> grantTypes)
public virtual void RemoveAllAllowedGrantTypes()
{
AllowedGrantTypes.AddRange(
grantTypes.Select(
grantType => new ClientGrantType(Id, grantType)
)
);
AllowedGrantTypes.Clear();
}
public virtual void RemoveAllAllowedGrantTypes()
public virtual void RemoveGrantType(string grantType)
{
AllowedGrantTypes.Clear();
AllowedGrantTypes.RemoveAll(r => r.GrantType == grantType);
}
public virtual ClientGrantType FindGrantType(string grantType)
{
return AllowedGrantTypes.FirstOrDefault(r => r.GrantType == grantType);
}
public virtual void AddSecret([NotNull] string value, DateTime? expiration = null, string type = IdentityServerConstants.SecretTypes.SharedSecret, string description = null)
@ -183,6 +184,16 @@ namespace Volo.Abp.IdentityServer.Clients
AllowedScopes.Clear();
}
public virtual void RemoveScope(string scope)
{
AllowedScopes.RemoveAll(r => r.Scope == scope);
}
public virtual ClientScope FindScope(string scope)
{
return AllowedScopes.FirstOrDefault(r => r.Scope == scope);
}
public virtual void AddCorsOrigin([NotNull] string origin)
{
AllowedCorsOrigins.Add(new ClientCorsOrigin(Id, origin));
@ -198,29 +209,49 @@ namespace Volo.Abp.IdentityServer.Clients
PostLogoutRedirectUris.Add(new ClientPostLogoutRedirectUri(Id, postLogoutRedirectUri));
}
public virtual void RemoveAllCorsOrigin()
public virtual void RemoveAllCorsOrigins()
{
AllowedCorsOrigins.Clear();
}
public virtual void RemoveAllRedirectUri()
public virtual void RemoveCorsOrigin(string uri)
{
AllowedCorsOrigins.RemoveAll(c => c.Origin == uri);
}
public virtual void RemoveAllRedirectUris()
{
RedirectUris.Clear();
}
public virtual void RemoveAllPostLogoutRedirectUri()
public virtual void RemoveRedirectUri(string uri)
{
RedirectUris.RemoveAll(r => r.RedirectUri == uri);
}
public virtual void RemoveAllPostLogoutRedirectUris()
{
PostLogoutRedirectUris.Clear();
}
public virtual void AddIdentityProviderRestriction([NotNull] string provider)
public virtual void RemovePostLogoutRedirectUri(string uri)
{
IdentityProviderRestrictions.Add(new ClientIdPRestriction(Id, provider));
PostLogoutRedirectUris.RemoveAll(p => p.PostLogoutRedirectUri == uri);
}
public virtual void RemoveAllIdentityProviderRestriction()
public virtual ClientCorsOrigin FindCorsOrigin(string uri)
{
IdentityProviderRestrictions.Clear();
return AllowedCorsOrigins.FirstOrDefault(c => c.Origin == uri);
}
public virtual ClientRedirectUri FindRedirectUri(string uri)
{
return RedirectUris.FirstOrDefault(r => r.RedirectUri == uri);
}
public virtual ClientPostLogoutRedirectUri FindPostLogoutRedirectUri(string uri)
{
return PostLogoutRedirectUris.FirstOrDefault(p => p.PostLogoutRedirectUri == uri);
}
public virtual void AddProperty([NotNull] string key, [NotNull] string value)
@ -233,14 +264,54 @@ namespace Volo.Abp.IdentityServer.Clients
Properties.Clear();
}
public virtual void AddClaim(IGuidGenerator guidGenerator, [NotNull] string type, string value)
public virtual void RemoveProperty(string key, string value)
{
Claims.Add(new ClientClaim(guidGenerator.Create(), Id, type, value));
Properties.RemoveAll(c => c.Value == value && c.Key == key);
}
public virtual ClientProperty FindProperty(string key, string value)
{
return Properties.FirstOrDefault(c => c.Key == key && c.Value == value);
}
public virtual void AddClaim([NotNull] string value, string type)
{
Claims.Add(new ClientClaim(Id, type, value));
}
public virtual void RemoveAllClaims()
{
Claims.Clear();
}
public virtual void RemoveClaim(string value, string type)
{
Claims.RemoveAll(c => c.Value == value && c.Type == type);
}
public virtual ClientClaim FindClaim(string value, string type)
{
return Claims.FirstOrDefault(c => c.Type == type && c.Value == value);
}
public virtual void AddIdentityProviderRestriction([NotNull] string provider)
{
IdentityProviderRestrictions.Add(new ClientIdPRestriction(Id, provider));
}
public virtual void RemoveAllIdentityProviderRestrictions()
{
IdentityProviderRestrictions.Clear();
}
public virtual void RemoveIdentityProviderRestriction(string provider)
{
IdentityProviderRestrictions.RemoveAll(r => r.Provider == provider);
}
public virtual ClientIdPRestriction FindIdentityProviderRestriction(string provider)
{
return IdentityProviderRestrictions.FirstOrDefault(r => r.Provider == provider);
}
}
}

17
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientClaim.cs

@ -4,7 +4,7 @@ using Volo.Abp.Domain.Entities;
namespace Volo.Abp.IdentityServer.Clients
{
public class ClientClaim : Entity<Guid>
public class ClientClaim : Entity
{
public virtual Guid ClientId { get; set; }
@ -14,17 +14,26 @@ namespace Volo.Abp.IdentityServer.Clients
protected ClientClaim()
{
}
public virtual bool Equals(Guid clientId, string value, string type)
{
return ClientId == clientId && Type == type && Value == value;
}
protected internal ClientClaim(Guid id, Guid clientId, [NotNull] string type, string value)
protected internal ClientClaim(Guid clientId, [NotNull] string type, string value)
{
Check.NotNull(type, nameof(type));
Id = id;
ClientId = clientId;
Type = type;
Value = value;
}
public override object[] GetKeys()
{
return new object[] { ClientId, Type, Value };
}
}
}

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientCorsOrigin.cs

@ -12,7 +12,12 @@ namespace Volo.Abp.IdentityServer.Clients
protected ClientCorsOrigin()
{
}
public virtual bool Equals(Guid clientId, [NotNull] string uri)
{
return ClientId == clientId && Origin == uri;
}
protected internal ClientCorsOrigin(Guid clientId, [NotNull] string origin)

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientGrantType.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string grantType)
{
return ClientId == clientId && GrantType == grantType;
}
protected internal ClientGrantType(Guid clientId, [NotNull] string grantType)
{
Check.NotNull(grantType, nameof(grantType));

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientIdPRestriction.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string provider)
{
return ClientId == clientId && Provider == provider;
}
protected internal ClientIdPRestriction(Guid clientId, [NotNull] string provider)
{
Check.NotNull(provider, nameof(provider));

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUri.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string uri)
{
return ClientId == clientId && PostLogoutRedirectUri == uri;
}
protected internal ClientPostLogoutRedirectUri(Guid clientId, [NotNull] string postLogoutRedirectUri)
{
Check.NotNull(postLogoutRedirectUri, nameof(postLogoutRedirectUri));

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientProperty.cs

@ -17,6 +17,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string key, string value)
{
return ClientId == clientId && Key == key && Value == value;
}
protected internal ClientProperty(Guid clientId, [NotNull] string key, [NotNull] string value)
{
Check.NotNull(key, nameof(key));

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientRedirectUri.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string uri)
{
return ClientId == clientId && RedirectUri == uri;
}
protected internal ClientRedirectUri(Guid clientId, [NotNull] string redirectUri)
{
Check.NotNull(redirectUri, nameof(redirectUri));

6
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScope.cs

@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.IdentityServer.Clients
@ -14,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string scope)
{
return ClientId == clientId && Scope == scope;
}
protected internal ClientScope(Guid clientId, string scope)
{
ClientId = clientId;

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityClaim.cs

@ -9,7 +9,12 @@ namespace Volo.Abp.IdentityServer.IdentityResources
protected IdentityClaim()
{
}
public virtual bool Equals(Guid identityResourceId, [NotNull] string type)
{
return IdentityResourceId == identityResourceId && Type == type;
}
protected internal IdentityClaim(Guid identityResourceId, [NotNull] string type)

10
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResource.cs

@ -75,5 +75,15 @@ namespace Volo.Abp.IdentityServer.IdentityResources
{
UserClaims.Clear();
}
public virtual void RemoveUserClaim(string type)
{
UserClaims.RemoveAll(c => c.Type == type);
}
public virtual IdentityClaim FindUserClaim(string type)
{
return UserClaims.FirstOrDefault(c => c.Type == type);
}
}
}

69
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs

@ -42,75 +42,6 @@ namespace Volo.Abp.IdentityServer.Clients
return await DbSet.CountAsync();
}
//public override async Task<Client> UpdateAsync(Client entity, bool autoSave = false, CancellationToken cancellationToken = default)
//{
// var secrets = DbContext.Set<ClientSecret>().Where(s => s.ClientId == entity.Id);
// foreach (var secret in secrets)
// {
// DbContext.Set<ClientSecret>().Remove(secret);
// }
// var claims = DbContext.Set<ClientClaim>().Where(s => s.ClientId == entity.Id);
// foreach (var claim in claims)
// {
// DbContext.Set<ClientClaim>().Remove(claim);
// }
// var grantTypes = DbContext.Set<ClientGrantType>().Where(s => s.ClientId == entity.Id);
// foreach (var grantType in grantTypes)
// {
// DbContext.Set<ClientGrantType>().Remove(grantType);
// }
// var restrictions = DbContext.Set<ClientIdPRestriction>().Where(s => s.ClientId == entity.Id);
// foreach (var restriction in restrictions)
// {
// DbContext.Set<ClientIdPRestriction>().Remove(restriction);
// }
// var properties = DbContext.Set<ClientProperty>().Where(s => s.ClientId == entity.Id);
// foreach (var clientProperty in properties)
// {
// DbContext.Set<ClientProperty>().Remove(clientProperty);
// }
// var scopes = DbContext.Set<ClientScope>().Where(s => s.ClientId == entity.Id);
// foreach (var scope in scopes)
// {
// DbContext.Set<ClientScope>().Remove(scope);
// }
// var corsOrigins = DbContext.Set<ClientCorsOrigin>().Where(s => s.ClientId == entity.Id);
// foreach (var corsOrigin in corsOrigins)
// {
// DbContext.Set<ClientCorsOrigin>().Remove(corsOrigin);
// }
// var redirectUris = DbContext.Set<ClientRedirectUri>().Where(s => s.ClientId == entity.Id);
// foreach (var redirectUri in redirectUris)
// {
// DbContext.Set<ClientRedirectUri>().Remove(redirectUri);
// }
// var postLogoutRedirectUris = DbContext.Set<ClientPostLogoutRedirectUri>().Where(s => s.ClientId == entity.Id);
// foreach (var postLogoutRedirectUri in postLogoutRedirectUris)
// {
// DbContext.Set<ClientPostLogoutRedirectUri>().Remove(postLogoutRedirectUri);
// }
// return await base.UpdateAsync(entity, autoSave, cancellationToken);
//}
public override IQueryable<Client> WithDetails()
{
return GetQueryable().IncludeDetails();

2
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs

@ -103,6 +103,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
{
claim.ToTable(tablePrefix + "ClientClaims", schema);
claim.HasKey(x => new { x.ClientId, x.Type, x.Value });
claim.Property(x => x.Type).HasMaxLength(ClientClaimConsts.TypeMaxLength).IsRequired();
claim.Property(x => x.Value).HasMaxLength(ClientClaimConsts.ValueMaxLength).IsRequired();
});

Loading…
Cancel
Save