mirror of
https://github.com/bitwarden/server.git
synced 2025-07-05 10:02:47 -05:00
[PM-5645] Cosmos DB Grant Storage (#3634)
* table storage grants * simple shard on storage accounts * use is not * cosmos grant repo * remove single storage connection string * some fixes to dapper grant repo * pattern matching * add fallback to base PersistedGrantStore * service collection extension cleanup * cleanup * remove unused Id * empty string rowkey * fix sharding method logic * ttl for cosmos * make ttl an int * fixes to cosmos implementation * fix partition key values * catch notfound exceptions * indenting * update grantitem with custom serialization * use new transform helpers * grantloader perf test tool * ref * remove grant loader project * remove table storage implementation * remove table storage stuff * all redis fallback to build to null * revert sln file change * EOF new line * remove trailing comma * lint fixes * add grant to names * move cosmos serilaizer to utils * add some .net 8 keyed service comments * EnableContentResponseOnWrite * Fix type in EF grant repository
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using System.Data;
|
||||
using Bit.Core.Auth.Entities;
|
||||
using Bit.Core.Auth.Models.Data;
|
||||
using Bit.Core.Auth.Repositories;
|
||||
using Bit.Core.Settings;
|
||||
using Bit.Infrastructure.Dapper.Repositories;
|
||||
@ -18,11 +19,11 @@ public class GrantRepository : BaseRepository, IGrantRepository
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public async Task<Grant> GetByKeyAsync(string key)
|
||||
public async Task<IGrant> GetByKeyAsync(string key)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Grant>(
|
||||
var results = await connection.QueryAsync<IGrant>(
|
||||
"[dbo].[Grant_ReadByKey]",
|
||||
new { Key = key },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
@ -31,12 +32,12 @@ public class GrantRepository : BaseRepository, IGrantRepository
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Grant>> GetManyAsync(string subjectId, string sessionId,
|
||||
public async Task<ICollection<IGrant>> GetManyAsync(string subjectId, string sessionId,
|
||||
string clientId, string type)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Grant>(
|
||||
var results = await connection.QueryAsync<IGrant>(
|
||||
"[dbo].[Grant_Read]",
|
||||
new { SubjectId = subjectId, SessionId = sessionId, ClientId = clientId, Type = type },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
@ -45,8 +46,13 @@ public class GrantRepository : BaseRepository, IGrantRepository
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SaveAsync(Grant obj)
|
||||
public async Task SaveAsync(IGrant obj)
|
||||
{
|
||||
if (obj is not Grant gObj)
|
||||
{
|
||||
throw new ArgumentException(null, nameof(obj));
|
||||
}
|
||||
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.ExecuteAsync(
|
||||
|
Reference in New Issue
Block a user