mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
[Require SSO] Enterprise policy enforcement (#970)
* Initial commit of require sso authentication policy enforcement * Updated sproc to send UseSso flag // Updated base validator to send back error message // Added changes to EntityFramework (just so its there for the future * Update policy name // adjusted conditional to demorgan's * Updated sproc // Added migrator script * Added .sql file extension to DeleteOrgUserWithOrg migrator script * Added policy // edit // strings // validation to business portal * Change requests from review // Added Owner & Admin exemption * Updated repository function used to get org user's type * Updated with requested changes
This commit is contained in:
@ -0,0 +1,69 @@
|
||||
IF OBJECT_ID('[dbo].[Organization_DeleteById]') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE [dbo].[Organization_DeleteById]
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[Organization_DeleteById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationId] @Id
|
||||
|
||||
DECLARE @BatchSize INT = 100
|
||||
WHILE @BatchSize > 0
|
||||
BEGIN
|
||||
BEGIN TRANSACTION Organization_DeleteById_Ciphers
|
||||
|
||||
DELETE TOP(@BatchSize)
|
||||
FROM
|
||||
[dbo].[Cipher]
|
||||
WHERE
|
||||
[UserId] IS NULL
|
||||
AND [OrganizationId] = @Id
|
||||
|
||||
SET @BatchSize = @@ROWCOUNT
|
||||
|
||||
COMMIT TRANSACTION Organization_DeleteById_Ciphers
|
||||
END
|
||||
|
||||
BEGIN TRANSACTION Organization_DeleteById
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[SsoUser]
|
||||
WHERE
|
||||
[OrganizationId] = @Id
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[SsoConfig]
|
||||
WHERE
|
||||
[OrganizationId] = @Id
|
||||
|
||||
DELETE CU
|
||||
FROM
|
||||
[dbo].[CollectionUser] CU
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] OU ON [CU].[OrganizationUserId] = [OU].[Id]
|
||||
WHERE
|
||||
[OU].[OrganizationId] = @Id
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[OrganizationUser]
|
||||
WHERE
|
||||
[OrganizationId] = @Id
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[Organization]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
|
||||
COMMIT TRANSACTION Organization_DeleteById
|
||||
END
|
||||
|
||||
GO
|
Reference in New Issue
Block a user