Skip to content

Commit 4a7530a

Browse files
vuldinFeediver1
andauthored
Update schema registry ACL details (#1528)
Co-authored-by: Joyce Fee <102751339+Feediver1@users.noreply.github.com>
1 parent eb7b43b commit 4a7530a

2 files changed

Lines changed: 275 additions & 0 deletions

File tree

modules/manage/pages/schema-reg/schema-reg-authorization.adoc

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,212 @@ Not all Kafka operations are supported when using Redpanda Schema Registry ACLs.
196196

197197
For additional guidance on these operations, see the link:/api/doc/schema-registry/operation/operation-get_security_acls[Redpanda Schema Registry API].
198198

199+
=== Operation definitions
200+
201+
You can use the following operations to control access to Schema Registry resources:
202+
203+
* **`read`**: Allows user to read schemas and their content. Required for consuming messages that use Schema Registry, fetching specific schema versions, and reading schema content by ID.
204+
* **`write`**: Allows user to register new schemas and schema versions. Required for producing messages with new schemas and updating existing subjects with new schema versions.
205+
* **`delete`**: Allows user to delete schema versions and subjects. Required for cleanup operations and removing deprecated schemas.
206+
* **`describe`**: Allows user to list and describe Schema Registry resources. Required for discovering available subjects, listing schema versions, and viewing metadata.
207+
* **`describe_configs`**: Allows user to read configuration settings. Required for viewing compatibility settings, reading modes (IMPORT/READWRITE), and checking global or per-subject configurations.
208+
* **`alter_configs`**: Allows user to modify configuration settings. Required for changing compatibility levels, setting IMPORT mode for migrations, and updating global or per-subject configurations.
209+
210+
=== Common use cases
211+
212+
The following examples show which operations are required for common Schema Registry tasks:
213+
214+
==== Schema Registry migration
215+
216+
When migrating schemas between clusters, you must have **different ACLs for source and target clusters**.
217+
218+
**Source cluster (read-only):**
219+
220+
[,bash]
221+
----
222+
# Read schemas from source Schema Registry
223+
rpk security acl create \
224+
--allow-principal User:migrator-user \
225+
--operation read,describe \
226+
--registry-global \
227+
--brokers <source-brokers>
228+
----
229+
230+
This grants:
231+
232+
* `read` - Read schemas by ID from source
233+
* `describe` - List all subjects in source
234+
235+
[NOTE]
236+
====
237+
The `describe_configs` operation is required to read Schema Registry configuration settings, including compatibility modes and IMPORT mode status.
238+
====
239+
240+
**Target cluster (read-write):**
241+
242+
[,bash]
243+
----
244+
# Write schemas to target Schema Registry and manage IMPORT mode
245+
rpk security acl create \
246+
--allow-principal User:migrator-user \
247+
--operation write,describe,alter_configs,describe_configs \
248+
--registry-global \
249+
--brokers <target-brokers>
250+
----
251+
252+
This grants:
253+
254+
* `write` - Register schemas in target with preserved IDs
255+
* `describe` - List all subjects in target
256+
* `alter_configs` - Set IMPORT mode on target Schema Registry
257+
* `describe_configs` - Read compatibility settings and mode
258+
259+
[IMPORTANT]
260+
====
261+
**Schema Registry ACLs are only for Schema Registry operations.** For complete data migration, you must also use Kafka ACLs:
262+
263+
* **Topics:** READ (source), WRITE/CREATE/DESCRIBE/ALTER (target)
264+
* **Consumer groups:** READ (source), CREATE/READ (target)
265+
* **Cluster:** DESCRIBE (both), CREATE (target)
266+
267+
See xref:manage:security/authorization/acl.adoc[Configure Access Control Lists] for Kafka ACL configuration.
268+
====
269+
270+
[NOTE]
271+
====
272+
The target Schema Registry must be in IMPORT mode to preserve schema IDs during migration. Only superusers or principals with `alter_configs` permission on the `registry` resource can change the global mode.
273+
ifndef::env-cloud[]
274+
See xref:manage:schema-reg/schema-reg-api.adoc#set-global-mode[Set global mode].
275+
endif::[]
276+
ifdef::env-cloud[]
277+
See xref:schema-reg:schema-reg-api.adoc#set-global-mode[Set global mode].
278+
endif::[]
279+
====
280+
281+
==== Complete migration setup workflow
282+
283+
For a complete migration setup, follow this workflow:
284+
285+
1. **Bootstrap superusers** - Configure superusers using `.bootstrap.yaml` before enabling authentication
286+
2. **Create migration user** - Create dedicated migration user with minimal required permissions
287+
3. **Configure Schema Registry ACLs** - Grant read access on source, read-write access on target
288+
4. **Configure Kafka ACLs** - Grant topic read/write, consumer group, and cluster permissions
289+
5. **Enable SASL authentication** - Enable SASL/SCRAM-SHA-256 on both clusters
290+
6. **Enable ACL authorization** - Enable `kafka_enable_authorization` and `schema_registry_enable_authorization`
291+
7. **Set target to IMPORT mode** - Enable IMPORT mode on target Schema Registry
292+
8. **Start migration** - Begin data and schema migration
293+
9. **Verify ACLs** - Test that permissions work correctly and restrictions are enforced
294+
10. **Complete migration** - Disable IMPORT mode after migration completes
295+
296+
For a complete working example with Docker Compose, see the https://github.com/redpanda-data/redpanda-labs/tree/main/docker-compose/redpanda-migrator-demo[Redpanda Migrator Demo].
297+
298+
[NOTE]
299+
====
300+
**Schema Registry Internal Client Authentication:** When SASL authentication is enabled on your Kafka cluster, the Schema Registry's internal Kafka client must also be configured with SASL credentials. Configure these using node-level properties:
301+
302+
[,bash]
303+
----
304+
--set schema_registry_client.scram_username=<username>
305+
--set schema_registry_client.scram_password=<password>
306+
--set schema_registry_client.sasl_mechanism=SCRAM-SHA-256
307+
----
308+
309+
Without these credentials, Schema Registry operations that interact with Kafka (like storing schema data) will fail with "broker_not_available" errors.
310+
====
311+
312+
==== Read-only access for consumers
313+
314+
Applications that only consume messages with schemas require:
315+
316+
[,bash]
317+
----
318+
# For consuming with schema validation
319+
rpk security acl create \
320+
--allow-principal consumer-app \
321+
--operation read \
322+
--registry-subject "orders-*" \
323+
--resource-pattern-type prefixed
324+
----
325+
326+
This allows:
327+
328+
* Reading schema content by ID (embedded in messages)
329+
* Viewing specific schema versions
330+
331+
This does _not_ allow listing all subjects or modifying schemas.
332+
333+
==== Producer access
334+
335+
Applications that produce messages with schemas require:
336+
337+
[,bash]
338+
----
339+
# For producing with new schemas
340+
rpk security acl create \
341+
--allow-principal producer-app \
342+
--operation read,write,describe \
343+
--registry-subject "orders-*" \
344+
--resource-pattern-type prefixed
345+
----
346+
347+
This allows:
348+
349+
* Checking if schemas already exist (`describe`)
350+
* Reading existing schema versions (`read`)
351+
* Registering new schema versions (`write`)
352+
353+
==== Schema administrator access
354+
355+
Schema administrators who manage compatibility and cleanup require:
356+
357+
[,bash]
358+
----
359+
# For full schema management
360+
rpk security acl create \
361+
--allow-principal schema-admin \
362+
--operation all \
363+
--registry-global
364+
----
365+
366+
This grants all operations, including:
367+
368+
* Managing compatibility settings
369+
* Deleting deprecated schemas
370+
* Viewing and modifying configurations
371+
* Listing all subjects and schemas
372+
373+
=== Pattern-based ACLs for Schema Registry
374+
375+
When using subject name patterns (like `orders-*`), always specify `--resource-pattern-type prefixed`:
376+
377+
[,bash]
378+
----
379+
# Correct - matches all subjects starting with "orders-"
380+
rpk security acl create \
381+
--allow-principal User:app \
382+
--operation read \
383+
--registry-subject "orders-" \
384+
--resource-pattern-type prefixed
385+
386+
# Incorrect - treats "orders-*" as literal subject name
387+
rpk security acl create \
388+
--allow-principal User:app \
389+
--operation read \
390+
--registry-subject "orders-*"
391+
----
392+
393+
Pattern types:
394+
395+
* **`prefixed`** - Matches subjects starting with the specified string (for example, `orders-` matches `orders-value`, `orders-key`)
396+
* **`literal`** - Matches exact subject name only (default if not specified)
397+
398+
[TIP]
399+
====
400+
Redpanda recommends using the topic naming strategy where subjects follow the pattern `<topicName>-key` or `<topicName>-value`. With this strategy, you can use a single prefixed ACL to grant access to both key and value subjects for a topic.
401+
402+
Example: `--registry-subject "orders-" --resource-pattern-type prefixed` grants access to both `orders-key` and `orders-value` subjects.
403+
====
404+
199405
== Enable Schema Registry Authorization
200406

201407
=== Prerequisites
@@ -413,6 +619,57 @@ User:jane * TOPIC private LITERAL WRITE
413619

414620
When using the `--registry-global` option, be aware that `REGISTRY` resource types are global and apply to all of Schema Registry. They do not have a resource name because they are not tied to a specific resource. There are no resource names missing here.
415621

622+
==== Schema Registry "broker_not_available" errors
623+
624+
If Schema Registry operations fail with `broker_not_available` errors after enabling SASL:
625+
626+
[,bash]
627+
----
628+
{"error_code":50302,"message":"{ node: -1 }, { error_code: broker_not_available [8] }"}
629+
----
630+
631+
**Cause:** The Schema Registry's internal Kafka client is not configured with SASL credentials.
632+
633+
**Solution:** Configure the Schema Registry client credentials:
634+
635+
[,bash]
636+
----
637+
rpk cluster config set schema_registry_client.scram_username <username>
638+
rpk cluster config set schema_registry_client.scram_password <password>
639+
rpk cluster config set schema_registry_client.sasl_mechanism SCRAM-SHA-256
640+
----
641+
642+
Then restart the Schema Registry service.
643+
644+
==== Pattern-based ACL not working
645+
646+
If a pattern-based ACL (like `orders-*`) is not matching expected subjects:
647+
648+
**Cause:** Missing `--resource-pattern-type prefixed` flag.
649+
650+
**Solution:** Recreate the ACL with the correct pattern type:
651+
652+
[,bash]
653+
----
654+
# Delete incorrect ACL
655+
rpk security acl delete \
656+
--allow-principal User:app \
657+
--operation read \
658+
--registry-subject "orders-*"
659+
660+
# Create correct ACL with pattern type
661+
rpk security acl create \
662+
--allow-principal User:app \
663+
--operation read \
664+
--registry-subject "orders-" \
665+
--resource-pattern-type prefixed
666+
----
667+
668+
[NOTE]
669+
====
670+
Pattern matching uses the string without the asterisk when using `prefixed` type.
671+
====
672+
416673
== Suggested reading
417674

418675
ifndef::env-cloud[]

modules/reference/pages/rpk/rpk-security/rpk-security-acl-create.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ Allow read permissions to user `panda` on topic `bar` and schema registry subjec
4444
rpk security acl create --allow-principal panda --operation read --topic bar --registry-subject bar-value
4545
```
4646

47+
Grant schema migration permissions for migrating schemas between clusters:
48+
49+
```bash
50+
# Source cluster (read-only)
51+
rpk security acl create --allow-principal User:migrator-user \
52+
--operation read,describe --registry-global --brokers <source-brokers>
53+
54+
# Target cluster (read-write and IMPORT mode management)
55+
rpk security acl create --allow-principal User:migrator-user \
56+
--operation write,describe,alter_configs,describe_configs \
57+
--registry-global --brokers <target-brokers>
58+
```
59+
60+
[NOTE]
61+
====
62+
These are Schema Registry ACLs only. You also require Kafka ACLs for topics, consumer groups, and cluster operations. See xref:manage:security/authorization/acl.adoc[Configure Access Control Lists].
63+
====
64+
4765
== Usage
4866

4967
[,bash]

0 commit comments

Comments
 (0)