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

Access Token Validity not supported #44

Closed
Waschnick opened this issue Feb 26, 2021 · 6 comments · Fixed by #45
Closed

Access Token Validity not supported #44

Waschnick opened this issue Feb 26, 2021 · 6 comments · Fixed by #45
Labels
enhancement New feature or request

Comments

@Waschnick
Copy link
Contributor

Waschnick commented Feb 26, 2021

Currently there is only client_refresh_token_validity, but cognito also supports the validity for the access token (5min to 24h) and id token. Can you add client_access_token_validity and client_id_token_validity?

example

@lgallard
Copy link
Owner

@Waschnick I don't see those attributes in the resource https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cognito_user_pool_client

Where did you get client_access_token_validity and client_access_token_validity names ?

In fact, there's an open issue in the AWS provider at hashicorp/terraform-provider-aws#14919 which requests those attributes to be included in the resource.

As soon as there are available I can add them to the module.

Thanks por reporting them!

@Waschnick
Copy link
Contributor Author

Waschnick commented Feb 28, 2021

Argh you are right, again. I would just implement it myself and create a PR for it on the hashicorp repo, but it has nearly 700 open PRs. EDIT: No need, there is already an open PR for this...

It's the same with the Lambda hook for "CustomSender" (CustomEmailSender), which is only supported via the AWS Cli (its not even visible in the AWS console). I created a shell script running in my CI pipeline to add the lambda via AWS Cli, but that's for the user-pool, which is way easier to configure. The client has way to many attributes...

@lgallard
Copy link
Owner

lgallard commented Mar 1, 2021

@Waschnick another approach is to use a CloudFormation stack called from Terraform to define the client. Take a look at AWS::Cognito::UserPoolClient and the Terraform's resource aws_cloudformation_stack if you want to explore that option.

@Waschnick
Copy link
Contributor Author

Hey @lgallard you should be able to add it now, it was recently released:

https://github.com/hashicorp/terraform-provider-aws/blob/v3.32.0/CHANGELOG.md
"Add support for access_token_validity"

@lgallard
Copy link
Owner

@Waschnick I will include it in the next release!

@lgallard
Copy link
Owner

lgallard commented Apr 10, 2021

@Waschnick Release 0.10.2 added the support. For the above screenshot define as follows:

# clients
clients = [
   {
     allowed_oauth_flows                  = []
     allowed_oauth_flows_user_pool_client = false
     allowed_oauth_scopes                 = []
     callback_urls                        = ["https://mydomain.com/callback"]
     default_redirect_uri                 = "https://mydomain.com/callback"
     explicit_auth_flows                  = []
     generate_secret                      = true
     logout_urls                          = []
     name                                 = "test1"
     read_attributes                      = ["email"]
     supported_identity_providers         = []
     write_attributes                     = []
     access_token_validity                = 1 
     id_token_validity                    = 1
     refresh_token_validity               = 60
     token_validity_units = {
       access_token  = "hours"
       id_token      = "hours"
       refresh_token = "days"
     }
   },
...
 ]

The complete example has this definition, alongside other clients definitions examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants