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

fix(cognito): callback URLs are specified when OAuth is disabled for user pool clients #10588

Merged
merged 3 commits into from
Sep 30, 2020
Merged
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: 1 addition & 1 deletion packages/@aws-cdk/aws-cognito/lib/user-pool-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class UserPoolClient extends Resource implements IUserPoolClient {
explicitAuthFlows: this.configureAuthFlows(props),
allowedOAuthFlows: props.disableOAuth ? undefined : this.configureOAuthFlows(),
allowedOAuthScopes: props.disableOAuth ? undefined : this.configureOAuthScopes(props.oAuth),
callbackUrLs: callbackUrls && callbackUrls.length > 0 ? callbackUrls : undefined,
callbackUrLs: callbackUrls && callbackUrls.length > 0 && !props.disableOAuth ? callbackUrls : undefined,
logoutUrLs: props.oAuth?.logoutUrls,
shivlaks marked this conversation as resolved.
Show resolved Hide resolved
allowedOAuthFlowsUserPoolClient: !props.disableOAuth,
preventUserExistenceErrors: this.configurePreventUserExistenceErrors(props.preventUserExistenceErrors),
Expand Down
17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-cognito/test/user-pool-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,23 @@ describe('User Pool Client', () => {
});
});

test('callbackUrls are not rendered if OAuth is disabled ', () => {
// GIVEN
const stack = new Stack();
const pool = new UserPool(stack, 'Pool');

// WHEN
new UserPoolClient(stack, 'PoolClient', {
userPool: pool,
disableOAuth: true,
});

// THEN
expect(stack).toHaveResourceLike('AWS::Cognito::UserPoolClient', {
CallbackURLs: ABSENT,
});
});

test('fails when callbackUrls is empty for codeGrant or implicitGrant', () => {
const stack = new Stack();
const pool = new UserPool(stack, 'Pool');
Expand Down