Documentation ¶
Index ¶
- Constants
- func ExtractTenantIDFromContext(ctx context.Context) (string, error)
- func ExtractTenantIDFromHeaders(ctx context.Context, headers http.Header) (string, context.Context, error)
- func InjectTenantID(ctx context.Context, tenantID string) context.Context
- func NewAuthInterceptor(enabled bool) connect.Interceptor
Constants ¶
const DefaultTenantID = "anonymous"
DefaultTenantID is the default tenant ID used when the interceptor is disabled.
const ErrNoTenantID = user.ErrNoOrgID
Variables ¶
This section is empty.
Functions ¶
func ExtractTenantIDFromContext ¶
ExtractTenantIDFromContext extracts a single TenantID from the context.
func ExtractTenantIDFromHeaders ¶
func ExtractTenantIDFromHeaders(ctx context.Context, headers http.Header) (string, context.Context, error)
ExtractTenantIDFromHeaders extracts a single TenantID from http headers.
func NewAuthInterceptor ¶
func NewAuthInterceptor(enabled bool) connect.Interceptor
NewAuthInterceptor create a new tenant authentication interceptor for the server and client.
For the server:
If enabled, the interceptor will check the tenant ID in the request header is present and inject it into the context. When the interceptor is disabled, it will inject the default tenant ID into the context.
For the client :
The interceptor will inject the tenant ID from the context into the request header no matter if the interceptor is enabled or not.
Types ¶
This section is empty.