diff --git a/website/content/docs/connect/config-entries/jwt-provider.mdx b/website/content/docs/connect/config-entries/jwt-provider.mdx index 273ebf16f14f..e9bcd6ca4b16 100644 --- a/website/content/docs/connect/config-entries/jwt-provider.mdx +++ b/website/content/docs/connect/config-entries/jwt-provider.mdx @@ -101,50 +101,54 @@ When every field is defined, a JWT provider configuration entry has the followin Kind = "jwt-provider" # required Name = "" # required Issuer = "" # required -JWKS = { # required - Local = { # cannot specify with JWKS{}.Remote - String = "" # cannot specify with JWKS{}.Remote{}.Filename - Filename = "" # cannot specify with JWKS{}.Remote{}.String - } +JSONWebKeySet = { # required + Local = { # cannot specify with JWKS{}.Remote + JWKS = "" # cannot specify with JWKS{}.Local{}.Filename + Filename = "" # cannot specify with JWKS{}.Local{}.String + } } -JWKS = { - Remote = { # cannot specify with JWKS{}.Local - URI = "" - RequestTimeoutMs = 1500 - CacheDuration = "5m" - FetchAsynchronously = false - RetryPolicy = { - NumRetries = 0 - } - } +JSONWebKeySet = { + Remote = { # cannot specify with JWKS{}.Local + URI = "" + RequestTimeoutMs = 1500 + CacheDuration = "5m" + FetchAsynchronously = false + RetryPolicy = { + NumRetries = 0 + RetryPolicyBackoff = { + BaseInterval = "1s" + MaxInterval = "10s" } + } + } +} Audiences = [""] Locations = [ - { - Header = { - Name = "" - ValuePrefix = "" - Forward = false - } - }, - { - QueryParam = { - Name = "" - } - }, - { - Cookie = { - Name = "" - } + { + Header = { + Name = "" + ValuePrefix = "" + Forward = false + } + }, + { + QueryParam = { + Name = "" } + }, + { + Cookie = { + Name = "" + } + } ] Forwarding = { - HeaderName = "" - PadForwardPayloadHeader = false + HeaderName = "" + PadForwardPayloadHeader = false } ClockSkewSeconds = 30 CacheConfig = { - Size = 0 + Size = 0 } ``` @@ -154,54 +158,58 @@ CacheConfig = { ```json { -"Kind": "jwt-provider", // required -"Name": "", // required -"Issuer": "", // required -"JWKS": { // required - "Local": { // cannot specify with JWKS.Remote - "String": "", // cannot specify with JWKS.Local.Filename - "Filename": "" // cannot specify with JWKS.Local.String + "Kind": "jwt-provider", // required + "Name": "", // required + "Issuer": "", // required + "JSONWebKeySet": { // required + "Local": { // cannot specify with JWKS.Remote + "JWKS": "", // cannot specify with JWKS.Local.Filename + "Filename": "" // cannot specify with JWKS.Local.String } -}, -"JWKS": { - "Remote": { // cannot specify with JWKS.Local - "URI": "", - "RequestTimeoutMs": "1500", - "CacheDuration": "5m", - "FetchAsynchronously": "false", - "RetryPolicy": { - "NumRetries": "0" - } + }, + "JSONWebKeySet": { + "Remote": { // cannot specify with JWKS.Local + "URI": "", + "RequestTimeoutMs": "1500", + "CacheDuration": "5m", + "FetchAsynchronously": "false", + "RetryPolicy": { + "NumRetries": "0", + "RetryPolicyBackOff": { + "BaseInterval": "1s", + "MaxInterval": "10s" } -}, -"Audiences": [""], -"Locations": [ + } + } + }, + "Audiences": [""], + "Locations": [ { - "Header": { - "Name": "", - "ValuePrefix": "", - "Forward": "false" - } + "Header": { + "Name": "", + "ValuePrefix": "", + "Forward": "false" + } }, { - "QueryParam": { - "Name":"", - } + "QueryParam": { + "Name":"", + } }, { - "Cookie": { - "Name": "" - } + "Cookie": { + "Name": "" + } } -], -"Forwarding": { - "HeaderName": "", - "PadForwardPayloadHeader": "false" -}, -"ClockSkewSeconds": "30", -"CacheConfig": { + ], + "Forwarding": { + "HeaderName": "", + "PadForwardPayloadHeader": "false" + }, + "ClockSkewSeconds": "30", + "CacheConfig": { "Size": "0" -} + } } ``` @@ -217,12 +225,12 @@ metadata: # required namespace: spec: # required issuer: - jwks: - local: # cannot specify with spec.jwks.remote - string: # cannot specify with spec.jwks.local.filename - filename: # cannot specify with spec.jwks.local.string - jwks: - remote: # cannot specify with spec.jwks.local + jsonWebKeySet: + local: # cannot specify with spec.jsonWebKeySet.remote + jwks: # cannot specify with spec.jsonWebKeySet.local.filename + filename: # cannot specify with spec.jsonWebKeySet.local.string + jsonWebKeySet: + remote: # cannot specify with spec.jsonWebKeySet.local uri: requestTimeoutMs: 1500 cacheDuration: 5m @@ -953,7 +961,7 @@ metadata: name: okta spec: issuer: okta - jwks: + jsonWebKeySet: remote: uri: https://dev-850216.okta.com/oauth2/default/v1/keys cacheDuration: 30m diff --git a/website/content/docs/connect/config-entries/service-intentions.mdx b/website/content/docs/connect/config-entries/service-intentions.mdx index 1fe1ed6bd487..4f3bb0fdf0dc 100644 --- a/website/content/docs/connect/config-entries/service-intentions.mdx +++ b/website/content/docs/connect/config-entries/service-intentions.mdx @@ -1313,3 +1313,111 @@ When using cluster peering connections, intentions secure your deployments with ``` + +### JWT validation with intentions + +The following example configures a service intention that evaluates requests when a service named `backend` receives a request from the `frontend` service. When the request is sent to the `/admin` HTTP path, a JSON Web Token provided by Okta is evaluated. In addition to the validation requirements in a separate JWT provider configuration entry, an additional check occurs to confirm that the token has either a `perms` or `role` claim with the `admin` value. If it does, the request is authorized. + +Because the intention allows requests that come from the `/` HTTP path, only requests on the `/admin` path are subject to token validation. + + + +```hcl +Kind = "service-intentions" +Name = "backend" +Sources = [ + { + Name = "frontend" + Permissions = [ + { + HTTP = { + PathExact = "/admin" + } + JWT = { + Providers = [ + { + Name = "okta" + VerifyClaims = [ + { + Path = ["perms", "role"] + Value = "admin" + } + ] + } + ] + } + }, + { + Action = "allow" + HTTP = { + PathPrefix = "/" + } + } + ] + } +] +``` + +```yaml +apiVersion: consul.hashicorp.com/v1alpha1 +kind: ServiceIntentions +metadata: + name: backend +spec: + sources: + name: frontend + permissions: + http: + pathExact: /admin + jwt: + providers: + name: okta + verifyClaims: + path: + - perms + - role + value: admin + action: allow + http: + pathPrefix: / +``` + +```json +{ + "Kind": "service-intentions", + "Name": "backend", + "Sources": [ + { + "Name": "frontend", + "Permissions": [ + { + "HTTP": { + "PathExact": "/admin" + }, + "JWT": { + "Providers": [ + { + "Name": "okta", + "VerifyClaims": [ + { + "Path": ["perms", "role"], + "Value": "admin" + } + ] + } + ] + } + }, + { + "Action": "allow", + "HTTP": { + "PathPrefix": "/" + } + } + ] + } + ] +} +``` + +