Skip to content

Commit

Permalink
feat: have OAuth2 Proxy refresh the access token before it expires
Browse files Browse the repository at this point in the history
I'm basing the default on our existing Cognito pools and clients. This
won't work if we need more control:

- access tokens expire after 60 minutes, so renew at 59
- refresh tokens expire after 30 days, so the default of 7 days is fine
  and I haven't made this configurable
  • Loading branch information
steveherrin committed Nov 19, 2024
1 parent cdbd064 commit 816c04f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions stack/templates/oidc_proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ spec:
- --pass-authorization-header=true
- --reverse-proxy
- --skip-jwt-bearer-tokens
- --cookie-refresh={{ .Values.oidcProxy.cookieRefresh }}

{{- range $allOIDCProtectedServces }}
- --upstream={{ . }}
Expand Down
9 changes: 7 additions & 2 deletions stack/tests/oidc_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ tests:
global:
oidcProxy:
enabled: true
cookieRefresh: 1h23m45s
skipAuth:
- method: GET
path: "/v1/api/docs2"
Expand All @@ -127,7 +128,7 @@ tests:
- documentIndex: 0
lengthEqual:
path: spec.template.spec.containers[0].args
count: 17
count: 18
- documentIndex: 0
contains:
path: spec.template.spec.containers[0].args
Expand All @@ -140,6 +141,10 @@ tests:
contains:
path: spec.template.spec.containers[0].args
content: "--skip-auth-route=/v1/api/security/access_token"
- documentIndex: 0
contains:
path: spec.template.spec.containers[0].args
content: "--cookie-refresh=1h23m45s"
- it: overwrites the name
set:
global:
Expand Down Expand Up @@ -421,7 +426,7 @@ tests:
- documentIndex: 0
lengthEqual:
path: spec.template.spec.containers[0].args
count: 21
count: 22
- documentIndex: 0
contains:
path: spec.template.spec.containers[0].args
Expand Down
7 changes: 6 additions & 1 deletion stack/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@
"default": [],
"items": {}
},
"cookieRefresh": {
"type": "string",
"description": "Refresh tokens and cookies after this period",
"default": "59m"
},
"extraArgs": {
"type": "array",
"description": "Extra arguments to pass to the OIDC proxy",
Expand Down Expand Up @@ -645,4 +650,4 @@
"default": {}
}
}
}
}
3 changes: 2 additions & 1 deletion stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ global:
# skipAuth:
# - path: "/healthz"
# method: GET

## @param global.oidcProxy.cookieRefresh Refresh tokens and cookies after this period
cookieRefresh: "59m"
## @param global.oidcProxy.extraArgs Extra arguments to pass to the OIDC proxy
extraArgs: []
# extraArgs:
Expand Down

0 comments on commit 816c04f

Please sign in to comment.