user

package
v1.0.34 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessListClaim

type AccessListClaim struct {
	Paths map[string]interface{} `json:"paths,omitempty" xml:"paths,omitempty" yaml:"paths,omitempty"`
}

AccessListClaim represents custom acl/paths claim

type Authenticator

type Authenticator struct {
	Name          string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Realm         string `json:"realm,omitempty" xml:"realm,omitempty" yaml:"realm,omitempty"`
	Method        string `json:"method,omitempty" xml:"method,omitempty" yaml:"method,omitempty"`
	TempSecret    string `json:"temp_secret,omitempty" xml:"temp_secret,omitempty" yaml:"temp_secret,omitempty"`
	TempSessionID string `json:"temp_session_id,omitempty" xml:"temp_session_id,omitempty" yaml:"temp_session_id,omitempty"`
	TempChallenge string `json:"temp_challenge,omitempty" xml:"temp_challenge,omitempty" yaml:"temp_challenge,omitempty"`
	URL           string `json:"url,omitempty" xml:"url,omitempty" yaml:"url,omitempty"`
}

Authenticator represents authentication backend

type Checkpoint

type Checkpoint struct {
	ID             int    `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	Name           string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Type           string `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
	Parameters     string `json:"parameters,omitempty" xml:"parameters,omitempty" yaml:"parameters,omitempty"`
	Passed         bool   `json:"passed,omitempty" xml:"passed,omitempty" yaml:"passed,omitempty"`
	FailedAttempts int    `json:"failed_attempts,omitempty" xml:"failed_attempts,omitempty" yaml:"failed_attempts,omitempty"`
}

Checkpoint represents additional checks that a user needs to pass. Once a user passes the checks, the Authorized is set to true. The checks could be the acceptance of the terms of use, multi-factor authentication, etc.

func NewCheckpoint

func NewCheckpoint(s string) (*Checkpoint, error)

NewCheckpoint returns Checkpoint instance.

func NewCheckpoints

func NewCheckpoints(v interface{}) ([]*Checkpoint, error)

NewCheckpoints returns Checkpoint instances.

type Claims

