Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(jans-cedarling): make all tokens optional when calling Cedar…
…ling::authorize (#10436) * refactor(jans-cedarling): make process_tokens params optional - make the `access_token` param for the JwtService::process_tokens optional - make the `id_token` param for the JwtService::process_tokens optional - return an `Unimplemented` error when any `None` is passed in for the tokens since the `authz` module doesn't support optional params yet. Signed-off-by: rmarinn <[email protected]> * feat(jans-cedarling): implement processing single tokens - implement JwtService::process_token which decodes and optionally validates a single JWT. Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): replace jwt validation implementation - replace the old jwt validation implementation that needs multiple tokens at once with the new implementation which validates the tokens one at a time. Signed-off-by: rmarinn <[email protected]> * feat(jans-cedarling): make tokens optional when calling authorize - implement allowing passing `None` for some tokens when calling authorize. Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): make creation of workload entity optional Signed-off-by: rmarinn <[email protected]> * fix(jans-cedarling): user and role entity creation Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): make creation of user entity optional Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): use if-else instead of match for bool Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): improve functionality for decoded JWTs implement convenience function for getting the following data from a decoded JWT: - metadata - user_mapping - claim_mapping - role_mapping - logging_info Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): removed unused functions for TrustedIssuer Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): improve create_workload_entity func implemenation - change order for creating workload entities to: id_token then access_token - improve `create_workload` error handling - renamed `CedarPolicyCreateTypeError` to `CreateCedarEntityError` Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): improve create_user_entity func implemenation - change order for creating workload entities to: id_token, access_token, then userinfo_token - improve `create_user_entitiy` error handling Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): resolve clippy issues Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): error check when loading bootstrap config - Error when both `CEDARLING_USER_AUTHZ` and `CEDARLING_WORKLOAD_AUTHZ` are disabled. Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): add new fields to TokenEntityMetadata - add `trusted` and `principal_identifier` to the TokenEntityMetadata struct so all tokens have access to them. Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): remove some cloning when logging authz Signed-off-by: rmarinn <[email protected]> * test(jans-cedarling): add unit tests for entity creation - add tests for creating user entity - add tests for creating workload entity Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): improve error handling for entity creation - errors that occur because no tokens were available should now be tracable when creating user and workload entities Signed-off-by: rmarinn <[email protected]> * test(jans-cedarling): update python tests expected error Signed-off-by: rmarinn <[email protected]> * feat(jans-cedarling): make tokens optional in the python binding Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): change error message to start with a lowercase letter Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): flattened `use` statements for readability Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): remove unused JwtProcessingError variant Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): simplify iterator creation Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): make workload entity creation optional Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): make user entity creation optional Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): remove outdated comment Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): convert Token into a struct from an enum Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): unify token entity creation logic - combine `entities::create_<token_kind>_token` functions into a single, unified function. - prevent incorrect token types from creating entities of the wrong kind (e.g., using access_tokens to create id_token entities). - simplify logic and enforce stricter type safety for token-to-entity mapping. Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): eliminate access_token from user entity creation - remove the use of access_token in the create_user_entity function - simplify the user entity creation process. Signed-off-by: rmarinn <[email protected]> * fix(jans-cedarling): field name conflict for serializing/deserializing - fix field name conflict by using serde_rename for UserAuthorizeInfo and WorkloadAuthorizeInfo Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): remove unused commented code Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): token priority when creating userinfo entity - change the token priority when creating the userinfo entity to be 1. userinfo_token then 2. id_token Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): resolve clippy issues Signed-off-by: rmarinn <[email protected]> * test(jans-cedarling): update expected error in python bindings test Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): implement rename for logging info fields - rename UserAuthorizeInfo.principal to user_principal - rename UserAuthorizeInfo.diagnostics to user_diagnostics - rename UserAuthorizeInfo.decision to user_decision - rename WorkloadAuthorizeInfo.principal to workload_principal - rename WorkloadAuthorizeInfo.diagnostics to workload_diagnostics - rename WorkloadAuthorizeInfo.decision to workload_decision Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): run cargo fmt and add missing license headers Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): rename the Vec of role from `role` to `roles` Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): remove unused function Signed-off-by: rmarinn <[email protected]> * refactor(jans-cedarling): rename UserAuthorizeInfo fields - change `user` to `person` Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): run cargo fmt Signed-off-by: rmarinn <[email protected]> * chore(jans-cedarling): refactor to avoid unnecessary cloning Signed-off-by: Oleh Bohzok <[email protected]> --------- Signed-off-by: rmarinn <[email protected]> Signed-off-by: Oleh Bohzok <[email protected]> Co-authored-by: Oleh Bohzok <[email protected]>
- Loading branch information