-
Notifications
You must be signed in to change notification settings - Fork 93
Add IAM Permissions Boundary support for environments #1928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
petrkalos
wants to merge
10
commits into
main
Choose a base branch
from
feature/permission_boundaries
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6964af0
backend impl
50435a9
fix migration
a082644
add ui
baf453d
add integ tests
eb5cf3d
add ui
d7bb31d
improve test
d5cc584
simplify test
77c3d24
format
eee7891
fix eslint
1dac92e
Merge branch 'main' into feature/permission_boundaries
petrkalos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
18 changes: 18 additions & 0 deletions
18
backend/dataall/core/environment/cdk/permissions_boundary_aspect.py
This file contains hidden or 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,18 @@ | ||
| import jsii | ||
| from aws_cdk import IAspect, CfnResource | ||
|
|
||
|
|
||
| @jsii.implements(IAspect) | ||
| class PermissionsBoundaryAspect: | ||
| """CDK Aspect that applies a permissions boundary to all IAM roles in a stack. | ||
|
|
||
| This handles roles auto-created by CDK constructs (e.g. cr.Provider, BucketDeployment) | ||
| that cannot be configured directly. | ||
| """ | ||
|
|
||
| def __init__(self, permissions_boundary_arn: str): | ||
| self._arn = permissions_boundary_arn | ||
|
|
||
| def visit(self, node): | ||
| if isinstance(node, CfnResource) and node.cfn_resource_type == 'AWS::IAM::Role': | ||
| node.add_property_override('PermissionsBoundary', self._arn) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
24 changes: 24 additions & 0 deletions
24
backend/migrations/versions/a4f8b2c1d3e5_add_permissions_boundary_to_environment.py
This file contains hidden or 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,24 @@ | ||
| """add_permissions_boundary_to_environment | ||
|
|
||
| Revision ID: a4f8b2c1d3e5 | ||
| Revises: 2258cd8d6e9f | ||
| Create Date: 2024-05-01 00:00:00.000000 | ||
|
|
||
| """ | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = 'a4f8b2c1d3e5' | ||
| down_revision = '2258cd8d6e9f' | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| op.add_column('environment', sa.Column('PermissionsBoundaryPolicyArn', sa.String(), nullable=True)) | ||
|
|
||
|
|
||
| def downgrade(): | ||
| op.drop_column('environment', 'PermissionsBoundaryPolicyArn') |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So when user has entered nothing , then in that case this will be '' ? ( empty string ) . If yes, wouldn't this pass empty string ''.
The reason I am thinking it will be '' is because of the code here = backend/dataall/core/environment/services/environment_service.py .. The model uses
PermissionsBoundaryPolicyArn=data.get('PermissionsBoundaryPolicyArn', ''),Please correct if I am wrong here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user pass an empty string
''the condition will evaluate toFalseand hence the boundary will be removed. Is that wrong?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is right. I actually wanted to allude to the possibility if the user enters ' ' ( blank space ) or 'arn:aws....' then in that case are we validating that the input is an ARN or that we are conditioning the string properly in the backend ?