第5章 Apicurio Registry デプロイメントの保護
Apicurio Registry は、OpenID Connect (OIDC) および HTTP Basic をベースとする Red Hat Single Sign-On を使用して、認証および認可を行います。Red Hat Single Sign-On Operator を使用して必要な設定を自動的に設定するか、Red Hat Single Sign-On および Apicurio Registry で手動で設定する必要があります。
Apicurio Registry は、OpenID Connect (OIDC) と OAuth 認可コードフローをベースとする Microsoft Azure Active Directory を使用した認証と認可も行います。Azure AD および Apicurio Registry で、必要な設定を手動で行えます。
Apicurio Registry は、Red Hat Single Sign-On または Azure AD を使用したロールベースの認可オプションに加えて、アーティファクト作成者のみが書き込み権限を持つ、スキーマまたは API レベルでのコンテンツベースの認可も提供します。OpenShift クラスターの内部または外部から Apicurio Registry への HTTPS 接続を設定することもできます。
この章では、OpenShift 上の Apicurio Registry デプロイメントで、次のセキュリティーオプションを設定する方法について説明します。
- 「Red Hat Single Sign-On Operator を使用した Apicurio Registry の保護」
- 「Red Hat Single Sign-On を使用した Apicurio Registry の認証と認可の設定」
- 「Microsoft Azure Active Directory を使用した Apicurio Registry の認証と認可の設定」
- 「Apicurio Registry の認証および認可の設定オプション」
- 「OpenShift クラスター内から Apicurio Registry への HTTPS 接続の設定」
- 「OpenShift クラスター外から Apicurio Registry への HTTPS 接続の設定」
関連情報
Java クライアントアプリケーションのセキュリティー設定の詳細は、以下を参照してください。
5.1. Red Hat Single Sign-On Operator を使用した Apicurio Registry の保護
次の手順は、Red Hat Single Sign-On によって保護されるように Apicurio Registry REST API と Web コンソールを設定する方法を示しています。
Apicurio Registry は、次のユーザーロールをサポートしています。
名前 | 機能 |
---|---|
| 完全なアクセス。制限はありません。 |
|
アーティファクトを作成し、アーティファクトルールを設定します。グローバルルールの変更、インポート/エクスポートの実行、 |
|
表示と検索のみ。アーテファクトやルールの変更、インポート/エクスポートの実行、 |
ApicurioRegistry
CRD には、Web コンソールを読み取り専用モードに設定するために使用できる関連する設定オプションがあります。ただし、この設定は REST API には影響しません。
前提条件
- Apicurio Registry Operator がインストールされている。
- Red Hat Single Sign-On Operator をインストールするか、OpenShift クラスターからアクセスできる Red Hat Single Sign-On が必要です。
この手順の設定例は、開発およびテストのみを目的としています。手順を単純にするために、実稼働環境で推奨される HTTPS やその他のセキュリティーは使用しません。詳細は、Red Hat Single Sign-On のドキュメントを参照してください。
手順
- OpenShift Web コンソールで、Installed Operators および Red Hat Single Sign-On Operator をクリックし、Keycloak タブをクリックします。
Create Keycloak をクリックし、Apicurio Registry デプロイメントのセキュリティーを保護するために、新しい Red Hat Single Sign-On インスタンスをプロビジョニングします。デフォルト値を使用できます。以下に例を示します。
apiVersion: keycloak.org/v1alpha1 kind: Keycloak metadata: name: example-keycloak labels: app: sso spec: instances: 1 externalAccess: enabled: True podDisruptionBudget: enabled: True
- インスタンスが作成されるまで待ち、Networking をクリックした後に Routes をクリックし、keycloak インスタンスの新規ルートにアクセスします。
- Location URL をクリックし、表示された URL 値をコピーして、後で Apicurio Registry のデプロイ時に使用します。
Installed Operators および Red Hat Single Sign-On Operator をクリックし、Keycloak Realm タブをクリックした後、Create Keycloak Realm をクリックして
registry
のサンプルレルムを作成します。apiVersion: keycloak.org/v1alpha1 kind: KeycloakRealm metadata: name: registry-keycloakrealm labels: app: sso spec: instanceSelector: matchLabels: app: sso realm: displayName: Registry enabled: true id: registry realm: registry sslRequired: none roles: realm: - name: sr-admin - name: sr-developer - name: sr-readonly clients: - clientId: registry-client-ui implicitFlowEnabled: true redirectUris: - '*' standardFlowEnabled: true webOrigins: - '*' publicClient: true - clientId: registry-client-api implicitFlowEnabled: true redirectUris: - '*' standardFlowEnabled: true webOrigins: - '*' publicClient: true users: - credentials: - temporary: false type: password value: changeme enabled: true realmRoles: - sr-admin username: registry-admin - credentials: - temporary: false type: password value: changeme enabled: true realmRoles: - sr-developer username: registry-developer - credentials: - temporary: false type: password value: changeme enabled: true realmRoles: - sr-readonly username: registry-user
重要実稼働環境にデプロイする場合は、ご使用の環境に適した値でこの
KeycloakRealm
リソースをカスタマイズする必要があります。Red Hat Single Sign-On Web コンソールを使用してレルムを作成および管理することもできます。クラスターに有効な HTTPS 証明書が設定されていない場合は、一時的な回避策として次の HTTP
Service
およびIngress
リソースを作成できます。Networking をクリックしてから Services をクリックし、以下の例を使用して Create Service をクリックします。
apiVersion: v1 kind: Service metadata: name: keycloak-http labels: app: keycloak spec: ports: - name: keycloak-http protocol: TCP port: 8080 targetPort: 8080 selector: app: keycloak component: keycloak type: ClusterIP sessionAffinity: None status: loadBalancer: {}
Networking をクリックしてから Ingresses をクリックし、以下の例を使用して Create Ingress をクリックします。
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: keycloak-http labels: app: keycloak spec: rules: - host: KEYCLOAK_HTTP_HOST http: paths: - path: / pathType: ImplementationSpecific backend: service: name: keycloak-http port: number: 8080
host
の値を変更して、Apicurio Registry ユーザーがアクセスできるルートを作成し、Red Hat Single Sign-On Operator によって作成された HTTPS ルートの代わりにこれを使用します。
Apicurio Registry Operator をクリックし、以下の例のように ApicurioRegistry タブをクリックして Create ApicurioRegistry をクリックしますが、
keycloak
セクションの値を置き換えます。apiVersion: registry.apicur.io/v1 kind: ApicurioRegistry metadata: name: example-apicurioregistry-kafkasql-keycloak spec: configuration: security: keycloak: url: "http://keycloak-http-<namespace>.apps.<cluster host>" # ^ Required # Use an HTTP URL in development. realm: "registry" # apiClientId: "registry-client-api" # ^ Optional (default value) # uiClientId: "registry-client-ui" # ^ Optional (default value) persistence: 'kafkasql' kafkasql: bootstrapServers: '<my-cluster>-kafka-bootstrap.<my-namespace>.svc:9092'