Pulsar has a pluggable authentication mechanism that currently supports 3 auth providers.
Each of them has few issues which could be summarized as:
To address these issues, this proposal plans to add a new auth provider that uses JSON Web Tokens (RFC-7519).
The compact representation of a signed JWT is a string that has three parts, each separated by a .
:
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY
The 3 parts are:
subject
(user identifier or principal), expiration
, etc.. Any kind of info can be attached when creating a token and used later during the validationThe main properties of JSON Web Tokens are:
Note: the TCP connection between client and broker is still expected to be protected by TLS encryption. That is because the token shouldn't be sent in clear text over the wire.
We need to provide tools to allow an administrator to create the secret key and the tokens for the users.
For example:
pulsar tokens create --key $SECRET_KEY --subject new-user-id
This will generate a new token and print it on console. This will be done by administrator (or some automated service) and the token will be passed to client.
Similarly, administrator will be able to create the secret key to bootstrap the tokens generation:
pulsar tokens create-secret-key
From client library perspective, a new AuthenticationProvider will be added that will support taking token and pass that directly to broker on connection. Client plugin will not interpret the token in any form, rather just treat it as an opaque string.
This will ensure that multiple tokens format can be used if required.
Additionally the AuthenticationProvider
will allow the application to pass a Supplier<String>
to give the opportunity to fetch the token from some config or secret store.
AuthenticationProvider in Broker will receive the token and validate that with the secret key.
The secret key will be either provided in broker.conf
or a special class implementing Supplier<String>
will be specified to fetch the secret key from config or secret store.