This section describes the authentication and authorization options for {registry} using {keycloak}.
You can enable authentication for the {registry} web console and core REST API using {keycloak}. The same {keycloak} realm and users are federated across the {registry} web console and core REST API using Open ID Connect (OIDC) so that you only require one set of credentials.
{registry} supports a number of authorization configurations, including role-based and content-based approaches. {registry} provides role-based authorization for default admin, write, and read-only user roles. {registry} also provides content-based authorization at the schema or API level, where only the creator of the registry artifact can update or delete it. {registry} authentication and authorization options are disabled by default.
-
{keycloak} is installed and running, and configured with a {keycloak} realm and a user. For more details, see
-
{registry} is installed and running.
You can set the following environment variables to configure authentication for the {registry} web console and API using {keycloak}:
Environment variable | Description | Type | Default |
---|---|---|---|
|
Enables/disables authentication in registry. When set to |
String |
|
|
The URL of the {keycloak} authentication server to use. Must end with |
String |
- |
|
The {keycloak} realm used for authentication. |
String |
- |
|
The client ID for the {registry} REST API. |
String |
|
|
The client ID for the {registry} web console. |
String |
|
Note
|
By default, {registry} supports authentication using the OpenID Connect protocol. This means that users (or API clients) must obtain an access token to make authenticated calls to the {registry} REST API. However, because some tools do not support OpenID Connect, you can also configure {registry} to support HTTP basic authentication by setting the following configuration property to true :
|
Environment variable | Java system property | Type | Default value |
---|---|---|---|
|
|
Boolean |
|
Set the following option to true
to enable role-based authorization in {registry}:
Environment variable | Java system property | Type | Default value |
---|---|---|---|
|
|
Boolean |
|
You can configure role-based authorization to use roles found in the user’s authentication token (for example, granted when authenticating using {keycloak}), or to use role mappings managed internally by {registry}.
To enable using roles assigned by {keycloak} set the following environment variables:
Environment variable | Description | Type | Default |
---|---|---|---|
|
When set to |
String |
|
|
The name of the role that indicates a user is an Admin. |
String |
|
|
The name of the role that indicates a user is a Developer. |
String |
|
|
The name of the role that indicates a user has Read Only access. |
String |
|
When {registry} is configured to use roles from {keycloak}, you must assign {registry} users to at least one of the following user roles in {keycloak} (note that the role names are configurable via the environment variables defined in the table above):
Role | Read artifacts | Write artifacts | Global rules | Description |
---|---|---|---|---|
|
Yes |
Yes |
Yes |
Full access to all create, read, update, and delete operations. |
|
Yes |
Yes |
No |
Access to create, read, update, and delete operations, except configuring global rules and import/export. This role can configure artifact rules only. |
|
Yes |
No |
No |
Access to read and search operations only. This role cannot configure any rules. |
To enable using roles managed internally by {registry}, set the following environment variables:
Environment variable | Description | Type | Default |
---|---|---|---|
|
When set to |
String |
|
When using internally managed role mappings, users can be assigned a role using the /admin/roleMappings
endpoint in the {registry} REST API. See the REST API documentation for details on how to use that API.
Users can be granted exactly one role: ADMIN
, DEVELOPER
, or READ_ONLY
. Only users with Admin
privileges can grant access to other users. Because there are no default Admin users in {registry}, it
is usually helpful to configure another way for users to be identified as admins. This admin-override
configuration can be controlled with the following environment variables:
Environment variable | Description | Type | Default |
---|---|---|---|
|
Enables the admin-override feature. |
String |
|
|
Where to look for admin-override information. Only |
String |
|
|
The type of information used to determine if a user is an admin. Values depend on the value of the FROM variable, for example, |
String |
|
|
The name of the role that indicates a user is an Admin. |
String |
|
|
The name of a JWT token claim to use for determining admin-override. |
String |
|
|
The value that the JWT token claim indicated by the CLAIM variable must be for the user to be granted admin-override. |
String |
|
For example, you can use the admin-override feature to assign the sr-admin
role to a single user
in {keycloak}, which grants that user the admin role. That user can then use the /admin/roleMappings
REST API (or associated UI) to grant roles to additional users (including additional admins).
Set the following option to true
to enable owner-only authorization for updates to schema and API artifacts in {registry}:
Environment variable | Java system property | Type | Default value |
---|---|---|---|
|
|
Boolean |
|
Enabling owner-only authorization results in a configuration where users with write access can only modify content that they themselves created. So users will not be able to update or delete artifacts created by other users.
In addition to the two main types of authorization (role-based and owner-based authorization), {registry} supports the following authorization related features.
To enable anonymous users (REST API calls with no authentication credentials provided) to be allowed to make
read-only calls to the REST API, the following option must be set to true
:
Environment variable | Java system property | Type | Default value |
---|---|---|---|
|
|
Boolean |
|
-
For an open source Docker-based example of authentication using {keycloak}, see https://github.com/Apicurio/apicurio-registry/tree/master/distro/docker-compose
-
For details on how to use {keycloak} in a production environment, see
-
For details on configuring custom authentication for {registry}, the see Quarkus Open ID Connect documentation