Skip to content

Commit

Permalink
add explicit token duration config for both JWTs (#1698)
Browse files Browse the repository at this point in the history
### Feature or Bugfix
<!-- please choose -->
- Enhancement

### Detail
- Add explicit token duration (60 min) over default 60 min

### Relates
- #1682 

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
  • Loading branch information
noah-paige authored Nov 15, 2024
1 parent 1f625f2 commit f3785be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions deploy/stacks/cognito.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,16 @@ def __init__(
domain_prefix=f"{resource_prefix.replace('-', '')}{envname}{self.region.replace('-', '')}{self.account}"
),
)
id_token_duration = 180 if with_approval_tests else 60
jwt_token_duration = 180 if with_approval_tests else 60
self.client = cognito.UserPoolClient(
self,
f'AppClient-{envname}',
user_pool=self.user_pool,
auth_flows=AuthFlow(user_password=with_approval_tests, user_srp=True, custom=True),
prevent_user_existence_errors=True,
refresh_token_validity=Duration.minutes(cognito_user_session_timeout_inmins),
id_token_validity=Duration.minutes(id_token_duration),
id_token_validity=Duration.minutes(jwt_token_duration),
access_token_validity=Duration.minutes(jwt_token_duration),
)

if enable_cw_rum:
Expand Down

0 comments on commit f3785be

Please sign in to comment.