export JWT_SIGNING_KEY=$(openssl rand -hex 32)
apiVersion: getambassador.io/v2
kind: Mapping
metadata:
name: my-service
annotations:
ambassador_cors:
origins: "*"
ambassador:
config: |
---
apiVersion: ambassador/v1
kind: Mapping
name: auth_jwt
prefix: /auth
rewrite: /auth
service: httpbin.org:8000
labels:
auth_jwt: optional
filters:
- name: jwt
config:
# Use the value of the environment variable JWT_SIGNING_KEY to validate JWT signatures.
secret: $JWT_SIGNING_KEY
# Use the JWT JSON Web Key Set (JWKS) endpoint to retrieve the signing keys.
jwks_uri: https://dev-foo.okta.com/oauth2/v1/keys
# Extract the JWT token from the Authorization header.
header: Authorization
# Only allow requests with JWTs that contain the following claims:
claims:
iss:
- https://dev-foo.okta.com/oauth2/default
aud:
- api://default
请注意,上面的示例使用Okta作为JWT提供程序,并使用“auth_jwt”作为HTTP URL前缀。
claims = jwt.decode(token, jwks_uri=self._config['jwks_uri'], audience=self._config.get('audience'))
请注意,此示例使用Python JWT库来解码JWT令牌。
通过执行上述步骤,您应该能够成功配置Ambassador Edge Stack JWT Filter与Okta令牌。