auth

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("key not found in cache")
View Source
var MB = 1024 * 1024 //used like NewCache(20 * MB, 60) to get a 20 mb cache

Functions

func GetAuthToken

func GetAuthToken(req *http.Request) string

func GetCachedTokenProvider

func GetCachedTokenProvider(config configuration.Config) func(userid string) (token Token, err error)

Types

type Cache

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

func NewCache

func NewCache(size int, defaultExpirationInSeconds int) *Cache

func (*Cache) Use

func (this *Cache) Use(key string, getter func() (interface{}, error), result interface{}) (err error)

func (*Cache) UseWithExpirationInResult

func (this *Cache) UseWithExpirationInResult(key string, getter func() (interface{}, int, error), result interface{}) (err error)

type Item

type Item struct {
	Key   string
	Value []byte
}

type OpenidToken

type OpenidToken struct {
	AccessToken      string    `json:"access_token"`
	ExpiresIn        float64   `json:"expires_in"`
	RefreshExpiresIn float64   `json:"refresh_expires_in"`
	RefreshToken     string    `json:"refresh_token"`
	TokenType        string    `json:"token_type"`
	RequestTime      time.Time `json:"-"`
}

func GetOpenidToken

func GetOpenidToken(authEndpoint string, authClientId string, authClientSecret string) (openid OpenidToken, err error)

func RefreshOpenidToken

func RefreshOpenidToken(authEndpoint string, authClientId string, authClientSecret string, refreshToken string) (openid OpenidToken, err error)

func (*OpenidToken) EnsureAccess

func (this *OpenidToken) EnsureAccess(config configuration.Config) (token string, err error)

type Token

type Token struct {
	Token       string              `json:"__token"`
	Sub         string              `json:"sub,omitempty"`
	RealmAccess map[string][]string `json:"realm_access,omitempty"`
}

func ExchangeUserToken

func ExchangeUserToken(config configuration.Config, userid string) (token Token, expiration int, err error)

func GetParsedToken

func GetParsedToken(req *http.Request) (token Token, err error)

func Parse

func Parse(token string) (claims Token, err error)

func (*Token) GetRoles

func (this *Token) GetRoles() []string

func (*Token) GetUserId

func (this *Token) GetUserId() string

func (*Token) IsAdmin

func (this *Token) IsAdmin() bool

func (*Token) Jwt

func (this *Token) Jwt() string

func (*Token) String

func (this *Token) String() string

func (*Token) Valid

func (this *Token) Valid() error

Jump to

Keyboard shortcuts

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