Certificate role based authorization in Apache Bookkeeper. #2429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This feature allows a predefined set of services to be 'whitelisted' to be able to access bookkeeper based on their client certificates. This feature is disabled by default.
Motivation
As BookKeeper and its supported services move to a cloud friendly service based architecture, it becomes of utmost importance to monitor and allow only certain qualified services to be able to access the data in BK.
We have TLS based authentication, however, any service with the rootCA can access Bookkeeper clusters which is not desirable.
Changes
To enable if, we have to set 2 configuration options in server config.
Set
bookieAuthProviderFactoryClass
config option to use BookieAuthZFactorybookieAuthProviderFactoryClass=org.apache.bookkeeper.tls.BookieAuthZFactory
Set
authorizedRoles
to a comma separated list of roles present in client certificates' OU field.authorizedRoles=pulsar-broker-1,pulsar-broker-2
Read further for details on how to implement these in your client certificates and how to wire it up.
So this feature can be broken down into two parts:
Details:
Certificate and roles:
Here is an example of how the SUBJECT field of a final certificate for Apache Pulsar running in the cloud would look like:
This shows that this bookkeeper client certificate is owned by the apache pulsar service has the role ‘pulsar-broker-role’ for entities in ‘cluster-1’.
Only those services with pulsar-broker-role should be able to access it.
We can add more fields separated by commas to increase the upstream application clusters to be able to access this bookkeeper cluster.
For example:
OU=0:herddb-readonlyNode,herddb-readwriteNode;1:herddb-cluster2
Such separation of access based on services is paramount to keeping this secure as many upstream users of BookKeeper are financial institutions, databases and other services.
Server configuration for authorized roles
Once we have a certificate whose SUBJECT field has the OU attribute with the roles we want to authorize, on the Bookie side, we need to specify which roles are allowed.
We make this happen by introducing a server configuration option called
authorizedRoles
.Since we have only static options, this will be set in stone as long as the bookie booted up with it.
If in case we need to change the allowed roles, we’ll need to stop the bookie, update the configuration file and then restart the bookie.
We can have multiple roles which are authorized as the OU field can have multiple comma separated values for roles.
This is a redo of stale PR #2355
Master Issue: #2354