Skip to content

Commit 699b872

Browse files
committed
chore: add oidc config to api
1 parent 5421bc4 commit 699b872

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

src/integ_test_resources/android/amplify/integration/cdk/scripts/amplify_app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from common import (
44
LOGGER,
55
AMPLIFY_AWSSDK_CLIENT,
6+
SECRETS_MANAGER_CLIENT,
67
BASE_PATH,
78
run_command,
89
OperationType
@@ -88,6 +89,10 @@ def push(self):
8889
self._load_metadata()
8990
return result.returncode
9091

92+
def retrieve_secret(self, secret_name: str):
93+
get_secret_result = SECRETS_MANAGER_CLIENT.get_secret_value(SecretId=secret_name)
94+
return json.loads(get_secret_result["SecretString"])
95+
9196
def _get_existing_app_id(self):
9297
try:
9398
response = AMPLIFY_AWSSDK_CLIENT.list_apps()

src/integ_test_resources/android/amplify/integration/cdk/scripts/auth.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def create(cls, *, auth_resource_name:str,
99
allow_unauth = True,
1010
signin_method = 'USERNAME',
1111
group_names = [],
12+
oauth_config = None,
1213
refresh_token_period_in_days = 365,
1314
required_signup_attributes = ['EMAIL', 'NAME', 'NICKNAME'],
1415
write_attributes = ['EMAIL', 'NAME', 'NICKNAME'],
@@ -37,6 +38,9 @@ def create(cls, *, auth_resource_name:str,
3738
'refreshTokenPeriod': refresh_token_period_in_days
3839
}
3940

41+
if oauth_config is not None:
42+
user_pool_config['oAuth'] = oauth_config
43+
4044
id_pool_config = {
4145
'unauthenticatedLogin': allow_unauth,
4246
'identityPoolName': identity_pool_name

src/integ_test_resources/android/amplify/integration/cdk/scripts/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class OperationType(Enum):
1313
def parse_arguments():
1414
parser = argparse.ArgumentParser(description="Utility that runs the Amplify CLI in headless mode to provision backend resources for integration tests.")
1515
parser.add_argument("--backend_name", help="The name of the Amplify app.", required=True)
16+
parser.add_argument("--oidc_provider", help="Name of the oidc provider.")
1617
parser.add_argument("--schema_dir", help="Name of the subdirectory under the schemas folder that contains the GraphQL schemas for the backend API.", required=True)
1718
parser.add_argument("--group_names", help="Comma-separated list of group names to be created.", default="")
1819
parser.add_argument("--conflict_resolution", help="Conflict resolution mode.")
@@ -26,6 +27,7 @@ def parse_arguments():
2627
LOGGER.addHandler(CONSOLE_HANDLER)
2728

2829
AMPLIFY_AWSSDK_CLIENT = boto3.client('amplify')
30+
SECRETS_MANAGER_CLIENT = boto3.client('secretsmanager')
2931
REGION = 'us-east-1'
3032
SCRIPTS_DIR = os.path.dirname(__file__)
3133
LOGGER.info(f"SCRIPTS_DIR = {SCRIPTS_DIR}")

src/integ_test_resources/android/amplify/integration/cdk/scripts/setup_amplify

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,20 @@ auth_config = AuthConfigFactory.create(auth_resource_name=auth_resource_name,
4646

4747
auth_cmd_result = amplify_app.config_auth(auth_config=auth_config, op_type=auth_op_type)
4848
if auth_cmd_result == 0:
49-
LOGGER.info("Auth category configured.")
49+
LOGGER.info("Auth category configured. Pushing changes.")
50+
push_cmd_result = amplify_app.push()
51+
if push_cmd_result == 0:
52+
LOGGER.info("Auth category changed pushed.")
53+
else:
54+
LOGGER.error("Failed to push Auth category changes.")
55+
exit(-1)
5056
else:
5157
LOGGER.error("Failed to configure Auth category.")
5258
exit(-1)
5359

54-
amplify_app.push()
55-
5660
api_key_config = ApiAuthModeFactory.create_api_key_config()
5761
user_pools_config = ApiAuthModeFactory.create_user_pools_config(auth_resource_name=f"auth{auth_resource_name}")
58-
oidc_config = ApiAuthModeFactory.create_oidc_config(client_id='dummy', issuer_url="https://localhost/", provider_name="Dummy provider")
62+
oidc_config = ApiAuthModeFactory.create_oidc_config(client_id='dummy', issuer_url="https://accounts.google.com/", provider_name='GoogleIntegTestOIDC')
5963
iam_config = ApiAuthModeFactory.create_iam_config()
6064
api_config = ApiConfigFactory.create(api_name=f"{amplify_backend_name}Api",
6165
op_type=api_op_type,

src/integ_test_resources/android/amplify/integration/cdk/stacks/amplify_deployer_stack.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,21 @@ def __init__(self, scope: core.App, id: str, props, **kwargs) -> None:
9191
aws_iam.PolicyStatement(actions=individual_actions, effect=aws_iam.Effect.ALLOW, resources=["*"]),
9292
]
9393
)
94+
policy.attach_to_role(project.role)
9495

96+
policy = aws_iam.ManagedPolicy(self,
97+
"AmplifyCodeBuildScriptRunnerSecretReaderPolicy",
98+
managed_policy_name=f"AmplifyCodeBuildScriptRunnerSecretReaderPolicy-{cb_project_name}",
99+
description="Policy used by the CodeBuild role that manages the creation of backend resources using the Amplify CLI",
100+
statements=[
101+
aws_iam.PolicyStatement(actions=["secretsmanager:GetSecretValue"],
102+
effect=aws_iam.Effect.ALLOW,
103+
resources=[f"arn:aws:secretsmanager:us-east-1:{self.account}:secret:awsmobilesdk/android/*"]),
104+
]
105+
)
95106
policy.attach_to_role(project.role)
96107

108+
97109
project.role.add_managed_policy(aws_iam.ManagedPolicy.from_aws_managed_policy_name("AmazonS3FullAccess"))
98110
project.role.add_managed_policy(aws_iam.ManagedPolicy.from_aws_managed_policy_name("AWSCloudFormationFullAccess"))
99111
project.role.add_managed_policy(aws_iam.ManagedPolicy.from_aws_managed_policy_name('IAMReadOnlyAccess'))

0 commit comments

Comments
 (0)