tenant

package
v1.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTenantID = "anonymous"

DefaultTenantID is the default tenant ID used when the interceptor is disabled.

Variables

View Source
var ErrNoTenantID = user.ErrNoOrgID

Functions

func ExtractTenantIDFromContext

func ExtractTenantIDFromContext(ctx context.Context) (string, error)

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 InjectTenantID

func InjectTenantID(ctx context.Context, tenantID string) context.Context

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

type AllowedTenants added in v1.2.0

type AllowedTenants struct {
	// contains filtered or unexported fields
}

AllowedTenants that can answer whether tenant is allowed or not based on configuration. Default value (nil) allows all tenants.

func NewAllowedTenants added in v1.2.0

func NewAllowedTenants(enabled []string, disabled []string) *AllowedTenants

NewAllowedTenants builds new allowed tenants based on enabled and disabled tenants. If there are any enabled tenants, then only those tenants are allowed. If there are any disabled tenants, then tenant from that list, that would normally be allowed, is disabled instead.

func (*AllowedTenants) IsAllowed added in v1.2.0

func (a *AllowedTenants) IsAllowed(tenantID string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL