Documentation ¶
Index ¶
- Constants
- func GetTenant(ctx context.Context) (tenant string, found bool)
- func GetTenantOrDefault(ctx context.Context) string
- func GetUser(ctx context.Context) (xuser.User, error)
- func MustGetUser(ctx context.Context) xuser.User
- func WithJwt(ctx context.Context, jwt string) context.Context
- func WithTenant(ctx context.Context, tenant string) context.Context
- func WithUser(ctx context.Context, user xuser.User) context.Context
Constants ¶
View Source
const ( // JwtCtxKey is the key used to store the JWT (raw) string in the context JwtCtxKey = "as-jwt-token" // UserCtxKey is the key used to store the user in the context UserCtxKey = "x-user" // ImpersonatingUserKeyName is the key used to store the impersonating (real) // user in the context ImpersonatingUserKeyName = "x-real-user" // TenantCtxKey is the key used to store the tenant in the context. If present // it will be used in case the user is not present. TenantCtxKey = "x-tenant" // DefaultTenant is the tenant to use if no tenant is found in the context DefaultTenant = "default" )
Variables ¶
This section is empty.
Functions ¶
func GetTenantOrDefault ¶
GetTenantOrDefault returns the tenant from the context if it exists or the default value.
func GetUser ¶
GetUser returns the user from the context if it exists. If the user does not exist, returns an unauthorized error.
func MustGetUser ¶
MustGetUser returns the user from the context if it exists. If the user does not exist, it panics.
func WithTenant ¶
WithTenant returns a new context with the tenant set.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.