type Claims struct {
	Audience      []string               `json:"aud,omitempty" xml:"aud,omitempty" yaml:"aud,omitempty"`
	ExpiresAt     int64                  `json:"exp,omitempty" xml:"exp,omitempty" yaml:"exp,omitempty"`
	ID            string                 `json:"jti,omitempty" xml:"jti,omitempty" yaml:"jti,omitempty"`
	IssuedAt      int64                  `json:"iat,omitempty" xml:"iat,omitempty" yaml:"iat,omitempty"`
	Issuer        string                 `json:"iss,omitempty" xml:"iss,omitempty" yaml:"iss,omitempty"`
	NotBefore     int64                  `json:"nbf,omitempty" xml:"nbf,omitempty" yaml:"nbf,omitempty"`
	Subject       string                 `json:"sub,omitempty" xml:"sub,omitempty" yaml:"sub,omitempty"`
	Name          string                 `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Email         string                 `json:"email,omitempty" xml:"email,omitempty" yaml:"email,omitempty"`
	Roles         []string               `json:"roles,omitempty" xml:"roles,omitempty" yaml:"roles,omitempty"`
	Origin        string                 `json:"origin,omitempty" xml:"origin,omitempty" yaml:"origin,omitempty"`
	Scopes        []string               `json:"scopes,omitempty" xml:"scopes,omitempty" yaml:"scopes,omitempty"`
	Organizations []string               `json:"org,omitempty" xml:"org,omitempty" yaml:"org,omitempty"`
	AccessList    *AccessListClaim       `json:"acl,omitempty" xml:"acl,omitempty" yaml:"acl,omitempty"`
	Address       string                 `json:"addr,omitempty" xml:"addr,omitempty" yaml:"addr,omitempty"`
	PictureURL    string                 `json:"picture,omitempty" xml:"picture,omitempty" yaml:"picture,omitempty"`
	Metadata      map[string]interface{} `json:"metadata,omitempty" xml:"metadata,omitempty" yaml:"metadata,omitempty"`
	// contains filtered or unexported fields
}

Claims represents custom and standard JWT claims associated with User.

func (Claims) Valid

func (c Claims) Valid() error

Valid validates user claims.

type User

type User struct {
	Claims        *Claims       `json:"claims,omitempty" xml:"claims,omitempty" yaml:"claims,omitempty"`
	Token         string        `json:"token,omitempty" xml:"token,omitempty" yaml:"token,omitempty"`
	TokenName     string        `json:"token_name,omitempty" xml:"token_name,omitempty" yaml:"token_name,omitempty"`
	TokenSource   string        `json:"token_source,omitempty" xml:"token_source,omitempty" yaml:"token_source,omitempty"`
	Authenticator Authenticator `json:"authenticator,omitempty" xml:"authenticator,omitempty" yaml:"authenticator,omitempty"`
	Checkpoints   []*Checkpoint `json:"checkpoints,omitempty" xml:"checkpoints,omitempty" yaml:"checkpoints,omitempty"`
	Authorized    bool          `json:"authorized,omitempty" xml:"authorized,omitempty" yaml:"authorized,omitempty"`
	FrontendLinks []string      `json:"frontend_links,omitempty" xml:"frontend_links,omitempty" yaml:"frontend_links,omitempty"`
	Locked        bool          `json:"locked,omitempty" xml:"locked,omitempty" yaml:"locked,omitempty"`
	Cached        bool          `json:"cached,omitempty" xml:"cached,omitempty" yaml:"cached,omitempty"`
	// contains filtered or unexported fields
}

User is a user with claims and status.

func NewUser

func NewUser(data interface{}) (*User, error)

NewUser returns a user with associated standard and custom claims.

func (u *User) AddFrontendLinks(v interface{}) error

AddFrontendLinks adds frontend links to User instance.

func (*User) AsMap

func (u *User) AsMap() map[string]interface{}

AsMap converts Claims struct to dictionary.

func (*User) BuildRequestIdentity

func (u *User) BuildRequestIdentity(s string) map[string]interface{}

BuildRequestIdentity builds request identity associated with the user.

func (*User) GetClaimValueByField

func (u *User) GetClaimValueByField(k string) string

GetClaimValueByField returns the value of the provides claims field.

func (*User) GetData

func (u *User) GetData() map[string]interface{}

GetData return user claim felds and their values for the evaluation by an ACL.

func (*User) GetRequestHeaders

func (u *User) GetRequestHeaders() map[string]string

GetRequestHeaders returns request headers associated with the user.

func (*User) GetRequestIdentity

func (u *User) GetRequestIdentity() map[string]interface{}

GetRequestIdentity returns request identity associated with the user.

func (*User) HasRole

func (u *User) HasRole(roles ...string) bool

HasRole checks whether a user has any of the provided roles.

func (*User) HasRoles

func (u *User) HasRoles(roles ...string) bool

HasRoles checks whether a user has all of the provided roles.

func (*User) SetExpiresAtClaim

func (u *User) SetExpiresAtClaim(i int64)

SetExpiresAtClaim sets ExpiresAt claim.

func (*User) SetIssuedAtClaim

func (u *User) SetIssuedAtClaim(i int64)

SetIssuedAtClaim sets IssuedAt claim.

func (*User) SetNotBeforeClaim

func (u *User) SetNotBeforeClaim(i int64)

SetNotBeforeClaim sets NotBefore claim.

func (*User) SetRequestHeaders

func (u *User) SetRequestHeaders(m map[string]string)

SetRequestHeaders sets request headers associated with the user.

func (*User) SetRequestIdentity

func (u *User) SetRequestIdentity(m map[string]interface{})

SetRequestIdentity sets request identity associated with the user.

func (*User) SetRolesClaim

func (u *User) SetRolesClaim(roles []string)

SetRolesClaim sets Roles claim

Jump to

Keyboard shortcuts

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