-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ODS-6057] Prevent security misconfiguration of relationship-based au…
…thorization from authorizing requests without any filtering (#858) Co-authored-by: Geoffrey McElhanon <[email protected]>
- Loading branch information
1 parent
35106f4
commit 24b189b
Showing
5 changed files
with
398 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
182 changes: 182 additions & 0 deletions
182
...rtifacts/MsSql/Data/Security/3000-ProgramRoleResources-NoFurtherAuthorizationRequired.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- 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. | ||
|
||
DECLARE | ||
@claimSetId AS INT, | ||
@resourceClaimId AS INT, | ||
@authorizationStrategyId AS INT, | ||
@createActionId AS INT, | ||
@readActionId AS INT, | ||
@updateActionId AS INT, | ||
@deleteActionId AS INT, | ||
@readChangesActionId AS INT | ||
|
||
SELECT @createActionId = ActionId | ||
FROM [dbo].[Actions] WHERE ActionName = 'Create'; | ||
|
||
SELECT @readActionId = ActionId | ||
FROM [dbo].[Actions] WHERE ActionName = 'Read'; | ||
|
||
SELECT @updateActionId = ActionId | ||
FROM [dbo].[Actions] WHERE ActionName = 'Update'; | ||
|
||
SELECT @deleteActionId = ActionId | ||
FROM [dbo].[Actions] WHERE ActionName = 'Delete'; | ||
|
||
SELECT @readChangesActionId = ActionId | ||
FROM [dbo].[Actions] WHERE ActionName = 'ReadChanges'; | ||
|
||
SELECT @claimSetId = ClaimSetId FROM ClaimSets WHERE claimSetName = 'Ed-Fi Sandbox' | ||
|
||
SELECT @authorizationStrategyId = AuthorizationStrategyId FROM AuthorizationStrategies | ||
WHERE AuthorizationStrategyName = 'NoFurtherAuthorizationRequired' | ||
|
||
---- Update EvaluationRubricDimension Authorization Strategy ----- | ||
|
||
SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ResourceName = 'EvaluationRubricDimension' | ||
|
||
INSERT INTO ClaimSetResourceClaimActions (ClaimSetId, ResourceClaimId, ActionId) | ||
VALUES | ||
(@claimSetId, @resourceClaimId, @createActionId), | ||
(@claimSetId, @resourceClaimId, @readActionId), | ||
(@claimSetId, @resourceClaimId, @updateActionId), | ||
(@claimSetId, @resourceClaimId, @deleteActionId), | ||
(@claimSetId, @resourceClaimId, @readChangesActionId); | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @createActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @readActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @updateActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @deleteActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @readChangesActionId | ||
|
||
---- Update ProgramEvaluation Authorization Strategy ------------- | ||
|
||
SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ResourceName = 'ProgramEvaluation' | ||
|
||
INSERT INTO ClaimSetResourceClaimActions (ClaimSetId, ResourceClaimId, ActionId) | ||
VALUES | ||
(@claimSetId, @resourceClaimId, @createActionId), | ||
(@claimSetId, @resourceClaimId, @readActionId), | ||
(@claimSetId, @resourceClaimId, @updateActionId), | ||
(@claimSetId, @resourceClaimId, @deleteActionId), | ||
(@claimSetId, @resourceClaimId, @readChangesActionId); | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @createActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @readActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @updateActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @deleteActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @readChangesActionId | ||
|
||
---- Update ProgramEvaluationElement Authorization Strategy ------ | ||
|
||
SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ResourceName = 'ProgramEvaluationElement' | ||
|
||
INSERT INTO ClaimSetResourceClaimActions (ClaimSetId, ResourceClaimId, ActionId) | ||
VALUES | ||
(@claimSetId, @resourceClaimId, @createActionId), | ||
(@claimSetId, @resourceClaimId, @readActionId), | ||
(@claimSetId, @resourceClaimId, @updateActionId), | ||
(@claimSetId, @resourceClaimId, @deleteActionId), | ||
(@claimSetId, @resourceClaimId, @readChangesActionId); | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @createActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @readActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @updateActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @deleteActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @readChangesActionId | ||
|
||
---- Update ProgramEvaluationObjective Authorization Strategy ---- | ||
|
||
SELECT @resourceClaimId = ResourceClaimId FROM ResourceClaims WHERE ResourceName = 'ProgramEvaluationObjective' | ||
|
||
INSERT INTO ClaimSetResourceClaimActions (ClaimSetId, ResourceClaimId, ActionId) | ||
VALUES | ||
(@claimSetId, @resourceClaimId, @createActionId), | ||
(@claimSetId, @resourceClaimId, @readActionId), | ||
(@claimSetId, @resourceClaimId, @updateActionId), | ||
(@claimSetId, @resourceClaimId, @deleteActionId), | ||
(@claimSetId, @resourceClaimId, @readChangesActionId); | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @createActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @readActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @updateActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @deleteActionId | ||
|
||
INSERT INTO ClaimSetResourceClaimActionAuthorizationStrategyOverrides | ||
(ClaimSetResourceClaimActionId, AuthorizationStrategyId) | ||
SELECT ClaimSetResourceClaimActionId, @authorizationStrategyId FROM ClaimSetResourceClaimActions | ||
WHERE ClaimSetId = @claimSetId AND ResourceClaimId = @resourceClaimId AND ActionId = @readChangesActionId |
Oops, something went wrong.