diff --git a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql index 6373df5b76..813ef9c32f 100644 --- a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql +++ b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql @@ -3,7 +3,9 @@ -- Licensed to the Ed-Fi Alliance under one or more agreements. -- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -- See the LICENSE and NOTICES files in the project root for more information. - +IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'ClaimSetResourceClaims') +BEGIN + BEGIN DECLARE @claimId AS INT, @@ -525,3 +527,5 @@ BEGIN COMMIT TRANSACTION END + +END diff --git a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql index aedca42d79..26d20fa0fb 100644 --- a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql +++ b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql @@ -14,6 +14,7 @@ FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/balanceSheetDimension' -- Create CRUD action claims for balanceSheetDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -23,12 +24,25 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId @@ -36,6 +50,7 @@ FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/functionDimension' -- Create CRUD action claims for functionDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -45,19 +60,34 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId - +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/fundDimension' -- Create CRUD action claims for fundDimension + + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -67,18 +97,31 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/objectDimension' -- Create CRUD action claims for objectDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -88,12 +131,25 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId @@ -101,6 +157,7 @@ FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/operationalUnitDimension' -- Create CRUD action claims for operationalUnitDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -110,19 +167,31 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId - +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/programDimension' -- Create CRUD action claims for programDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -132,19 +201,32 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId - +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/projectDimension' -- Create CRUD action claims for projectDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -154,18 +236,32 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); + SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/sourceDimension' -- Create CRUD action claims for sourceDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -175,13 +271,24 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId - +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); /* NamespaceBased */ @@ -192,6 +299,7 @@ FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/descriptorMapping' -- Create CRUD action claims for descriptorMapping + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -201,9 +309,22 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); diff --git a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2140-Update-identities-claim-name.sql b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2140-Update-identities-claim-name.sql index da2e177bef..402a5bf249 100644 --- a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2140-Update-identities-claim-name.sql +++ b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Data/Security/2140-Update-identities-claim-name.sql @@ -1,4 +1,10 @@ -- Move identities to a separate "services" segment to delineate from data management resources + +IF NOT EXISTS (SELECT 1 FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity') +BEGIN + update dbo.ResourceClaims set ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity' where ClaimName = 'http://ed-fi.org/ods/identity/claims/domains/identity' + +END \ No newline at end of file diff --git a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql index 421a2c6c29..940317f9dc 100644 --- a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql +++ b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql @@ -22,6 +22,9 @@ DECLARE claim_id_stack INTEGER ARRAY; BEGIN +IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'claimsetresourceclaims') +THEN + SELECT actionid INTO create_action_id FROM dbo.actions WHERE ActionName = 'Create'; @@ -507,4 +510,6 @@ BEGIN claim_id_stack := (select claim_id_stack[1:array_upper(claim_id_stack, 1) - 1]); COMMIT; + +END IF; END $$; diff --git a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql index 5dd785e4b7..a290e5d7c0 100644 --- a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql +++ b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql @@ -15,140 +15,268 @@ BEGIN SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/balanceSheetDimension'; -- Create CRUD action claims for balanceSheetDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; + WHERE ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for balanceSheetDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; - + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/functionDimension'; -- Create CRUD action claims for functionDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for functionDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/fundDimension'; -- Create CRUD action claims for fundDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for fundDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/objectDimension'; -- Create CRUD action claims for objectDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for objectDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/operationalUnitDimension'; -- Create CRUD action claims for operationalUnitDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for operationalUnitDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/programDimension'; -- Create CRUD action claims for programDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for programDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); - SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/projectDimension'; + END IF; + + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/projectDimension'; -- Create CRUD action claims for projectDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for projectDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/sourceDimension'; -- Create CRUD action claims for sourceDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for sourceDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; - + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + + END IF; + SELECT authorizationstrategyId INTO authorizationStrategy_Id FROM dbo.AuthorizationStrategies WHERE AuthorizationStrategyName = 'NamespaceBased'; SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/descriptorMapping'; -- Create CRUD action claims for descriptorMapping + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for descriptorMapping resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + + END IF; END $$; \ No newline at end of file diff --git a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2140-Update-identities-claim-name.sql b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2140-Update-identities-claim-name.sql index da2e177bef..2811cb029a 100644 --- a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2140-Update-identities-claim-name.sql +++ b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/PgSql/Data/Security/2140-Update-identities-claim-name.sql @@ -1,4 +1,10 @@ -- Move identities to a separate "services" segment to delineate from data management resources -update dbo.ResourceClaims -set ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity' -where ClaimName = 'http://ed-fi.org/ods/identity/claims/domains/identity' +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity') THEN + UPDATE dbo.ResourceClaims + SET ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity' + WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/domains/identity'; + END IF; +END $$; + diff --git a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql index bbcaebf628..ae8fba8768 100644 --- a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql +++ b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql @@ -3,7 +3,10 @@ -- Licensed to the Ed-Fi Alliance under one or more agreements. -- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -- See the LICENSE and NOTICES files in the project root for more information. - + +IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'ClaimSetResourceClaims') +BEGIN + BEGIN DECLARE @@ -529,3 +532,4 @@ BEGIN COMMIT TRANSACTION END +END \ No newline at end of file diff --git a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql index aedca42d79..26d20fa0fb 100644 --- a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql +++ b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql @@ -14,6 +14,7 @@ FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/balanceSheetDimension' -- Create CRUD action claims for balanceSheetDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -23,12 +24,25 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId @@ -36,6 +50,7 @@ FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/functionDimension' -- Create CRUD action claims for functionDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -45,19 +60,34 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId - +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/fundDimension' -- Create CRUD action claims for fundDimension + + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -67,18 +97,31 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/objectDimension' -- Create CRUD action claims for objectDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -88,12 +131,25 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId @@ -101,6 +157,7 @@ FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/operationalUnitDimension' -- Create CRUD action claims for operationalUnitDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -110,19 +167,31 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId - +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/programDimension' -- Create CRUD action claims for programDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -132,19 +201,32 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId - +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/projectDimension' -- Create CRUD action claims for projectDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -154,18 +236,32 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); + SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/sourceDimension' -- Create CRUD action claims for sourceDimension + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -175,13 +271,24 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId - +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); /* NamespaceBased */ @@ -192,6 +299,7 @@ FROM ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/descriptorMapping' -- Create CRUD action claims for descriptorMapping + INSERT INTO dbo.ResourceClaimActions ( ActionId ,ResourceClaimId @@ -201,9 +309,22 @@ SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a WHERE ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId +); + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,@authorizationStrategyId FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId WHERE RCA.ResourceClaimId = @resourceClaimId +AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAA + WHERE RCAA.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAA.AuthorizationStrategyId = @authorizationStrategyId +); diff --git a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2140-Update-identities-claim-name.sql b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2140-Update-identities-claim-name.sql index da2e177bef..402a5bf249 100644 --- a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2140-Update-identities-claim-name.sql +++ b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/MsSql/Data/Security/2140-Update-identities-claim-name.sql @@ -1,4 +1,10 @@ -- Move identities to a separate "services" segment to delineate from data management resources + +IF NOT EXISTS (SELECT 1 FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity') +BEGIN + update dbo.ResourceClaims set ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity' where ClaimName = 'http://ed-fi.org/ods/identity/claims/domains/identity' + +END \ No newline at end of file diff --git a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql index eb11e87630..3b9eceede1 100644 --- a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql +++ b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2030-Clean-up-ReadChanges-from-AB-Connect-Claim-Set.sql @@ -20,9 +20,10 @@ DECLARE delete_action_id INTEGER; readchanges_action_id INTEGER; claim_id_stack INTEGER ARRAY; -BEGIN +BEGIN +IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'claimsetresourceclaims') THEN SELECT actionid INTO create_action_id FROM dbo.actions WHERE ActionName = 'Create'; @@ -510,4 +511,7 @@ BEGIN claim_id_stack := (select claim_id_stack[1:array_upper(claim_id_stack, 1) - 1]); COMMIT; + +END IF; + END $$; diff --git a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql index 5dd785e4b7..a290e5d7c0 100644 --- a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql +++ b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2070-DataStandard4.0a-ResourceClaimMetadata.sql @@ -15,140 +15,268 @@ BEGIN SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/balanceSheetDimension'; -- Create CRUD action claims for balanceSheetDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; + WHERE ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for balanceSheetDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; - + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/functionDimension'; -- Create CRUD action claims for functionDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for functionDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/fundDimension'; -- Create CRUD action claims for fundDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for fundDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/objectDimension'; -- Create CRUD action claims for objectDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for objectDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/operationalUnitDimension'; -- Create CRUD action claims for operationalUnitDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for operationalUnitDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/programDimension'; -- Create CRUD action claims for programDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for programDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); - SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/projectDimension'; + END IF; + + SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/projectDimension'; -- Create CRUD action claims for projectDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for projectDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + END IF; SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/sourceDimension'; -- Create CRUD action claims for sourceDimension + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for sourceDimension resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; - + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + + END IF; + SELECT authorizationstrategyId INTO authorizationStrategy_Id FROM dbo.AuthorizationStrategies WHERE AuthorizationStrategyName = 'NamespaceBased'; SELECT ResourceClaimId INTO resourceClaim_Id FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/descriptorMapping'; -- Create CRUD action claims for descriptorMapping + IF resourceClaim_Id IS NOT NULL AND authorizationStrategy_Id IS NOT NULL THEN + INSERT INTO dbo.ResourceClaimActions (ActionId ,ResourceClaimId ,ValidationRuleSetName) SELECT a.ActionId ,ResourceClaimId ,NULL FROM dbo.ResourceClaims RC CROSS JOIN dbo.Actions a - WHERE ResourceClaimId = resourceClaim_Id; - + WHERE ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActions RCA + WHERE RCA.ResourceClaimId = RC.ResourceClaimId + AND RCA.ActionId = a.ActionId); + --- 'NoFurtherAuthorizationRequired' AuthorizationStrategyName added for descriptorMapping resource + INSERT INTO dbo.ResourceClaimActionAuthorizationStrategies(ResourceClaimActionId, AuthorizationStrategyId) SELECT RCA.ResourceClaimActionId,authorizationStrategy_Id FROM dbo.ResourceClaimActionS RCA INNER JOIN dbo.ResourceClaims RC ON RCA.ResourceClaimId = RC.ResourceClaimId INNER JOIN dbo.Actions A ON RCA.ActionId = A.ActionId - WHERE RCA.ResourceClaimId = resourceClaim_Id; + WHERE RCA.ResourceClaimId = resourceClaim_Id + AND NOT EXISTS ( + SELECT 1 + FROM dbo.ResourceClaimActionAuthorizationStrategies RCAAS + WHERE RCAAS.ResourceClaimActionId = RCA.ResourceClaimActionId + AND RCAAS.AuthorizationStrategyId = authorizationStrategy_Id); + + END IF; END $$; \ No newline at end of file diff --git a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2140-Update-identities-claim-name.sql b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2140-Update-identities-claim-name.sql index da2e177bef..4d630ecff4 100644 --- a/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2140-Update-identities-claim-name.sql +++ b/Application/EdFi.Ods.Standard/Standard/5.0.0/Artifacts/PgSql/Data/Security/2140-Update-identities-claim-name.sql @@ -1,4 +1,9 @@ -- Move identities to a separate "services" segment to delineate from data management resources -update dbo.ResourceClaims -set ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity' -where ClaimName = 'http://ed-fi.org/ods/identity/claims/domains/identity' +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM dbo.ResourceClaims WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity') THEN + UPDATE dbo.ResourceClaims + SET ClaimName = 'http://ed-fi.org/ods/identity/claims/services/identity' + WHERE ClaimName = 'http://ed-fi.org/ods/identity/claims/domains/identity'; + END IF; +END $$;