mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
Additional changes for enterprise portal sso config (#819)
* Additional changes for enterprise portal sso config * Requested changes * rename enum to Saml2 * Limit to one SSO config per org
This commit is contained in:
parent
5ecdc77d3f
commit
92238eb0a9
@ -2,7 +2,7 @@
|
||||
{
|
||||
public enum SsoType : byte
|
||||
{
|
||||
// TODO proper SsoType values
|
||||
Test = 1
|
||||
OpenIdConnect = 1,
|
||||
Saml2 = 2,
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,18 @@
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class SsoConfig
|
||||
public class SsoConfig : ITableObject<long>
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public long Id { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
public Guid OrganizationId { get; set; }
|
||||
public string Data { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
// nothing - int will be auto-populated
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
src/Core/Repositories/ISsoConfigRepository.cs
Normal file
12
src/Core/Repositories/ISsoConfigRepository.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Core.Repositories
|
||||
{
|
||||
public interface ISsoConfigRepository : IRepository<SsoConfig, long>
|
||||
{
|
||||
Task<SsoConfig> GetByOrganizationIdAsync(Guid organizationId);
|
||||
Task<SsoConfig> GetByIdentifierAsync(string identifier);
|
||||
}
|
||||
}
|
47
src/Core/Repositories/SqlServer/SsoConfigRepository.cs
Normal file
47
src/Core/Repositories/SqlServer/SsoConfigRepository.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Table;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
public class SsoConfigRepository : Repository<SsoConfig, long>, ISsoConfigRepository
|
||||
{
|
||||
public SsoConfigRepository(GlobalSettings globalSettings)
|
||||
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public SsoConfigRepository(string connectionString, string readOnlyConnectionString)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public async Task<SsoConfig> GetByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<SsoConfig>(
|
||||
$"[{Schema}].[{Table}_ReadByOrganizationId]",
|
||||
new { OrganizationId = organizationId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.SingleOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<SsoConfig> GetByIdentifierAsync(string identifier)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<SsoConfig>(
|
||||
$"[{Schema}].[{Table}_ReadByIdentifier]",
|
||||
new { Identifier = identifier },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -76,6 +76,7 @@ namespace Bit.Core.Utilities
|
||||
services.AddSingleton<IMaintenanceRepository, SqlServerRepos.MaintenanceRepository>();
|
||||
services.AddSingleton<ITransactionRepository, SqlServerRepos.TransactionRepository>();
|
||||
services.AddSingleton<IPolicyRepository, SqlServerRepos.PolicyRepository>();
|
||||
services.AddSingleton<ISsoConfigRepository, SqlServerRepos.SsoConfigRepository>();
|
||||
}
|
||||
|
||||
if (globalSettings.SelfHosted)
|
||||
|
Loading…
Reference in New Issue
Block a user