-
Hello together, it seems, that the configuration for data sources assumes, that a JWT Token in the authorization header has no expiration time. From my understanding, a JWT or in particular Access Tokens, that are used for authentication/authorization purposes, are considered to be sensitive and therefore should mitigate misusage, for example via short expiration times. In fact, I am using Keycloak as my Authorization Server for authentication, where I also store users, groups, roles etc. I would like to use this information for policy decisions in OPA and want to use it as a data source in OPAL. To be able to fetch this data, you have to firstly obtain a JWT Token, for example via Client Credentials Flow with a Service Account against the Keycloak Authorization Server. In addition, in Keycloak you have to set an expiration date for JWT's, so to constantly be able to fetch data from Keycloak, you have to refresh expired tokens. While I think you could just set the expiration date in Keycloak to something like "100000000000000000" days, I also think this is bad practice and it unfortunately not only affects the service account, but also the JWT Tokens for authenticated users. If it would only affect the service account, this would still be bad practice for me, but would be okay, because service accounts only communicate via backends (machine to machine communication) and can't accidentally reveal JWT Tokens. I also think, if I would redeploy the Authorization Server, all previously issued JWT's are not valid anymore, so even in this scenario I would need to update the Bearer Token in the data source config. What are your thoughts on this situation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @amrap030, great questions! Let's tackle them one-by-one. TL;DROPAL cannot currently support refresh tokens natively, however there is a solution - redirecting to external data sources.
Continue reading for detailed explanations. Q: In which flows does OPAL uses tokens to fetch data?If the sources of data are protected by authentication, OPAL client can fetch data using a token (a JWT, or any other token). You may also use user-password or any other authentication mechanism by writing custom data fetchers. Tokens are relevant in two distinct cases: 1) Data updates initiated/requested by OPAL client (
|
Beta Was this translation helpful? Give feedback.
Hi @amrap030, great questions! Let's tackle them one-by-one.
TL;DR
OPAL cannot currently support refresh tokens natively, however there is a solution - redirecting to external data sources.
OPAL_DATA_CONFIG_SOURCES
which is encoded into an env var - therefore you must use long lived tokens - which violates your requirement. However,OPAL_DATA_CONFIG_SOURCES
can redirect to an external data source served by your backend, and this backend can generate short lived tokens on the …