Browse Source

Added DeviceFlowCodes and related classes.

pull/2545/head
Halil İbrahim Kalkan 7 years ago
parent
commit
df7c5f61cb
  1. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs
  2. 31
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Devices/DeviceFlowCodes.cs
  3. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Devices/IDeviceFlowCodesRepository.cs
  4. 17
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesRepository.cs
  5. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/AbpIdentityServerEntityFrameworkCoreModule.cs
  6. 3
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IIdentityServerDbContext.cs
  7. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs
  8. 19
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs
  9. 3
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContext.cs
  10. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContextExtensions.cs
  11. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbModule.cs
  12. 3
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IAbpIdentityServerMongoDbContext.cs
  13. 16
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoDeviceFlowCodesRepository.cs

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

@ -108,10 +108,10 @@ namespace Volo.Abp.IdentityServer.Clients
}
public Client(Guid id, [NotNull] string clientId)
: base(id)
{
Check.NotNull(clientId, nameof(clientId));
Id = id;
ClientId = clientId;
//TODO: Replace magics with constants?

31
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Devices/DeviceFlowCodes.cs

@ -0,0 +1,31 @@
using System;
using Volo.Abp.Domain.Entities.Auditing;
namespace Volo.Abp.IdentityServer.Devices
{
public class DeviceFlowCodes : CreationAuditedAggregateRoot<Guid>
{
public virtual string DeviceCode { get; set; }
public virtual string UserCode { get; set; }
public virtual string SubjectId { get; set; }
public virtual string ClientId { get; set; }
public virtual DateTime? Expiration { get; set; }
public virtual string Data { get; set; }
private DeviceFlowCodes()
{
}
public DeviceFlowCodes(Guid id)
: base(id)
{
}
}
}

10
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Devices/IDeviceFlowCodesRepository.cs

@ -0,0 +1,10 @@
using System;
using Volo.Abp.Domain.Repositories;
namespace Volo.Abp.IdentityServer.Devices
{
public interface IDeviceFlowCodesRepository : IBasicRepository<DeviceFlowCodes, Guid>
{
}
}

17
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesRepository.cs

@ -0,0 +1,17 @@
using System;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
namespace Volo.Abp.IdentityServer.Devices
{
public class DeviceFlowCodesRepository : EfCoreRepository<IIdentityServerDbContext, DeviceFlowCodes, Guid>,
IDeviceFlowCodesRepository
{
public DeviceFlowCodesRepository(IDbContextProvider<IIdentityServerDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
}
}

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

@ -2,6 +2,7 @@
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.Modularity;
@ -34,6 +35,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
options.AddRepository<ApiResource, ApiResourceRepository>();
options.AddRepository<IdentityResource, IdentityResourceRepository>();
options.AddRepository<PersistedGrant, PersistentGrantRepository>();
options.AddRepository<DeviceFlowCodes, DeviceFlowCodesRepository>();
});
}
}

3
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IIdentityServerDbContext.cs

@ -3,6 +3,7 @@ using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
@ -46,5 +47,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
DbSet<ClientProperty> ClientProperties { get; set; }
DbSet<PersistedGrant> PersistedGrants { get; set; }
DbSet<DeviceFlowCodes> DeviceFlowCodes { get; set; }
}
}

4
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs

@ -3,6 +3,7 @@ using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
@ -47,6 +48,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
public DbSet<PersistedGrant> PersistedGrants { get; set; }
public DbSet<DeviceFlowCodes> DeviceFlowCodes { get; set; }
public IdentityServerDbContext(DbContextOptions<IdentityServerDbContext> options)
: base(options)
{
@ -56,6 +59,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.ConfigureIdentityServer();
}
}

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

@ -6,6 +6,7 @@ using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
@ -289,6 +290,24 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
apiScopeClaim.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired();
apiScopeClaim.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired();
});
builder.Entity<DeviceFlowCodes>(b =>
{
b.ToTable(options.TablePrefix + "DeviceFlowCodes", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.DeviceCode).HasMaxLength(200).IsRequired();
b.Property(x => x.UserCode).HasMaxLength(200).IsRequired();
b.Property(x => x.SubjectId).HasMaxLength(200);
b.Property(x => x.ClientId).HasMaxLength(200).IsRequired();
b.Property(x => x.Expiration).IsRequired();
b.Property(x => x.Data).HasMaxLength(50000).IsRequired();
b.HasIndex(x => new { x.UserCode }).IsUnique();
b.HasIndex(x => x.DeviceCode).IsUnique();
b.HasIndex(x => x.Expiration);
});
}
}
}

3
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContext.cs

@ -2,6 +2,7 @@
using Volo.Abp.Data;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.MongoDB;
using IdentityResource = Volo.Abp.IdentityServer.IdentityResources.IdentityResource;
@ -19,6 +20,8 @@ namespace Volo.Abp.IdentityServer.MongoDB
public IMongoCollection<PersistedGrant> PersistedGrants => Collection<PersistedGrant>();
public IMongoCollection<DeviceFlowCodes> DeviceFlowCodes => Collection<DeviceFlowCodes>();
protected override void CreateModel(IMongoModelBuilder modelBuilder)
{
base.CreateModel(modelBuilder);

6
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContextExtensions.cs

@ -1,6 +1,7 @@
using System;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.MongoDB;
@ -39,6 +40,11 @@ namespace Volo.Abp.IdentityServer.MongoDB
{
b.CollectionName = options.CollectionPrefix + "PersistedGrants";
});
builder.Entity<DeviceFlowCodes>(b =>
{
b.CollectionName = options.CollectionPrefix + "DeviceFlowCodes";
});
}
}
}

2
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbModule.cs

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.Modularity;
using Volo.Abp.MongoDB;
@ -32,6 +33,7 @@ namespace Volo.Abp.IdentityServer.MongoDB
options.AddRepository<IdentityResource, MongoIdentityResourceRepository>();
options.AddRepository<Client, MongoClientRepository>();
options.AddRepository<PersistedGrant, MongoPersistentGrantRepository>();
options.AddRepository<DeviceFlowCodes, MongoDeviceFlowCodesRepository>();
});
}
}

3
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IAbpIdentityServerMongoDbContext.cs

@ -1,6 +1,7 @@
using MongoDB.Driver;
using Volo.Abp.Data;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.MongoDB;
@ -18,5 +19,7 @@ namespace Volo.Abp.IdentityServer.MongoDB
IMongoCollection<IdentityResource> IdentityResources { get; }
IMongoCollection<PersistedGrant> PersistedGrants { get; }
IMongoCollection<DeviceFlowCodes> DeviceFlowCodes { get; }
}
}

16
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoDeviceFlowCodesRepository.cs

@ -0,0 +1,16 @@
using System;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.MongoDB;
namespace Volo.Abp.IdentityServer.MongoDB
{
public class MongoDeviceFlowCodesRepository :
MongoDbRepository<IAbpIdentityServerMongoDbContext, DeviceFlowCodes, Guid>, IDeviceFlowCodesRepository
{
public MongoDeviceFlowCodesRepository(
IMongoDbContextProvider<IAbpIdentityServerMongoDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}
}
Loading…
Cancel
Save