Skip to content
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

Manage Access to credentialed-access projects Using Access Point Policies #2293

Open
wants to merge 26 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
102ef42
Set the bucket name for the S3 bucket containing the controlled acces…
Chrystinne Jul 25, 2024
0304cc2
Add S3_CONTROLLED_ACCESS_BUCKET to specify the default bucket for sto…
Chrystinne Jul 25, 2024
05e4ada
Add AccessPoint and AccessPointUser models.
Chrystinne Jul 25, 2024
ed36e43
Change references from AWS S3 bucket access policy to AWS S3 access p…
Chrystinne Jul 25, 2024
13deebf
Change the creation of the bucket policy to now consider whether it i…
Chrystinne Jul 25, 2024
4790d95
Check if the AWS instance exists for the project. Modify the sign_dua…
Chrystinne Jul 25, 2024
da7dff7
Fix s3 sync command for credentialed-access projects.
Chrystinne Sep 17, 2024
2f02a39
Add migration file for AccessPointUser and AccessPoint models.
Chrystinne Sep 17, 2024
bdf25c2
Updating the s3_uri parameter based on the project's access type.
Chrystinne Sep 18, 2024
730fd2c
Checking whether the user has signed the DUA before attempting to dis…
Chrystinne Nov 21, 2024
df79aa8
Avoid including aws_id as an argument in AWS.s3_uri().
Chrystinne Nov 21, 2024
4f984ec
Rename AccessPoint to AWSAccessPoint and AccessPointUser to AWSAccess…
Chrystinne Nov 21, 2024
07ee0ef
Update methods that retrieve access point and access point policy inf…
Chrystinne Nov 21, 2024
a4b287d
Adding a function to access the request object for retrieving the log…
Chrystinne Nov 21, 2024
92447ef
Remove the previous migration file: 0078_accesspointuser_accesspoint.py.
Chrystinne Nov 21, 2024
e7a527e
Add new migration file.
Chrystinne Nov 21, 2024
7afbaaf
Fix the bucket policy for the controlled-data-dev-server bucket.
Chrystinne Nov 22, 2024
1dc66d5
Set the bucket policy for the controlled-access bucket upon its initi…
Chrystinne Nov 22, 2024
b8eaa82
Fix the AccessPolicy type and configure the S3_CONTROLLED_ACCESS_BUCK…
Chrystinne Dec 3, 2024
8f06abe
Fixing access point policy updates and user assignments. Updating onl…
Chrystinne Jan 14, 2025
b42d709
Remove middleware, prevent display of AWS sync command when S3 URI is…
Chrystinne Jan 14, 2025
187fe98
Move the logic for retrieving the access point name to the view layer.
Chrystinne Jan 21, 2025
c7ee305
Enforcing uniqueness of AWSAccessPointUser for (user, aws) and adding…
Chrystinne Jan 22, 2025
ed5c551
Move the method for retrieving the S3 URI for a specific authorized u…
Chrystinne Jan 22, 2025
a180adf
Remove unused methods.
Chrystinne Jan 27, 2025
6f23a41
Refactor: remove redundant validation checks in template and view.
Chrystinne Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ AWS_SHARED_CREDENTIALS_FILE=
S3_OPEN_ACCESS_BUCKET=
# The default bucket name to store logs and metrics related to project usage.
S3_SERVER_ACCESS_LOG_BUCKET=
# The default bucket name to store projects with a 'RESTRICTED/CREDENTIALED' access policy.
S3_CONTROLLED_ACCESS_BUCKET=

# Datacite
# Used to assign the DOIs
Expand Down
40 changes: 0 additions & 40 deletions physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
upload_project_to_S3,
get_bucket_name,
check_s3_bucket_exists,
update_bucket_policy,
has_s3_credentials,
)

Expand Down Expand Up @@ -895,44 +894,6 @@ def send_files_to_aws(pid):
project.aws.save()


@associated_task(PublishedProject, "pid", read_only=True)
@background()
def update_aws_bucket_policy(pid):
"""
Update the AWS S3 bucket's access policy based on the
project's access policy.

This function determines the access policy of the project identified
by 'pid' and updates the AWS S3 bucket's access policy accordingly.
It checks if the bucket exists, retrieves its name, and uses the
'utility.update_bucket_policy' function for the update.

Args:
pid (int): The unique identifier (ID) of the project for which to
update the bucket policy.

Returns:
bool: True if the bucket policy was updated successfully,
False otherwise.

Note:
- Verify that AWS credentials and configurations are correctly set up
for the S3 client.
- The 'updated_policy' variable indicates whether the policy was
updated successfully.
"""
updated_policy = False
project = PublishedProject.objects.get(id=pid)
exists = check_s3_bucket_exists(project)
if exists:
bucket_name = get_bucket_name(project)
update_bucket_policy(project, bucket_name)
updated_policy = True
else:
updated_policy = False
return updated_policy


@console_permission_required('project.change_publishedproject')
def manage_doi_request(request, project):
"""
Expand Down Expand Up @@ -1219,7 +1180,6 @@ def aws_bucket_management(request, project, user):
is_private = False

bucket_name = get_bucket_name(project)

if not AWS.objects.filter(project=project).exists():
AWS.objects.create(
project=project, bucket_name=bucket_name, is_private=is_private
Expand Down
3 changes: 3 additions & 0 deletions physionet-django/physionet/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@
# Bucket name to store logs and metrics related to project usage.
S3_SERVER_ACCESS_LOG_BUCKET = config('S3_SERVER_ACCESS_LOG_BUCKET', default=None)

# Bucket name for the S3 bucket containing the controlled access data
S3_CONTROLLED_ACCESS_BUCKET = config('S3_CONTROLLED_ACCESS_BUCKET', default=None)

# Header tags for the AWS lambda function that grants access to S3 storage
AWS_HEADER_KEY = config('AWS_KEY', default=False)
AWS_HEADER_VALUE = config('AWS_VALUE', default=False)
Expand Down
Loading
Loading