mirror of
https://github.com/bitwarden/server.git
synced 2025-07-07 02:52:50 -05:00
Sso user table, model and repo stubbed out (#837)
* Sso user table, model and repo stubbed out * switch to nullable org id, bigint id * update GetBySsoUserAsync * cleanup migrator file * fix EF user repo * fix pg repo * is `IS NULL` checks * unique indexes * update migration scripts * add another unique index * remove old script
This commit is contained in:
@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Core.Repositories.EntityFramework
|
||||
{
|
||||
@ -122,5 +123,10 @@ namespace Bit.Core.Repositories.EntityFramework
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public Task<User> GetBySsoUserAsync(string externalId, Guid? organizationId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8
src/Core/Repositories/ISsoUserRepository.cs
Normal file
8
src/Core/Repositories/ISsoUserRepository.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Core.Repositories
|
||||
{
|
||||
public interface ISsoUserRepository : IRepository<SsoUser, long>
|
||||
{
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ namespace Bit.Core.Repositories
|
||||
public interface IUserRepository : IRepository<User, Guid>
|
||||
{
|
||||
Task<User> GetByEmailAsync(string email);
|
||||
Task<User> GetBySsoUserAsync(string externalId, Guid? organizationId);
|
||||
Task<UserKdfInformation> GetKdfInformationByEmailAsync(string email);
|
||||
Task<ICollection<User>> SearchAsync(string email, int skip, int take);
|
||||
Task<ICollection<User>> GetManyByPremiumAsync(bool premium);
|
||||
|
@ -155,5 +155,10 @@ namespace Bit.Core.Repositories.PostgreSql
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
public Task<User> GetBySsoUserAsync(string externalId, Guid? organizationId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
15
src/Core/Repositories/SqlServer/SsoUserRepository.cs
Normal file
15
src/Core/Repositories/SqlServer/SsoUserRepository.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
public class SsoUserRepository : Repository<SsoUser, long>, ISsoUserRepository
|
||||
{
|
||||
public SsoUserRepository(GlobalSettings globalSettings)
|
||||
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public SsoUserRepository(string connectionString, string readOnlyConnectionString)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{ }
|
||||
}
|
||||
}
|
@ -38,6 +38,19 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<User> GetBySsoUserAsync(string externalId, Guid? organizationId)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<User>(
|
||||
$"[{Schema}].[{Table}_ReadBySsoUserOrganizationIdExternalId]",
|
||||
new { OrganizationId = organizationId, ExternalId = externalId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.SingleOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<UserKdfInformation> GetKdfInformationByEmailAsync(string email)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
|
Reference in New Issue
Block a user