-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Missing Feature - UserPool client configuration (Callback URLs and scopes) #3037
Comments
Hi Callum, thanks for reaching out! Unfortunately, it appears that CloudFormation doesn't currently support setting callback or signout URLs. Once they have resolved the issue, I will reopen this issue as a feature-request. |
Thanks will close for now and keep an eye on cloud formation updates. |
In an effort to have better visibility of Cfn support gaps, we are going to keep these open, so I am going to reopen this issue. |
From the CloudFormation documentation on UserPoolClient I would expect CloudFormation to support callback and logout URLS. Not sure if this was added recently by the CloudFormation team, but I thought it would be useful to post it here. So this means that for now you could use the
Be aware of the 'strange' capitalizing of the I did give it a run with CDK 1.9.0 and it seemed to create the UserPoolClient with the callback URL just fine for me. |
I'm not sure if this is the right place, but in my use case, I'd like to authenticate with cognito from an application load balancer action using a secret generated via a UserPoolClient or CfnUserPoolClient. It doesn't seem clear how the oidc client secret can be gotten from the UserPoolClient and given to the application load balancer rule actions, as I seem to get a nonsense value from from the Apparently there was a ClientSecret attribute documented on UserPoolClient resources at one point. I'm not sure what happened. |
Hi @misterjoshua, I believe there is no convenient way to automate this at the moment. The client secret is not available through CloudFormation and thus there is no way to use it from CDK simply by referencing the attribute. That said, what you might be able to do is the following*:
*Not sure if this plays well if all resources are defined within the same stack, because secrets needs to be available at the moment the CloudFormation template is being rolled out. But if you use different stacks for your Cognito UserPoolClient and ALB resources I don't see why it wouldn't work. I haven't tried this myself, so that's how far my warranty goes ;-), but it might be worth a try. By the way have you considered posting your question on Stackoverflow? Maybe other people might have a potential solution for this as well. |
May be worth checking out and subscribing to aws/aws-cdk-rfcs#95 as well. |
I'm having an issue with something similar. I'm unable to use the suggested SSM parameter if the string is secured. |
As a followup to @dveijck's post above replying to @misterjoshua; CDK has a really short/convenient syntax for custom resources that just need to call AWS SDK functions:
A basic example (untested for this use case exactly) derived from some similar code I wrote recently: const describeCognitoUserPoolClient = new cr.AwsCustomResource(
this,
'DescribeCognitoUserPoolClient',
{
resourceType: 'Custom::DescribeCognitoUserPoolClient',
onCreate: {
region: 'us-east-1',
service: 'CognitoIdentityServiceProvider',
action: 'describeUserPoolClient',
parameters: {
UserPoolId: userPool.userPoolId,
ClientId: userPoolClient.userPoolClientId,
},
physicalResourceId: cr.PhysicalResourceId.of(userPoolClient.userPoolClientId),
},
// TODO: can we restrict this policy more?
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
}),
}
)
const userPoolClientSecret = describeCognitoUserPoolClient.getResponseField(
'UserPoolClient.ClientSecret'
)
new cdk.CfnOutput(this, 'UserPoolClientSecret', {
value: userPoolClientSecret,
}) |
Hello, Thanks |
I'm wondering the same, I cannot find the sign out URL as params. I'm using cdk in typescript. |
@huankimtran @leantorres73 the parameter is called |
@katiewoolston maybe it exists for other languages, for typescript is not implemented.
|
@leantorres73 I'm using TypeScript, but the import { CfnUserPoolClient } from '@aws-cdk/aws-cognito';
const userPoolClient = new CfnUserPoolClient(this, 'MyAppClient', {
clientName: 'MyAppClient',
userPoolId: 'some-userpool-id',
...someOtherParams,
callbackUrLs: [myAppUrl],
logoutUrLs: [myAppUrl],
}); |
@katiewoolston got it, I'm using the
|
Ah, I see - yeah, it doesn't look like you can do it that way. |
Hey. When I'm trying to deploy it with cdk codePipeline I have this issue: |
My issue is I need the client id to construct the default login/logout urls for simple route protection using default cognito signing page. You cannot modify the oath properties without layer 1 resources which I want to avoid. The logout url and login url could really just have a boolean option to assume the defaults or accept callbacks which return the this.userPool = new UserPool(this, 'user-pool', {
someOptions
...
})
this.userPoolDomain = this.userPool.addDomain('user-pool-domain', {
someOptions
...
})
const baseUrl = this.userPoolDomain.baseUrl()
// const clientId = this.userPoolClient.userPoolClientId // obviously throws undefined
const loginRedirect = `${baseUrl}/oauth2/idpresponse`
const oAuth: OAuthSettings = {
scopes: [OAuthScope.EMAIL, OAuthScope.PHONE, OAuthScope.PROFILE, OAuthScope.OPENID],
flows: {
authorizationCodeGrant: true
},
callbackUrls: [loginRedirect],
// logoutUrls: [] // cannot be constructed without this.userPoolClient.userPoolClientId
// https://myurl/logout?client_id=${unknown_by_this_point}&redirect_uri=${loginRedirect}&response_type=code&scope=openid
}
this.userPoolClient = new UserPoolClient(this, 'user-pool-client', {
userPool: this.userPool,
someOptions
..
oAuth
})
// this.userPoolClient // no mutations available for callback or logout urls. I eventually tried the |
Ability to configure a Cognito User Pool Clients including callback URLs, signout URLs, and allowed scopes.
I'm submitting a ...
What is the current behavior?
Can create UserPools and UserPool clients, however the configuration of the client is very limited. Can only specify clientName, enabledAuthFlows, and whether to create a secret or not.
What is the expected behavior (or behavior of feature suggested)?
Would also like to be able to configure callback URLs, signout URLs, and allowed scopes so a complete functional UserPool can be created from scratch.
What is the motivation / use case for changing the behavior or adding this feature?
Ability to create an ApiGateway secured by a cognito userpool with specific callback URLs and available scopes.
Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
Currently I am creating the userpool like below, I believe this to be correct but please tell me if this is the wrong way to go about this?
The text was updated successfully, but these errors were encountered: