-
Notifications
You must be signed in to change notification settings - Fork 71
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
REST proxy SASL OIDC authentication #731
REST proxy SASL OIDC authentication #731
Conversation
c4bd613
to
f1bfc7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to producer/consumer when token expires?
Handle OAuth/OIDC (Bearer token) auth headers, and use them when instantiating Kafka clients (with the exception of backups for now). Basic authentication behaviour is unchanged, just extracted and unittested.
f1bfc7e
to
b19cf19
Compare
Potentially producer and consumer clients could go into a retry-loop until the idle proxy janitor cleans up the As discussed offline, I'll modify the current |
9029b14
to
b191fb0
Compare
1db9235
to
662078f
Compare
662078f
to
5de666d
Compare
Due to the behaviour of the Kafka clients, we want to avoid them going into a retry loop in case of an expired OAuth token. The current proxy janitor _would_ clean them up eventually but this is behaviour to be avoided. Thus the proxy janitor is extended to clean up proxies that have auth tokens expiring within a "tolerance" amount of time. To extract the expiry time (`exp` claim) from an OAuth token, the `pyjwt` library is used. With this action we do not verify the token signature (which would not be possible without knowing the signing public key). Normally this would present the issue of tokens that have been tampered with and not re-signed. However, when using a token for the first time, the Karapace REST proxy instantiates a Kafka admin client, which results in immediate verification of the token by Kafka. So even if the expiration time has been maliciously changed, the connection will be refused by Kafka, resulting in an Unauthorized response from Karapace to its client.
5de666d
to
c350775
Compare
About this change - What it does
OAuth credentials pass-through:
Authorization
header has aBearer
token, will create Kafka clients with theOAUTHBEARER
SASL mechanism and pass the token through to themProxy janitor extension:
pyjwt
is used overpython-jose
due to its smaller footprint - any future switch (eg. due to the need to actually verify credentials and use JWK) is trivial (switch dependencies, modify imports) due topython-jose
building onpyjwt
and having identical interfaces for the features added nowWhy this way
Preserve the current auth behaviour without duplicating the client creation, make the decision purely based on the incoming HTTP requests.