Documentation ¶
Index ¶
- type IdentityBuilder
- func (b *IdentityBuilder) Build(r *http.Request) *api.IdentityContext
- func (b *IdentityBuilder) FromContextValue(key interface{}) *IdentityBuilder
- func (b *IdentityBuilder) FromHeader(header ...string) *IdentityBuilder
- func (b *IdentityBuilder) FromHostname(segment int) *IdentityBuilder
- func (b *IdentityBuilder) ID(identity string) *IdentityBuilder
- func (b *IdentityBuilder) JWT() *IdentityBuilder
- func (b *IdentityBuilder) Mapper(mapper IdentityMapper) *IdentityBuilder
- func (b *IdentityBuilder) None() *IdentityBuilder
- func (b *IdentityBuilder) Subject() *IdentityBuilder
- type IdentityMapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IdentityBuilder ¶
type IdentityBuilder struct {
// contains filtered or unexported fields
}
IdentityBuilder is used to configure what information about caller identity is sent in authorization calls.
func (*IdentityBuilder) Build ¶
func (b *IdentityBuilder) Build(r *http.Request) *api.IdentityContext
Build constructs an IdentityContext that can be used in authorization requests.
func (*IdentityBuilder) FromContextValue ¶
func (b *IdentityBuilder) FromContextValue(key interface{}) *IdentityBuilder
FromContextValue extracts caller identity from a value in the incoming request context.
If the value is not present, not a string, or an empty string then the request is considered anonymous.
func (*IdentityBuilder) FromHeader ¶
func (b *IdentityBuilder) FromHeader(header ...string) *IdentityBuilder
FromHeader retrieves caller identity from request headers.
Headers are attempted in order. The first non-empty header is used. If none of the specified headers have a value, the request is considered anonymous.
func (*IdentityBuilder) FromHostname ¶
func (b *IdentityBuilder) FromHostname(segment int) *IdentityBuilder
FromHostname extracts caller identity from the incoming request's host name.
The function returns the specified hostname segment. Indexing is zero-based and starts from the left. Negative indices start from the right.
For Example, if the hostname is "service.user.company.com" then both FromHostname(1) and FromHostname(-3) return the value "user".
func (*IdentityBuilder) ID ¶
func (b *IdentityBuilder) ID(identity string) *IdentityBuilder
Call ID(...) to set the user's identity. If neither JWT() or Subject() are called too, IdentityMapper tries to infer whether the specified identity is a JWT or not. Passing an empty string is the same as calling .None() and results in an authorization check for anonymous access.
func (*IdentityBuilder) JWT ¶
func (b *IdentityBuilder) JWT() *IdentityBuilder
Call JWT() to indicate that the user's identity is expressed as a string-encoded JWT.
JWT() is always called in conjunction with another method that provides the user ID itself. For example:
idBuilder.JWT().FromHeader("Authorization")
func (*IdentityBuilder) Mapper ¶
func (b *IdentityBuilder) Mapper(mapper IdentityMapper) *IdentityBuilder
Mapper takes a custom IdentityMapper to be used for extracting identity information from incoming requests.
func (*IdentityBuilder) None ¶
func (b *IdentityBuilder) None() *IdentityBuilder
Call None() to indicate that requests are unauthenticated.
func (*IdentityBuilder) Subject ¶
func (b *IdentityBuilder) Subject() *IdentityBuilder
Subject() is always used in conjunction with another method that provides the user ID itself. For example:
idBuilder.Subject().FromContextValue("username")
type IdentityMapper ¶
type IdentityMapper func(*http.Request, middleware.Identity)
IdentityMapper is the type of callback functions that can inspect incoming HTTP requests and set the caller's identity.