security

package
v0.0.0-...-b1e6648 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 21 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorAccessDenied = errors.New("access denied")
View Source
var ErrorInternal = errors.New("internal error")
View Source
var ErrorNotFound = errors.New("not found")
View Source
var ErrorUnexpectedStatus = errors.New("unexpected status")

Functions

func GetJWTPayload

func GetJWTPayload(auth string, results ...interface{}) (err error)

Types

type JwtPayload

type JwtPayload struct {
	UserId         string                 `json:"sub"`
	ResourceAccess map[string]JwtResource `json:"resource_access"`
	RealmAccess    JwtResource            `json:"realm_access"`
}

type JwtResource

type JwtResource struct {
	Roles []string `json:"roles"`
}

type JwtToken

type JwtToken string

func (JwtToken) Delete

func (this JwtToken) Delete(url string) (resp *http.Response, err error)

func (JwtToken) Get

func (this JwtToken) Get(url string) (resp *http.Response, err error)

func (JwtToken) GetJSON

func (this JwtToken) GetJSON(url string, result interface{}) (err error)

func (JwtToken) GetPayload

func (this JwtToken) GetPayload() (result JwtPayload, err error)

func (JwtToken) Head

func (this JwtToken) Head(url string) (statuscode int, err error)

func (JwtToken) Post

func (this JwtToken) Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)

func (JwtToken) PostJSON

func (this JwtToken) PostJSON(url string, body interface{}, result interface{}) (err error)

func (JwtToken) Put

func (this JwtToken) Put(url string, contentType string, body io.Reader) (resp *http.Response, err error)

func (JwtToken) PutJSON

func (this JwtToken) PutJSON(url string, body interface{}, result interface{}) (err error)

type KeycloakClaims

type KeycloakClaims struct {
	RealmAccess RealmAccess `json:"realm_access"`
	jwt.StandardClaims
}

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 GetOpenidPasswordToken

func GetOpenidPasswordToken(authEndpoint string, authClientId string, authClientSecret string, username, password string) (token OpenidToken, err error)

func GetOpenidToken

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

func RefreshOpenidToken

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

func (*OpenidToken) JwtToken

func (this *OpenidToken) JwtToken() JwtToken

type RealmAccess

type RealmAccess struct {
	Roles []string `json:"roles"`
}

type RoleMapping

type RoleMapping struct {
	Name string `json:"name"`
}

type Security

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

func New

func New(authEndpoint string, authClientId string, authClientSecret string, jwtIssuer string, jwtPrivateKey string, jwtExpiration int64, authExpirationTimeBuffer float64, tokenCacheExpiration int32, cacheUrls []string, cacheMaxIdleConns int, cacheTimeout time.Duration) (security *Security, err error)

func (*Security) Access

func (this *Security) Access() (token JwtToken, err error)

func (*Security) ExchangeUserToken

func (this *Security) ExchangeUserToken(userid string) (token JwtToken, err error)

func (*Security) GenerateUserToken

func (this *Security) GenerateUserToken(username string) (token JwtToken, err error)

func (*Security) GenerateUserTokenById

func (this *Security) GenerateUserTokenById(userid string) (token JwtToken, err error)

func (*Security) GetCachedUserToken

func (this *Security) GetCachedUserToken(username string) (token JwtToken, err error)

func (*Security) GetUserId

func (this *Security) GetUserId(username string) (userid string, err error)

func (*Security) GetUserRoles

func (this *Security) GetUserRoles(userid string) (roles []string, err error)

func (*Security) GetUserToken

func (this *Security) GetUserToken(username string, password string) (token JwtToken, err error)

func (*Security) ResetAccess

func (this *Security) ResetAccess()

type UserRepresentation

type UserRepresentation struct {
	Id   string `json:"id"`
	Name string `json:"username"`
}

Jump to

Keyboard shortcuts

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