1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-31 18:27:49 +01:00

Merge pull request #785 from bitwarden/sso-config

DB support for SSO config
This commit is contained in:
Matt Portune 2020-06-22 11:53:23 -04:00 committed by GitHub
commit 2daca941f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 112 additions and 0 deletions

View File

@ -69,7 +69,10 @@
<Folder Include="dbo\User Defined Types\" />
</ItemGroup>
<ItemGroup>
<Build Include="dbo\Stored Procedures\SsoConfig_ReadByIdentifier.sql" />
<Build Include="dbo\Stored Procedures\SsoConfig_ReadByOrganizationId.sql" />
<Build Include="dbo\Tables\Grant.sql" />
<Build Include="dbo\Tables\SsoConfig.sql" />
<Build Include="dbo\Tables\User.sql" />
<Build Include="dbo\Tables\U2f.sql" />
<Build Include="dbo\Tables\Device.sql" />
@ -84,6 +87,7 @@
<Build Include="dbo\Tables\OrganizationUser.sql" />
<Build Include="dbo\Tables\Organization.sql" />
<Build Include="dbo\Views\GrantView.sql" />
<Build Include="dbo\Views\SsoConfigView.sql" />
<Build Include="dbo\Views\UserView.sql" />
<Build Include="dbo\Views\U2fView.sql" />
<Build Include="dbo\Views\CipherView.sql" />

View File

@ -0,0 +1,13 @@
CREATE PROCEDURE [dbo].[SsoConfig_ReadByIdentifier]
@Identifier NVARCHAR(50)
AS
BEGIN
SET NOCOUNT ON
SELECT TOP 1
*
FROM
[dbo].[SsoConfigView]
WHERE
[Identifier] = @Identifier
END

View File

@ -0,0 +1,13 @@
CREATE PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId]
@OrganizationId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT TOP 1
*
FROM
[dbo].[SsoConfigView]
WHERE
[OrganizationId] = @OrganizationId
END

View File

@ -0,0 +1,8 @@
CREATE TABLE [dbo].[SsoConfig] (
[OrganizationId] UNIQUEIDENTIFIER NULL,
[Identifier] NVARCHAR (50) NULL,
[Data] NVARCHAR (MAX) NULL,
[CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [FK_SsoConfig_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
);

View File

@ -0,0 +1,6 @@
CREATE VIEW [dbo].[SsoConfigView]
AS
SELECT
*
FROM
[dbo].[SsoConfig]

View File

@ -0,0 +1,68 @@
IF OBJECT_ID('[dbo].[SsoConfig]') IS NULL
BEGIN
CREATE TABLE [dbo].[SsoConfig] (
[OrganizationId] UNIQUEIDENTIFIER NULL,
[Identifier] NVARCHAR (50) NULL,
[Data] NVARCHAR (MAX) NULL,
[CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [FK_SsoConfig_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
);
END
GO
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'SsoConfig')
BEGIN
DROP VIEW [dbo].[SsoConfigView]
END
GO
CREATE VIEW [dbo].[SsoConfigView]
AS
SELECT
*
FROM
[dbo].[SsoConfig]
GO
IF OBJECT_ID('[dbo].[SsoConfig_ReadByIdentifier]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[SsoConfig_ReadByIdentifier]
END
GO
CREATE PROCEDURE [dbo].[SsoConfig_ReadByIdentifier]
@Identifier NVARCHAR(50)
AS
BEGIN
SET NOCOUNT ON
SELECT TOP 1
*
FROM
[dbo].[SsoConfigView]
WHERE
[Identifier] = @Identifier
END
GO
IF OBJECT_ID('[dbo].[SsoConfig_ReadByOrganizationId]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId]
END
GO
CREATE PROCEDURE [dbo].[SsoConfig_ReadByOrganizationId]
@OrganizationId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT TOP 1
*
FROM
[dbo].[SsoConfigView]
WHERE
[OrganizationId] = @OrganizationId
END
GO