Is there a way to rotate opal master token. Any up...
# opal
p
Is there a way to rotate opal master token. Any update on the master token seems to invalidate opal connection to the server. Is there an architecture pattern available?
a
Hi @Prasenjit Roy, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
Based on the available documentation, there isn't a specific architecture pattern documented for rotating the OPAL master token without invalidating connections (1) (2) . The master token (
OPAL_AUTH_MASTER_TOKEN
) is used to generate client JWT tokens for authentication (2) . When you update the master token on the server, existing client JWTs that were generated with the old master token would become invalid, which explains why connections break . To rotate the master token, you would need to: 1. Generate new client JWT tokens using the new master token via the CLI or REST API (3) (2) 2. Update the
OPAL_CLIENT_TOKEN
environment variable on all clients with the newly generated tokens (3) 3. Restart the clients to use the new tokens You can generate a new master token using:
Copy code
opal-server generate-secret
(2) And obtain new client tokens with:
Copy code
opal-client obtain-token $OPAL_AUTH_MASTER_TOKEN --server-url=$YOUR_SERVERS_ADDRESS
Or via the REST API:
Copy code
curl --request POST '<https://opal.yourdomain.com/token>' \
--header 'Authorization: Bearer MY_MASTER_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
 "type": "client"
}'
(3) However, the documentation doesn't provide a zero-downtime rotation pattern or a way to maintain connections during the rotation process.
To learn more, see the sources I considered: [[1] OPAL Configuration Guide | OPAL](https://docs.opal.ac/getting-started/configuration) [[2] Running the Server and Client in Secure Mode](https://docs.opal.ac/getting-started/running-opal/as-python-package/secure-mode-setup) [[3] Obtain the JWT token](https://docs.opal.ac/getting-started/running-opal/run-opal-client/obtain-jwt-token)
d
Hi @Prasenjit Roy, the AI gave a good answer. What are you trying to achieve? Why do you want to rotate the master token?
p
As part of security policies all secrets are rotated frequently. I'm looking at options to rotate it in production environments without any downtime.
d
Understood - there is no graceful way to rotate the token. However you could write a script to generate a new token periodically in production. But you will run into JWT issues of clients with the old token. To get around this, your clients will also need to call
/token
endpoint so they dont run into authorization errors. @Thomas, can you shed any light?
o
This is simply a missing feature. @Prasenjit Roy You're welcome to contribute an API that would allow dynamically updating a token. Alternativly - you can solve it in a devops way- e.g. have a rolling update- spinning a new OPAL server and clients with new tokens, before replacing the existing ones.
p
Yep. On it. Will keep you posted.
p
Hey, thanks for reaching out ! It seems our team is a little busy right now, a human will be with you within the next hour or so. In the meantime, can I help you ?