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

Add configurable role access to credential flow secrets #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 app.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
oidc_thumbprint,
)



# Programmatic Clients
stack.add_programmatic_client("veda-sdk")

Expand Down
7 changes: 6 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from getpass import getuser
from typing import Optional
from typing import Optional, Sequence

import pydantic

Expand Down Expand Up @@ -39,3 +39,8 @@ class Config(pydantic.BaseSettings):
None,
description="Thumbprint of OIDC provider to use for CI workers.",
)

secret_role_access: Sequence[str] = pydantic.Field(
[],
description="Optional list of role ARNs with access to credential flow secrets"
)
7 changes: 7 additions & 0 deletions infra/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def _create_secret(
self,
service_id: str,
secret_dict: Dict[Any, Any],
secret_role_access: Sequence[str] = [] # list of roles with access to get secret value
):
"""
Create a secret to represent service credentials.
Expand All @@ -203,6 +204,10 @@ def _create_secret(
# CloudFormation template.
secret_string_value=SecretValue.unsafe_plain_text(json.dumps(secret_dict)),
)

for role_arn in secret_role_access:
role = iam.Role.from_role_arn(self, f"ImportedRole{role_arn.split(':')[-1]}", role_arn)
secret.grant_read(role)

CfnOutput(
self,
Expand Down Expand Up @@ -296,6 +301,7 @@ def add_programmatic_client(
self,
service_id: str,
name: Optional[str] = None,
secret_role_access: Optional[str] = [] # Optional role arns with access to auth flow secret
) -> cognito.UserPoolClient:

client = self.userpool.add_client(
Expand All @@ -313,6 +319,7 @@ def add_programmatic_client(
"cognito_domain": self.domain.base_url(),
"client_id": client.user_pool_client_id,
},
secret_role_access,
)

return client
Expand Down