-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[jwt_parser] Ensure the policy only activate if the authentication mo…
…de is not OIDC
- Loading branch information
Showing
4 changed files
with
233 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# JWT Parser | ||
|
||
JWT Parser is used to parse the JSON Web Token (JWT) in the `Authorization` header and stores it in the request context that can be shared with other policies. | ||
|
||
If `required` flag is set to true and no JWT token is sent, APIcast will reject the request and send HTTP ``WWW-Authenticate`` response header. | ||
|
||
NOTE: Not compatible with OIDC authentication mode. When this policy is added to a service configured with OIDC authentication mode, APIcast will print a warning about the incompatibility and ignore the policy. | ||
|
||
## Example usage | ||
|
||
With `JWT Claim Check` policy | ||
|
||
``` | ||
"policy_chain": [ | ||
{ | ||
"name": "apicast.policy.jwt_parser", | ||
"configuration": { | ||
"issuer_endpoint": "http://red_hat_single_sign-on/auth/realms/foo" | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"name": "apicast.policy.jwt_claim_check", | ||
"configuration": { | ||
"error_message": "Invalid JWT check", | ||
"rules": [ | ||
{ | ||
"operations": [ | ||
{"op": "==", "jwt_claim": "role", "jwt_claim_type": "plain", "value": "admin"} | ||
], | ||
"combine_op":"and", | ||
"methods": ["GET"], | ||
"resource": "/resource", | ||
"resource_type": "plain" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
``` | ||
|
||
With `Keycloak Role Check` policy | ||
|
||
``` | ||
"policy_chain": [ | ||
{ | ||
"name": "apicast.policy.jwt_parser", | ||
"configuration": { | ||
"u": true | ||
"issuer_endpoint": "http://red_hat_single_sign-on/auth/realms/foo" | ||
} | ||
}, | ||
{ | ||
"name": "apicast.policy.keycloak_role_check", | ||
"configuration": { | ||
"scopes": [ | ||
{ | ||
"realm_roles": [ { "name": "foo" } ], | ||
"resource": "/confidential" | ||
} | ||
] | ||
} | ||
}, | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters