Skip to content

Commit 1bf68f3

Browse files
authored
configure jwks refresh interval (#110)
* configure jwks refresh interval Currently jwks set is only fetched at startup. This configures the jwks storage to refresh the key set. By default, the keys are freshed every hour. Signed-off-by: Mike Mason <mimason@equinix.com> * update helm docs Signed-off-by: Mike Mason <mimason@equinix.com> --------- Signed-off-by: Mike Mason <mimason@equinix.com>
1 parent a9c6b76 commit 1bf68f3

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

chart/iam-runtime-infratographer/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ iam-runtime-infratographer:
4848
4949
| Repository | Name | Version |
5050
|------------|------|---------|
51-
| https://charts.bitnami.com/bitnami | common | 2.22.0 |
51+
| https://charts.bitnami.com/bitnami | common | 2.27.0 |
5252
5353
## Values
5454
@@ -70,6 +70,7 @@ iam-runtime-infratographer:
7070
| config.events.nats.token | string | `""` | token NATS user token to use. |
7171
| config.events.nats.url | string | `""` | url NATS server url to use. |
7272
| config.jwt.issuer | string | `""` | issuer Issuer to use for JWT validation. |
73+
| config.jwt.jwksRefreshInterval | string | `"1h"` | jwksRefreshInterval sets the refresh interval for JWKS keys. |
7374
| config.jwt.jwksURI | string | `""` | jwksURI JWKS URI to use for JWT validation. |
7475
| config.permissions.discovery.check.concurrency | int | `5` | concurrency is the number of hosts to concurrently check. |
7576
| config.permissions.discovery.check.count | int | `5` | count is the number of checks to run on each host to check for connection latency. |
@@ -92,6 +93,12 @@ iam-runtime-infratographer:
9293
| image.pullPolicy | string | `"IfNotPresent"` | pullPolicy is the image pull policy for the service image |
9394
| image.repository | string | `"ghcr.io/infratographer/iam-runtime-infratographer"` | repository is the image repository to pull the image from |
9495
| image.tag | string | `""` | tag is the image tag to use. Defaults to the chart's app version |
96+
| livenessProbe.enabled | bool | `true` | enables liveness probe. |
97+
| livenessProbe.grpc.port | int | `4784` | sets the grpc health service port. |
98+
| livenessProbe.timeoutSeconds | int | `10` | |
99+
| readinessProbe.enabled | bool | `true` | enables readiness probe. |
100+
| readinessProbe.grpc.port | int | `4784` | sets the grpc health service port. |
101+
| readinessProbe.timeoutSeconds | int | `10` | |
95102
| resources | object | `{}` | resource limits & requests ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ |
96103
| restartPolicy | string | `""` | restartPolicy set to Always if using with initContainers on kube 1.29 and up with the SideContainer feature flag enabled. ref: https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/#sidecar-containers-and-pod-lifecycle |
97104
| securityContext | object | `{"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":65532}` | securityContext configures the container's security context. ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ |

chart/iam-runtime-infratographer/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ config:
1313
issuer: ""
1414
# -- jwksURI JWKS URI to use for JWT validation.
1515
jwksURI: ""
16+
# -- jwksRefreshInterval sets the refresh interval for JWKS keys.
17+
jwksRefreshInterval: 1h
1618
permissions:
1719
# -- host permissions-api host to use.
1820
host: ""

config.example.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ permissions:
2020
concurrency: 5
2121
jwt:
2222
disable: false
23-
jwksuri: https://identity-api.enterprise.dev/jwks.json
2423
issuer: https://identity-api.enterprise.dev/
24+
jwksuri: https://identity-api.enterprise.dev/jwks.json
25+
jwksrefreshinterval: 1h
2526
events:
2627
nats:
2728
url: nats://localhost:4222

internal/jwt/config.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
package jwt
22

33
import (
4+
"time"
5+
46
"github.com/spf13/pflag"
57
)
68

79
// Config represents the configuration for a JWT validator.
810
type Config struct {
9-
Disable bool
10-
Issuer string
11-
JWKSURI string
11+
Disable bool
12+
Issuer string
13+
JWKSURI string
14+
JWKSRefreshInterval time.Duration
1215
}
1316

1417
// AddFlags sets the command line flags for JWT validation.
1518
func AddFlags(flags *pflag.FlagSet) {
1619
flags.Bool("jwt.disable", false, "Disable JWT service")
1720
flags.String("jwt.issuer", "", "Issuer to use for JWT validation")
1821
flags.String("jwt.jwksuri", "", "JWKS URI to use for JWT validation")
22+
flags.Duration("jwt.jwksrefreshinterval", time.Hour, "sets the jwks refresh interval")
1923
}

internal/jwt/validator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ func NewValidator(config Config) (Validator, error) {
6464
}
6565

6666
storageOpts := jwkset.HTTPClientStorageOptions{
67-
Client: client,
67+
Client: client,
68+
RefreshInterval: config.JWKSRefreshInterval,
6869
}
6970

7071
storage, err := jwkset.NewStorageFromHTTP(jwksURL, storageOpts)

0 commit comments

Comments
 (0)