Browse Source

Working on Client aggregate

pull/206/head
Halil İbrahim Kalkan 9 years ago
parent
commit
a03ac02ead
  1. 2
      src/AbpDesk/AbpDesk.Web.Mvc/Controllers/IdentityServerTestController.cs
  2. 2
      src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientScopeConsts.cs
  3. 6
      src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs
  4. 5
      src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScope.cs
  5. 2
      src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs
  6. 2
      test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

2
src/AbpDesk/AbpDesk.Web.Mvc/Controllers/IdentityServerTestController.cs

@ -50,7 +50,7 @@ namespace AbpDesk.Web.Mvc.Controllers
client.AddGrantTypes(GrantTypes.ClientCredentials); client.AddGrantTypes(GrantTypes.ClientCredentials);
client.AddSecret("secret".Sha256()); client.AddSecret("secret".Sha256());
client.AddAllowedScope(GuidGenerator, "api1"); //TODO: Why not with Id..? client.AddScope("api1");
await _clientRepository.InsertAsync(client); await _clientRepository.InsertAsync(client);

2
src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientScopeConsts.cs

@ -2,6 +2,6 @@
{ {
public class ClientScopeConsts public class ClientScopeConsts
{ {
public const int ScopeMaxLength = 200; public const int ScopeMaxLength = 196;
} }
} }

6
src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs

@ -26,7 +26,7 @@ namespace Volo.Abp.IdentityServer.Clients
public virtual bool RequireClientSecret { get; set; } public virtual bool RequireClientSecret { get; set; }
public virtual bool RequireConsent { get; set; } = true; public virtual bool RequireConsent { get; set; }
public virtual bool AllowRememberConsent { get; set; } public virtual bool AllowRememberConsent { get; set; }
@ -159,9 +159,9 @@ namespace Volo.Abp.IdentityServer.Clients
); );
} }
public virtual void AddAllowedScope(IGuidGenerator guidGenerator, string scope) public virtual void AddScope(string scope)
{ {
AllowedScopes.Add(new ClientScope(guidGenerator.Create(), Id, scope)); AllowedScopes.Add(new ClientScope(Id, scope));
} }
} }
} }

5
src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScope.cs

@ -3,7 +3,7 @@ using Volo.Abp.Domain.Entities;
namespace Volo.Abp.IdentityServer.Clients namespace Volo.Abp.IdentityServer.Clients
{ {
public class ClientScope : Entity<Guid> public class ClientScope : Entity
{ {
public virtual Guid ClientId { get; protected set; } public virtual Guid ClientId { get; protected set; }
@ -14,9 +14,8 @@ namespace Volo.Abp.IdentityServer.Clients
} }
public ClientScope(Guid id, Guid clientId, string scope) protected internal ClientScope(Guid clientId, string scope)
{ {
Id = id;
ClientId = clientId; ClientId = clientId;
Scope = scope; Scope = scope;
} }

2
src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs

@ -113,6 +113,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
{ {
scope.ToTable(TablePrefix + "ClientScopes"); scope.ToTable(TablePrefix + "ClientScopes");
scope.HasKey(x => new {x.ClientId, x.Scope});
scope.Property(x => x.Scope).HasMaxLength(ClientScopeConsts.ScopeMaxLength).IsRequired(); scope.Property(x => x.Scope).HasMaxLength(ClientScopeConsts.ScopeMaxLength).IsRequired();
}); });

2
test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

@ -58,7 +58,7 @@ namespace Volo.Abp.IdentityServer
} }
); );
client42.AddAllowedScope(_guidGenerator, "api1"); client42.AddScope("api1");
_clientRepository.Insert(client42); _clientRepository.Insert(client42);
} }

Loading…
Cancel
Save