Browse Source

Identity Server Api Resource repository

pull/538/head
Yunus Emre Kalkan 8 years ago
parent
commit
ba600d75c6
  1. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs
  2. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs
  3. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IIdentityResourceRepository.cs
  4. 17
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs
  5. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs
  6. 17
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs
  7. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs

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

@ -72,5 +72,10 @@ namespace Volo.Abp.IdentityServer.ApiResources
{ {
UserClaims.Add(new ApiResourceClaim(Id, type)); UserClaims.Add(new ApiResourceClaim(Id, type));
} }
public virtual void RemoveAllUserClaims()
{
UserClaims.Clear();
}
} }
} }

10
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs

@ -21,8 +21,18 @@ namespace Volo.Abp.IdentityServer.ApiResources
); );
Task<List<ApiResource>> GetListAsync( Task<List<ApiResource>> GetListAsync(
string sorting,
int skipCount,
int maxResultCount,
bool includeDetails = false, bool includeDetails = false,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
Task<List<ApiResource>> GetListAsync(
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<long> GetTotalCount();
} }
} }

2
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IIdentityResourceRepository.cs

@ -27,6 +27,6 @@ namespace Volo.Abp.IdentityServer.IdentityResources
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
Task<long> GetTotalBlogCount(); Task<long> GetTotalCount();
} }
} }

17
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs

@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore; using Volo.Abp.IdentityServer.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
namespace Volo.Abp.IdentityServer.ApiResources namespace Volo.Abp.IdentityServer.ApiResources
{ {
@ -41,7 +42,16 @@ namespace Volo.Abp.IdentityServer.ApiResources
return await query.ToListAsync(GetCancellationToken(cancellationToken)); return await query.ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<ApiResource>> GetListAsync(string sorting, int skipCount, int maxResultCount, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeDetails(includeDetails).OrderBy(sorting ?? "name desc")
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<ApiResource>> GetListAsync( public virtual async Task<List<ApiResource>> GetListAsync(
bool includeDetails = false, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -51,6 +61,11 @@ namespace Volo.Abp.IdentityServer.ApiResources
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<long> GetTotalCount()
{
return await DbSet.CountAsync();
}
public override IQueryable<ApiResource> WithDetails() public override IQueryable<ApiResource> WithDetails()
{ {
return GetQueryable().IncludeDetails(); return GetQueryable().IncludeDetails();

2
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs

@ -54,7 +54,7 @@ namespace Volo.Abp.IdentityServer.IdentityResources
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<long> GetTotalBlogCount() public virtual async Task<long> GetTotalCount()
{ {
return await DbSet.CountAsync(); return await DbSet.CountAsync();
} }

17
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs

@ -1,13 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Driver; using MongoDB.Driver;
using MongoDB.Driver.Linq; using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.IdentityServer.ApiResources; using Volo.Abp.IdentityServer.ApiResources;
using System.Linq.Dynamic.Core;
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
namespace Volo.Abp.IdentityServer.MongoDB namespace Volo.Abp.IdentityServer.MongoDB
@ -32,5 +32,20 @@ namespace Volo.Abp.IdentityServer.MongoDB
.Where(ar=>ar.Scopes.Any(x=> scopeNames.Contains(x.Name))) .Where(ar=>ar.Scopes.Any(x=> scopeNames.Contains(x.Name)))
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<ApiResource>> GetListAsync(string sorting, int skipCount, int maxResultCount, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.OrderBy(sorting ?? nameof(ApiResource.Name))
.As<IMongoQueryable<ApiResource>>()
.PageBy<ApiResource, IMongoQueryable<ApiResource>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<long> GetTotalCount()
{
return await GetCountAsync();
}
} }
} }

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

@ -36,7 +36,7 @@ namespace Volo.Abp.IdentityServer.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<long> GetTotalBlogCount() public virtual async Task<long> GetTotalCount()
{ {
return await GetCountAsync(); return await GetCountAsync();
} }

Loading…
Cancel
Save