1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 09:32:48 -05:00

[SM-460] Isolate SecretsManager files (#2616)

Move SecretsManager files to directories called SecretsManager and add CodeOwners
This commit is contained in:
Oscar Hinton
2023-01-24 19:57:28 +01:00
committed by GitHub
parent 4041d7f009
commit 59f5285c88
122 changed files with 449 additions and 419 deletions

View File

@ -1,44 +0,0 @@
using System.Data;
using Bit.Core.Entities;
using Bit.Core.Models.Data;
using Bit.Core.Repositories;
using Bit.Core.Settings;
using Dapper;
using Microsoft.Data.SqlClient;
namespace Bit.Infrastructure.Dapper.Repositories;
public class ApiKeyRepository : Repository<ApiKey, Guid>, IApiKeyRepository
{
public ApiKeyRepository(GlobalSettings globalSettings)
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
{ }
public ApiKeyRepository(string connectionString, string readOnlyConnectionString)
: base(connectionString, readOnlyConnectionString)
{ }
public async Task<ApiKeyDetails> GetDetailsByIdAsync(Guid id)
{
using var connection = new SqlConnection(ConnectionString);
// When adding different key details, we should change the QueryAsync type to match the database data,
// but cast it to the appropriate data model.
var results = await connection.QueryAsync<ServiceAccountApiKeyDetails>(
$"[{Schema}].[ApiKeyDetails_ReadById]",
new { Id = id },
commandType: CommandType.StoredProcedure);
return results.SingleOrDefault();
}
public async Task<ICollection<ApiKey>> GetManyByServiceAccountIdAsync(Guid serviceAccountId)
{
using var connection = new SqlConnection(ConnectionString);
var results = await connection.QueryAsync<ApiKey>(
$"[{Schema}].[ApiKey_ReadByServiceAccountId]",
new { ServiceAccountId = serviceAccountId },
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}