-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(jans-cedarling): implement new bootstrap configs for JWT validation #10306
Conversation
- implement the NewJwtConfig which contains the updated bootstrap properties and some helper methods for initialization. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
…module Removed example docstring in a private module due to test failures. The examples could not import the necessary structs because they are private, causing `cargo test` to fail. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
- remove AccessTokenValidationConfig - remove UserinfoTokenValidationConfig - remove IdTokenValidationConfig Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
… and TrustedIssuer - Added `new_from_jwkset` method to initialize `JwkStore` from a JWK set. - Added `new_from_trusted_issuer` method to initialize `JwkStore` using a TrustedIssuer. - Implemented `get` method to easily fetch keys by Key ID. - Added support for storing and handling keys without Key IDs. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
…le validators - refactor the JwtValidator startup process to support reusing existing validators, reducing redundant initialization and improving performance. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
- implement new_from_config for NewJwtService - implement process_tokens for NewJwtService Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
…esult - Implement returning TrustedIssuer information with the JWT validation result to be able to find the mappings used for Cedar easily. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
…nfig - remove local jwks and trusted issuers from NewJwtConfig. - local jwks and trusted issuers should be passed separately via the new_with_local_jwks or new_with_trusted_issuers functions. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
- allow initialization of JwtValidator even if there's no JWKS or trusted issuer provided as long as signature validator is turned off. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
- Change process_token's result to be DecodeTokensResult so it would be compatible with the existing calls. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
- implement returning a reference to the TrustedIssuer when decoding without signature validation - implement checking if the scheme of the token's `iss` is `https` Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
DryRun Security SummaryThe provided code changes focus on enhancing the security and reliability of the Cedarling application, with updates to JWT validation, authorization configuration, logging and monitoring, error handling, and secure coding practices. Expand for full summarySummary: The provided code changes cover a variety of updates and improvements across the Cedarling application, with a strong focus on enhancing the security and reliability of the application's core functionality. The changes include:
Overall, the code changes in this pull request appear to be focused on enhancing the security and reliability of the Cedarling application, with a particular emphasis on the handling of authentication, authorization, and logging functionality. These improvements are essential for maintaining the security posture of the application and protecting it from potential vulnerabilities. Files Changed:
Code AnalysisWe ran |
Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com>
Signed-off-by: John Anderson <john@gluu.org>
…ion (#10306) * feat(jans-cedarling): implement NewJwtConfig - implement the NewJwtConfig which contains the updated bootstrap properties and some helper methods for initialization. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * refactor(jans-cedarling): move HttpClient and it's tests closer to root Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): implement loading JWKS for NewJwtService Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): remove failing example docstring from private module Removed example docstring in a private module due to test failures. The examples could not import the necessary structs because they are private, causing `cargo test` to fail. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): update a docstring in NewJwtConfig Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): remove unused structs - remove AccessTokenValidationConfig - remove UserinfoTokenValidationConfig - remove IdTokenValidationConfig Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): enhance JwkStore to support loading from JwkSet and TrustedIssuer - Added `new_from_jwkset` method to initialize `JwkStore` from a JWK set. - Added `new_from_trusted_issuer` method to initialize `JwkStore` using a TrustedIssuer. - Implemented `get` method to easily fetch keys by Key ID. - Added support for storing and handling keys without Key IDs. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): implement a new KeyService Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): start new implementation for token Validator Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): simplify JwtValidatorConfig Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): implement new check_missing_claims function Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): gracefully handle JWKS with unsupported algs Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): optimize JwtValidator initialization for reusable validators - refactor the JwtValidator startup process to support reusing existing validators, reducing redundant initialization and improving performance. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): implement init and process for NewJwtService - implement new_from_config for NewJwtService - implement process_tokens for NewJwtService Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): return TrustedIssuer info with jwt validation result - Implement returning TrustedIssuer information with the JWT validation result to be able to find the mappings used for Cedar easily. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * refactor(jans-cedarling): remove local jwks and issuers from NewJwtConfig - remove local jwks and trusted issuers from NewJwtConfig. - local jwks and trusted issuers should be passed separately via the new_with_local_jwks or new_with_trusted_issuers functions. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * refactor(jans-cedarling): add back local jwks into NewJwtConfig Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): add NewJwtService to ServiceFactory Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): enhance JwtValidator initialization - allow initialization of JwtValidator even if there's no JWKS or trusted issuer provided as long as signature validator is turned off. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): add NewJwtService to AuthzConfig Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): change process_tokens's result - Change process_token's result to be DecodeTokensResult so it would be compatible with the existing calls. Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * feat(jans-cedarling): enchance JwtValidator implementation - implement returning a reference to the TrustedIssuer when decoding without signature validation - implement checking if the scheme of the token's `iss` is `https` Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * refactor(jans-cedarling): replace old JwtService implementation with new Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): rename JwtServiceError to JwtProcessingError Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): rename DecodeTokensResult to ProcessTokensResult Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * docs(jans-cedarling): update jwt/README.md Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): remove unnecessary println! calls Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): delete unused files Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): add copyright information on top of files Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * docs(jans-cedarling): update cedarling-properties.md Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): resolve clippy issue with elided lifetime Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> * chore(jans-cedarling): minor spelling corrections Signed-off-by: John Anderson <john@gluu.org> --------- Signed-off-by: rmarinn <34529290+rmarinn@users.noreply.github.com> Signed-off-by: John Anderson <john@gluu.org> Co-authored-by: John Anderson <john@gluu.org>
Prepare
Description
This PR adds the implementation of the new bootstrap config items onto the
JwtService
.Target issue
target issue #10142
closes #10142
Implementation Details
The
JwtService
now has implementations to handle the following bootstrap configs:CEDARLING_AT_ISS_VALIDATION
: When enabled, the iss claim must be present in access token and the scheme must be https.CEDARLING_AT_JTI_VALIDATION
: When enabled, the jti claim must be present in access token.CEDARLING_AT_NBF_VALIDATION
When enabled, the nbf claim must be present in access token and the Cedarling should verify that the current date is after the nbf.CEDARLING_AT_EXP_VALIDATION
When enabled, the exp claim must be present and not past the date specified.CEDARLING_IDT_ISS_VALIDATION
When enabled, the iss claim must be present in id_token and the scheme must be https.CEDARLING_IDT_SUB_VALIDATION
When enabled, the sub claim must be present in id_token.CEDARLING_IDT_EXP_VALIDATION
When enabled, the exp claim must be present and not past the date specified.CEDARLING_IDT_IAT_VALIDATION
When enabled, the iat claim must be present in id_token.CEDARLING_IDT_AUD_VALIDATION
When enabled, the aud claim must be present in id_token.CEDARLING_USERINFO_ISS_VALIDATION
When enabled, the iss claim must be present and the scheme must be https.CEDARLING_USERINFO_SUB_VALIDATION
When enabled, the sub claim must be present in Userinfo JWT.CEDARLING_USERINFO_AUD_VALIDATION
When enabled, the aud claim must be present in Userinfo JWT.CEDARLING_USERINFO_EXP_VALIDATION
When enabled, the exp claim must be present and not past the date specified.CEDARLING_ID_TOKEN_TRUST_MODE
Strict | None. Varying levels of validations based on the preference of the developer. Strict mode requires (1) id_token's aud matches the access_token's client_id; (2) if a Userinfo token is present, the sub matches the id_token, and that the aud matches the access token client_id.A refactor was done with the
JwtService
's internals but it's usage is unchanged.Test and Document the changes
Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with
docs:
to indicate documentation changes or if the below checklist is not selected.