Connectum API Reference / @connectum/auth / createAuthzInterceptor
Function: createAuthzInterceptor() ​
createAuthzInterceptor(
options?):Interceptor
Defined in: packages/auth/src/authz-interceptor.ts:89
Create an authorization interceptor.
Evaluates declarative rules and/or a programmatic callback against the AuthContext established by the authentication interceptor.
IMPORTANT: This interceptor MUST run AFTER an authentication interceptor in the chain.
Parameters ​
options? ​
Authorization options
Returns ​
Interceptor
ConnectRPC interceptor
Throws ​
When skipMethods contains "*" (the pattern "*" stays valid in rule methods)
Throws ​
When defaultPolicy or the effect of a rule is not exactly "allow" or "deny", or when skipMethods or the methods of a rule hold a pattern other than "*", "Service/*" or "Service/Method"
Example ​
RBAC with declarative rules
import { createAuthzInterceptor } from '@connectum/auth';
const authz = createAuthzInterceptor({
defaultPolicy: 'deny',
rules: [
{ name: 'public', methods: ['public.v1.PublicService/*'], effect: 'allow' },
{ name: 'admin', methods: ['admin.v1.AdminService/*'], requires: { roles: ['admin'] }, effect: 'allow' },
],
});