Chapter 5. Securing a Apicurio Registry deployment
This chapter explains how to configure security settings for your Apicurio Registry deployment on OpenShift:
- Section 5.1, “Securing Apicurio Registry using the Red Hat Single Sign-On Operator”
- Section 5.2, “Configuring Apicurio Registry authentication and authorization with Red Hat Single Sign-On”
- Section 5.3, “Configuring an HTTPS connection to Apicurio Registry from inside the OpenShift cluster”
- Section 5.4, “Configuring an HTTPS connection to Apicurio Registry from outside the OpenShift cluster”
Apicurio Registry provides authentication and authorization using Red Hat Single Sign-On based on OpenID Connect (OIDC) or HTTP basic. You can configure the required settings automatically using the Red Hat Single Sign-On Operator, or manually configure them in Red Hat Single Sign-On and Apicurio Registry.
Apicurio Registry provides role-based authentication and authorization for the Apicurio Registry web console and core REST API using Red Hat Single Sign-On. Apicurio Registry also provides content-based authorization at the schema or API level, where only the artifact creator has write access. You can also configure an HTTPS connection to Apicurio Registry from inside or outside an OpenShift cluster.
5.1. Securing Apicurio Registry using the Red Hat Single Sign-On Operator Copy linkLink copied to clipboard!
The following procedure shows how to configure a Apicurio Registry REST API and web console to be protected by Red Hat Single Sign-On. The Red Hat Single Sign-On Operator is available as a Technology Preview feature.
Technology Preview features are not supported with Red Hat production service-level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend implementing any Technology Preview features in production environments.
This Technology Preview feature provides early access to upcoming product innovations, enabling you to test functionality and provide feedback during the development process. For more information about support scope, see Technology Preview Features Support Scope.
Apicurio Registry supports the following user roles:
| Name | Capabilities |
|---|---|
|
| Full access, no restrictions. |
|
|
Create artifacts and configure artifact rules. Cannot modify global rules, perform import/export, or use |
|
|
View and search only. Cannot modify artifacts or rules, perform import/export, or use |
There is a related configuration option in the ApicurioRegistry CRD that you can use to set the web console to read-only mode. However, this configuration does not affect the REST API.
Prerequisites
- You must have already installed the Apicurio Registry Operator.
- You must install the Red Hat Single Sign-On Operator or have Red Hat Single Sign-On accessible from your OpenShift cluster.
The example configuration in this procedure is intended for development and testing only. To keep the procedure simple, it does not use HTTPS and other defenses recommended for a production environment. For more details, see the Red Hat Single Sign-On documentation.
Procedure
- In the OpenShift web console, click Installed Operators and Red Hat Single Sign-On Operator, and then the Keycloak tab.
Click Create Keycloak to provision a new Red Hat Single Sign-On instance for securing a Apicurio Registry deployment. You can use the default value, for example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Wait until the instance has been created, and click Networking and then Routes to access the new route for the keycloak instance.
-
Click the Location URL and copy the displayed
../authURL value for later use when deploying Apicurio Registry. Click Installed Operators and Red Hat Single Sign-On Operator, and click the Keycloak Realm tab, and then Create Keycloak Realm to create a
registryexample realm:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantYou must customize this
KeycloakRealmresource with values suitable for your environment if you are deploying to production. You can also create and manage realms using the Red Hat Single Sign-On web console.If your cluster does not have a valid HTTPS certificate configured, you can create the following HTTP
ServiceandIngressresources as a temporary workaround:Click Networking and then Services, and click Create Service using the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Click Networking and then Ingresses, and click Create Ingress using the following example::
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Modify the
hostvalue to create a route accessible for the Apicurio Registry user, and use it instead of the HTTPS route created by Red Hat Single Sign-On Operator.
Click the Apicurio Registry Operator, and on the ApicurioRegistry tab, click Create ApicurioRegistry, using the following example, but replace your values in the
keycloaksection.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2. Configuring Apicurio Registry authentication and authorization with Red Hat Single Sign-On Copy linkLink copied to clipboard!
This section explains how to manually configure authentication and authorization options for Apicurio Registry using Red Hat Single Sign-On.
Alternatively, for details on how to configure these settings automatically, see Section 5.1, “Securing Apicurio Registry using the Red Hat Single Sign-On Operator”.
You can enable authentication for the Apicurio Registry web console and core REST API using Red Hat Single Sign-On based on OAuth using OpenID Connect (OIDC). The same Red Hat Single Sign-On realm and users are federated across the Apicurio Registry web console and core REST API using OpenID Connect so that you only require one set of credentials.
Apicurio Registry provides role-based authorization for default admin, write, and read-only user roles. Apicurio 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. Apicurio Registry authentication and authorization settings are disabled by default.
Prerequisites
- Red Hat Single Sign-On is installed and running. For more details, see the Red Hat Single Sign-On user documentation.
- Apicurio Registry is installed and running.
Procedure
-
In the Red Hat Single Sign-On Admin Console, create a Red Hat Single Sign-On realm for Apicurio Registry. By default, Apicurio Registry expects a realm name of
registry. For more details on creating realms, see the Red Hat Single Sign-On user documentation. Create a Red Hat Single Sign-On client for the Apicurio Registry API. By default, Apicurio Registry expects the following settings:
-
Client ID:
registry-api -
Client Protocol:
openid-connect Access Type:
bearer-onlyYou can use the defaults for the other client settings.
NoteIf you are using Red Hat Single Sign-On service accounts, the client Access Type must be
confidentialinstead ofbearer-only.
-
Client ID:
Create a Red Hat Single Sign-On client for the Apicurio Registry web console. By default, Apicurio Registry expects the following settings:
-
Client ID:
apicurio-registry -
Client Protocol:
openid-connect -
Access Type:
public -
Valid Redirect URLs:
http://my-registry-url:8080/* Web Origins:
+You can use the defaults for the other client settings.
-
Client ID:
In your Apicurio Registry deployment on OpenShift, set the following Apicurio Registry environment variables to configure authentication using Red Hat Single Sign-On:
Expand Table 5.2. Configuration for Apicurio Registry authentication Environment variable Description Type Default AUTH_ENABLEDIf set to
true, the environment variables that follow are required.String
falseKEYCLOAK_URLThe URL of the Red Hat Single Sign-On authentication server to use. Must end with
/auth.String
None
KEYCLOAK_REALMThe Red Hat Single Sign-On realm used for authentication.
String
registryKEYCLOAK_API_CLIENT_IDThe client ID for the Apicurio Registry REST API.
String
registry-apiKEYCLOAK_UI_CLIENT_IDThe client ID for the Apicurio Registry web console.
String
apicurio-registryTipFor an example of setting environment variables on OpenShift, see Section 6.1, “Configuring Apicurio Registry health checks on OpenShift”.
Set the following option to
trueto enable Apicurio Registry user roles in Red Hat Single Sign-On:Expand Table 5.3. Configuration for Apicurio Registry user roles Environment variable Java system property Type Default value ROLES_ENABLEDregistry.auth.roles.enabledBoolean
falseWhen Apicurio Registry user roles are enabled, you must assign Apicurio Registry users to at least one of the following default user roles in your Red Hat Single Sign-On realm:
Expand Table 5.4. Default user roles for registry authentication and authorization Role Read artifacts Write artifacts Global rules Summary sr-adminYes
Yes
Yes
Full access to all create, read, update, and delete operations.
sr-developerYes
Yes
No
Access to create, read, update, and delete operations, except configuring global rules. This role can configure artifact rules.
sr-readonlyYes
No
No
Access to read and search operations only. This role cannot configure any rules.
Set the following to
trueto enable owner-only authorization for updates to schema and API artifacts in Apicurio Registry:Expand Table 5.5. Configuration for owner-only authorization Environment variable Java system property Type Default value REGISTRY_AUTH_OWNER_ONLY_AUTHORIZATIONregistry.auth.owner-only-authorizationBoolean
false
5.3. Configuring an HTTPS connection to Apicurio Registry from inside the OpenShift cluster Copy linkLink copied to clipboard!
The following procedure shows how to configure Apicurio Registry deployment to expose a port for HTTPS connections from inside the OpenShift cluster.
This kind of connection is not directly available outside of the cluster. Routing is based on hostname, which is encoded in the case of an HTTPS connection. Therefore, edge termination or other configuration is still needed. See Section 5.4, “Configuring an HTTPS connection to Apicurio Registry from outside the OpenShift cluster”.
Prerequisites
- You must have already installed the Apicurio Registry Operator.
Procedure
Generate a
keystorewith a self-signed certificate. You can skip this step if you are using your own certificates.keytool -genkey -trustcacerts -keyalg RSA -keystore registry-keystore.jks -storepass password
keytool -genkey -trustcacerts -keyalg RSA -keystore registry-keystore.jks -storepass passwordCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new secret to hold the keystore and keystore password.
- In the left navigation menu of the OpenShift web console, click Workloads > Secrets > Create Key/Value Secret.
Use the following values:
Name:registry-keystore
Key 1:keystore.jks
Value 1: registry-keystore.jks (uploaded file)
Key 2:password
Value 2: passwordNoteIf you encounter a
java.io.IOException: Invalid keystore format, the upload of the binary file did not work properly. As an alternative, encode the file as a base64 string usingcat registry-keystore.jks | base64 -w0 > data.txtand edit the Secret resource as yaml to manually add the encoded file.
Edit the Deployment resource of the Apicurio Registry instance. You can find the correct name in a status field of the Apicurio Registry Operator.
Add the keystore secret as a volume:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a volume mount:
volumeMounts: - name: registry-keystore-secret-volume mountPath: /etc/registry-keystore readOnly: truevolumeMounts: - name: registry-keystore-secret-volume mountPath: /etc/registry-keystore readOnly: trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add
JAVA_OPTIONSandKEYSTORE_PASSWORDenvironment variables:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteOrder is important when using string interpolation.
Enable the HTTPS port:
ports: - containerPort: 8080 protocol: TCP - containerPort: 8443 protocol: TCPports: - containerPort: 8080 protocol: TCP - containerPort: 8443 protocol: TCPCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Edit the Service resource of the Apicurio Registry instance. You can find the correct name in a status field of the Apicurio Registry Operator.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the connection is working:
Connect into a pod on the cluster using SSH (you can use the Apicurio Registry pod):
oc rsh -n default example-apicurioregistry-deployment-vx28s-4-lmtqb
oc rsh -n default example-apicurioregistry-deployment-vx28s-4-lmtqbCopy to Clipboard Copied! Toggle word wrap Toggle overflow Find the cluster IP of the Apicurio Registry pod from the Service resource (see the Location column in the web console). Afterwards, execute a test request (we are using self-signed certificate, so an insecure flag is required):
curl -k https://172.30.209.198:8443/health [...]
curl -k https://172.30.209.198:8443/health [...]Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.4. Configuring an HTTPS connection to Apicurio Registry from outside the OpenShift cluster Copy linkLink copied to clipboard!
The following procedure shows how to configure Apicurio Registry deployment to expose an HTTPS edge-terminated route for connections from outside the OpenShift cluster.
Prerequisites
- You must have already installed the Apicurio Registry Operator.
- Read the OpenShift documentation for creating secured routes.
Procedure
Add a second Route in addition to the HTTP route created by the Apicurio Registry Operator. See the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteMake sure the
insecureEdgeTerminationPolicy: Redirectconfiguration property is set.If you do not specify a certificate, OpenShift will use a default. You can alternatively generate a custom self-signed certificate using the following commands:
openssl genrsa 2048 > host.key && openssl req -new -x509 -nodes -sha256 -days 365 -key host.key -out host.cert
openssl genrsa 2048 > host.key && openssl req -new -x509 -nodes -sha256 -days 365 -key host.key -out host.certCopy to Clipboard Copied! Toggle word wrap Toggle overflow and then create a route using the OpenShift CLI:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow