Skip to content

Commit c1ef4c9

Browse files
authored
Merge pull request #51 from mineiros-io/soerenmartius/add-support-for-token_validity_units
Add support for token validity units
2 parents 0ba192c + 6c6cc3d commit c1ef4c9

File tree

9 files changed

+91
-9
lines changed

9 files changed

+91
-9
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.8.0]
11+
12+
### BREAKING
13+
14+
- Minimum version of the aws provider has been bumped to `3.32.0` to enable
15+
support for `token_validity_units`
16+
17+
### Added
18+
19+
- Add support `token_validity_units`
20+
1021
## [0.7.0]
1122

1223
### Added
@@ -123,11 +134,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
123134

124135
<!-- markdown-link-check-disable -->
125136

126-
[unreleased]: https://github.com/mineiros-io/terraform-aws-cognito-user-pool/compare/v0.7.0...HEAD
127-
[0.7.0]: https://github.com/mineiros-io/terraform-aws-cognito-user-pool/compare/v0.6.0...v0.7.0
137+
[unreleased]: https://github.com/mineiros-io/terraform-aws-cognito-user-pool/compare/v0.8.0...HEAD
138+
[0.8.0]: https://github.com/mineiros-io/terraform-aws-cognito-user-pool/compare/v0.7.0...v0.8.0
128139

129140
<!-- markdown-link-check-enable -->
130141

142+
[0.7.0]: https://github.com/mineiros-io/terraform-aws-cognito-user-pool/compare/v0.6.0...v0.7.0
131143
[0.6.0]: https://github.com/mineiros-io/terraform-aws-cognito-user-pool/compare/v0.5.0...v0.6.0
132144
[0.5.0]: https://github.com/mineiros-io/terraform-aws-cognito-user-pool/compare/v0.4.1...v0.5.0
133145
[0.4.1]: https://github.com/mineiros-io/terraform-aws-cognito-user-pool/compare/v0.4.0...v0.4.1

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Most basic usage just setting required arguments:
6767
```hcl
6868
module "terraform-aws-cognito-user-pool" {
6969
source = "mineiros-io/cognito-user-pool/aws"
70-
version = "~> 0.7.0"
70+
version = "~> 0.8.0"
7171
7272
name = "application-userpool"
7373
}
@@ -456,6 +456,10 @@ for details and use-cases.
456456
default_client_write_attributes = null
457457
default_client_explicit_auth_flows = null
458458
default_client_prevent_user_existence_errors = null
459+
default_client_access_token_validity = null
460+
default_client_id_token_validity = null
461+
default_client_token_validity_units = null
462+
default_client_enable_token_revocation = null
459463
```
460464

461465
- **`default_client_callback_urls`**: *(Optional `list(string)`)*
@@ -510,6 +514,24 @@ for details and use-cases.
510514

511515
Choose which errors and responses are returned by Cognito APIs during authentication, account confirmation, and password recovery when the user does not exist in the Cognito User Pool. When set to `ENABLED` and the user does not exist, authentication returns an error indicating either the username or password was incorrect, and account confirmation and password recovery return a response indicating a code was sent to a simulated destination. When set to `LEGACY`, those APIs will return a `UserNotFoundException` exception if the user does not exist in the Cognito User Pool.
512516

517+
- **`default_client_access_token_validity`**: *(Optional `number`)*
518+
519+
Time limit, between 5 minutes and 1 day, after which the access token is no longer valid and cannot be used.
520+
This value will be overridden if you have entered a value in 'default_client_token_validity_units'.
521+
522+
- **`default_client_id_token_validity`**: *(Optional `number`)*
523+
524+
Time limit, between 5 minutes and 1 day, after which the ID token is no longer valid and cannot be used.
525+
This value will be overridden if you have entered a value in 'default_client_token_validity_units'.
526+
527+
- **`default_client_token_validity_units`**: *(Optional `any`)*
528+
529+
Configuration block for units in which the validity times are represented in.
530+
531+
- **`default_client_enable_token_revocation`**: *(Optional `bool`)*
532+
533+
Enables or disables token revocation.
534+
513535
## Module Attributes Reference
514536

515537
The following attributes are exported by the module:

