Kind: Interface
Source: packages/microservices/external/kafka.interface.ts
Part of: Microservices
AclResource describes a Kafka resource targeted by an access control list (ACL) rule. It identifies the resource category, its name, and the pattern Kafka should use when matching the resource name during authorization.
Properties
| Property | Type |
|---|---|
resourceType | AclResourceTypes |
resourceName | string |
resourcePatternType | ResourcePatternTypes |
Diagram
mermaidgraph LR ACL[Kafka ACL Rule] --> Resource[AclResource] Resource --> Type[resourceType: AclResourceTypes] Resource --> Name[resourceName: string] Resource --> Pattern[resourcePatternType: ResourcePatternTypes] Type --> KafkaResource[Kafka resource category] Pattern --> Matching[Kafka resource matching behavior]
Usage
tsimport {
AclResource,
AclResourceTypes,
ResourcePatternTypes,
} from './kafka.interface';
const topicResource: AclResource = {
resourceType: AclResourceTypes.TOPIC,
resourceName: 'orders',
resourcePatternType: ResourcePatternTypes.LITERAL,
};
// Use the resource definition when creating or filtering Kafka ACLs.
await admin.createAcls({
acl: {
resource: topicResource,
principal: 'User:order-service',
host: '*',
operation: 'READ',
permissionType: 'ALLOW',
},
});
AI Coding Instructions
- Provide all three fields when constructing an
AclResource; they define how Kafka locates the protected resource. - Use
AclResourceTypesandResourcePatternTypesenum values instead of hard-coded strings. - Use
LITERALmatching for a single, exact topic or consumer group name; use prefix matching only when broader access is intentional. - Ensure
resourceNamematches the Kafka resource naming convention used by the target cluster. - Pass this interface as the
resourceportion of Kafka ACL create, delete, or filter operations.
Was this page helpful?