-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Used a "JWT token exchange" concept to allow access to the "Queues Admin", considering an IDIR(Ministry) user already authenticated and with a specific role. > A JWT (JSON Web Token) exchange is a process where an existing JWT is used to obtain a new JWT, often with different claims or for accessing different resources. _Note:_ Keycloak has a [token exchange preview feature](https://www.keycloak.org/securing-apps/token-exchange) that seems what was needed but is not enabled right now. Also, it would be possible to use our Keycloak js lib and authenticate a second token, but it does not seem to be recommendable and the current approach of SIMS-API issuing a token seems good enough for now. The SIMS-API will allow access to a specific endpoint `users/queue-admin-token-exchange`, protected under a Ministry role (`aest-queue-dashboard-admin`), to generate a cookie with a SIMS-API issued token where its sole purpose is to allow access to the "Queues Admin". Queues admin is now able to validate the generated token based on a shared secret between the SIMS-API and queue-consumers that allows the token to be signed and validated. This token is saved in a cookie that will also be accessible by the "Queues Admin", allowing its validation. The token has the security properties sets (`httpOnly`, `secure`, and `sameSite`) to prevent different security vulnerabilities. Some of those must be relaxed for local development only. _Note:_ `credentials: true` was added under the `app.enableCors` to allow the generated cookie to be saved on the client, otherwise `Axios` would not save it. Please see below an example of what the generated token looks like, the known [registered claims](https://auth0.com/docs/secure/tokens/json-web-tokens/json-web-token-claims#registered-claims) were used. ```json { "iss": "sims-api", "sub": "some-user-guid@idir", "aud": "queues-dashboard", "iat": 1739839795, "exp": 1739839915 } ``` The new way of accessing the "Queues Admin" is using the new link in the Ministry portal. Once accessed, it will generate the token to allow the user to access the queues dashboard. The new Ministry role (`aest-queue-dashboard-admin`) is intended to show/hide the button to avoid confusion to other users since this is supposed to be accessible to only a few users.  ## Possible next steps - Share some API minor utils for the access log. - Add a GUID to the token to allow a "session" control using a shared resource (like Redis), to invalidate the cookie after a few minutes of inactivity. ## Notes on secret generation The secret key to be saved to the GitHub should be generated using some strong random generator, for instance, executing the `openssl rand -base64 32`. The value should be sent to the PODs as base64 which means it should be added to GitHub secrets as a base64 string.
- Loading branch information
1 parent
147bbc0
commit dddb903
Showing
37 changed files
with
471 additions
and
67 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ export FORMIO_SOURCE_REPO_TAG := $(or $(FORMIO_SOURCE_REPO_TAG), v4.3.0) | |
export FORMIO_ROOT_EMAIL := $(or ${FORMIO_ROOT_EMAIL}, [email protected]) | ||
export MONGODB_URI := $(or ${MONGODB_URI}, $$MONGODB_URI) | ||
export QUEUE_PREFIX := $(or $(QUEUE_PREFIX), {sims-local}) | ||
export QUEUE_DASHBOARD_TOKEN_EXPIRATION_SECONDS := $(or $(QUEUE_DASHBOARD_TOKEN_EXPIRATION_SECONDS), 3600) | ||
|
||
export MAX_WAIT=300 # Maximum wait time in seconds. | ||
export WAIT_TIME=0 # Initialize wait time to zero. | ||
|
@@ -192,6 +193,8 @@ init-secrets: | |
-p ZEEBE_CLIENT_SECRET=$(ZEEBE_CLIENT_SECRET) \ | ||
-p CAMUNDA_OAUTH_URL=$(CAMUNDA_OAUTH_URL) \ | ||
-p ZEEBE_GRPC_WORKER_LONGPOLL_SECONDS=$(ZEEBE_GRPC_WORKER_LONGPOLL_SECONDS) \ | ||
-p QUEUE_DASHBOARD_TOKEN_SECRET=$(QUEUE_DASHBOARD_TOKEN_SECRET) \ | ||
-p QUEUE_DASHBOARD_TOKEN_EXPIRATION_SECONDS=$(QUEUE_DASHBOARD_TOKEN_EXPIRATION_SECONDS) \ | ||
-p CAS_BASE_URL=$(CAS_BASE_URL) \ | ||
-p CAS_CLIENT_ID=$(CAS_CLIENT_ID) \ | ||
-p CAS_CLIENT_SECRET=$(CAS_CLIENT_SECRET) \ | ||
|
@@ -335,6 +338,7 @@ deploy-api: | |
test -n "$(ATBC_ENDPOINT)" | ||
test -n "$(API)" | ||
test -n "$(API_SECRET_NAME)" | ||
test -n "$(HOST)" | ||
test -n "$(SWAGGER_NAME)" | ||
test -n "$(QUEUE_PREFIX)" | ||
test -n "$(API_PORT)" | ||
|
@@ -370,7 +374,8 @@ deploy-api: | |
-p TLS_CERTIFICATE=$(TLS_CERTIFICATE) \ | ||
-p TLS_KEY=$(TLS_KEY) \ | ||
-p TLS_CA_CERTIFICATE=$(TLS_CA_CERTIFICATE) \ | ||
-p ALLOW_BETA_USERS_ONLY=$(ALLOW_BETA_USERS_ONLY) \ | ||
-p ALLOW_BETA_USERS_ONLY=$(ALLOW_BETA_USERS_ONLY) \ | ||
-p QUEUE_DASHBOARD_BASE_URL=https://$(HOST) \ | ||
| oc -n $(NAMESPACE) apply -f - | ||
$(call rollout_and_wait,deployment/$(API)) | ||
|
||
|
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
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
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
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
Oops, something went wrong.