examples/complete/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ shows how to deploy a Cognito User Pool with custom settings.
1212
```hcl
1313
module "cognito_user_pool" {
1414
source = "mineiros-io/cognito-user-pool/aws"
15-
version = "~> 0.7.0"
15+
version = "~> 0.8.0"
1616
1717
name = "complete-example-userpool"
1818

examples/complete/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ provider "aws" {
1717

1818
module "cognito_user_pool" {
1919
source = "mineiros-io/cognito-user-pool/aws"
20-
version = "~> 0.7.0"
20+
version = "~> 0.8.0"
2121

2222
name = "complete-example-userpool"
2323

examples/user-pool-with-default-settings/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defined in the [variables.tf] file of this module.
1313
```hcl
1414
module "cognito_user_pool" {
1515
source = "mineiros-io/cognito-user-pool/aws"
16-
version = "~> 0.7.0"
16+
version = "~> 0.8.0"
1717
1818
name = "example-userpool"
1919
}

examples/user-pool-with-default-settings/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ provider "aws" {
1818

1919
module "cognito_user_pool" {
2020
source = "mineiros-io/cognito-user-pool/aws"
21-
version = "~> 0.7.0"
21+
version = "~> 0.8.0"
2222

2323
name = "example-userpool"
2424
}

main.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ locals {
202202
supported_identity_providers = lookup(client, "supported_identity_providers", var.default_client_supported_identity_providers)
203203
prevent_user_existence_errors = lookup(client, "prevent_user_existence_errors", var.default_client_prevent_user_existence_errors)
204204
write_attributes = lookup(client, "write_attributes", var.default_client_write_attributes)
205+
access_token_validity = lookup(client, "access_token_validity", var.default_client_access_token_validity)
206+
id_token_validity = lookup(client, "id_token_validity", var.default_client_id_token_validity)
207+
token_validity_units = lookup(client, "token_validity_units", var.default_client_token_validity_units)
208+
enable_token_revocation = lookup(client, "enable_token_revocation", var.default_client_enable_token_revocation)
205209
}
206210
}
207211
}
@@ -225,8 +229,20 @@ resource "aws_cognito_user_pool_client" "client" {
225229
prevent_user_existence_errors = each.value.prevent_user_existence_errors
226230
user_pool_id = aws_cognito_user_pool.user_pool[0].id
227231
write_attributes = each.value.write_attributes
228-
}
232+
access_token_validity = each.value.access_token_validity
233+
id_token_validity = each.value.id_token_validity
234+
235+
dynamic "token_validity_units" {
236+
for_each = length(each.value.token_validity_units) > 0 ? [true] : []
229237

238+
content {
239+
refresh_token = each.value.token_validity_units.refresh_token
240+
access_token = each.value.token_validity_units.access_token
241+
id_token = each.value.token_validity_units.id_token
242+
}
243+
}
244+
enable_token_revocation = each.value.enable_token_revocation
245+
}
230246
resource "aws_cognito_user_pool_domain" "domain" {
231247
count = var.module_enabled && var.domain != null ? 1 : 0
232248

variables.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,38 @@ variable "default_client_write_attributes" {
160160
default = null
161161
}
162162

163+
variable "default_client_access_token_validity" {
164+
description = "(Optional) Time limit, between 5 minutes and 1 day, after which the access token is no longer valid and cannot be used. This value will be overridden if you have entered a value in 'default_client_token_validity_units'."
165+
type = number
166+
default = null
167+
}
168+
169+
variable "default_client_id_token_validity" {
170+
description = "(Optional) Time limit, between 5 minutes and 1 day, after which the ID token is no longer valid and cannot be used. This value will be overridden if you have entered a value in 'default_client_token_validity_units'."
171+
type = number
172+
default = null
173+
}
174+
175+
variable "default_client_token_validity_units" {
176+
description = "(Optional) Configuration block for units in which the validity times are represented in."
177+
type = any
178+
default = null
179+
}
180+
181+
# Example:
182+
#
183+
# default_client_token_validity_units = {
184+
# refresh_token = "days"
185+
# access_token = "minutes"
186+
# id_token = "minutes"
187+
# }
188+
189+
variable "default_client_enable_token_revocation" {
190+
description = "(Optional) Enables or disables token revocation."
191+
type = bool
192+
default = null
193+
}
194+
163195
variable "invite_email_subject" {
164196
type = string
165197
description = "(Optional) The subject for email messages."

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ terraform {
66
required_version = ">= 0.12.20, < 2.0"
77

88
required_providers {
9-
aws = ">= 3.19, < 4.0"
9+
aws = ">= 3.32, < 4.0"
1010
}
1111
}

0 commit comments

Comments
 (0)