Connectum API Reference / @connectum/auth / createAuthzInterceptor
Function: createAuthzInterceptor()
createAuthzInterceptor(
options?):Interceptor
Defined in: packages/auth/src/authz-interceptor.ts:85
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
Example
typescript
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' },
],
});