auth

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetToken

func GetToken(httpClient *http.Client, authFileBaseName string) (string, bool, error)

GetToken returns current user access token.

func NewHMACAuth

func NewHMACAuth(key []byte) (jwt.SigningMethod, jwt.Keyfunc)

func NewPerRPCCredentials

func NewPerRPCCredentials(authType, token string) jwtCreds

func NewPerRPCInternalCredentials

func NewPerRPCInternalCredentials(token string) jwtCreds

func NewRSAAuth

func NewRSAAuth() (jwt.SigningMethod, jwt.Keyfunc)

NewRSAAuth returns a jwt.Keyfunc with empty key. Useful for checking token expiration.

Types

type Authentifier

type Authentifier interface {
	Login() error
	Renew() error
	Valid() bool
	GetToken() string
	GetType() Type
}

type BaseAuthConfig

type BaseAuthConfig struct {
	Type Type `json:"type"`
}

BaseAuthConfig describes a base AuthConfig used to find the good implementation.

func (*BaseAuthConfig) GetToken

func (ac *BaseAuthConfig) GetToken() string

func (*BaseAuthConfig) GetType

func (ac *BaseAuthConfig) GetType() Type

func (*BaseAuthConfig) Login

func (ac *BaseAuthConfig) Login() error

func (*BaseAuthConfig) Renew

func (ac *BaseAuthConfig) Renew() error

func (*BaseAuthConfig) Valid

func (ac *BaseAuthConfig) Valid() bool

type Claims

type Claims struct {
	// compose RegisteredClaims
	jwt.RegisteredClaims

	EmailVerified     bool                `json:"email_verified,omitempty"`
	Name              string              `json:"name,omitempty"`
	PreferredUsername string              `json:"preferred_username,omitempty"`
	GivenName         string              `json:"given_name,omitempty"`
	FamilyName        string              `json:"family_name,omitempty"`
	Email             string              `json:"email,omitempty"`
	ResourceAccess    interface{}         `json:"resource_access,omitempty"`
	RealmAccess       map[string][]string `json:"realm_access,omitempty"`
	Groups            []string            `json:"groups,omitempty"`

	// custom properties
	AuthType string
}

type Config

type Config struct {
	CurrentContext string             `json:"current_context"`
	Contexts       map[string]Context `json:"contexts"`
	// contains filtered or unexported fields
}

func Load

func Load(baseFileName string) (Config, error)

func (*Config) GetAuthConfig

func (c *Config) GetAuthConfig(httpClient *http.Client) (Authentifier, error)

GetAuthConfig returns the auth configuration corresponding to the current context.

func (*Config) IsContext

func (c *Config) IsContext(contextName string) bool

func (*Config) Save

func (c *Config) Save() error

Save save the auth configs to the disk.

func (*Config) UpdateContext

func (c *Config) UpdateContext(newAuth Authentifier) error

UpdateContext update the current context with a new Autentifier.

func (*Config) UseContext

func (c *Config) UseContext(contextName string)

UseContext set current context to context name. Creates a new empty context if does not exist.

type ContainerAuthConfig

type ContainerAuthConfig struct {
	Type Type   `json:"type"`
	Key  []byte `json:"key"`

	BaseURL string `json:"base_url"`

	AccessToken string `json:"access_token"`
}

ContainerAuthConfig define container authentication configuration.

func NewContainerAuthConfig

func NewContainerAuthConfig(key, url string) *ContainerAuthConfig

func (*ContainerAuthConfig) GetToken

func (ac *ContainerAuthConfig) GetToken() string

GetToken returns an access token for the current user.

func (*ContainerAuthConfig) GetType

func (ac *ContainerAuthConfig) GetType() Type

GetType returns the type of the Auth Configuration.

func (*ContainerAuthConfig) Login

func (ac *ContainerAuthConfig) Login() error

Login authenticates user with the authentication server.

func (*ContainerAuthConfig) Renew

func (ac *ContainerAuthConfig) Renew() error

Renew renews AccessToken.

func (*ContainerAuthConfig) Valid

func (ac *ContainerAuthConfig) Valid() bool

Valid returns true if current AccessToken is valid.

type Context

type Context struct {
	AuthType   Type            `json:"auth_type"`
	AuthConfig json.RawMessage `json:"auth_config"`
}

type KeycloakAuthConfig

type KeycloakAuthConfig struct {
	Type     Type   `json:"type"`
	Username string `json:"username"`
	BaseURL  string `json:"base_url"`
	// contains filtered or unexported fields
}

KeycloakAuthConfig define authentication configuration.

func NewKeycloakAuthConfig

func NewKeycloakAuthConfig(client *http.Client, username, pwd, url string) *KeycloakAuthConfig

func NewKeycloakAuthConfigDeviceAuthzGrant

func NewKeycloakAuthConfigDeviceAuthzGrant(client *http.Client, url string) *KeycloakAuthConfig

func (*KeycloakAuthConfig) GetToken

func (ac *KeycloakAuthConfig) GetToken() string

GetToken returns an access token for the current user.

func (*KeycloakAuthConfig) GetType

func (ac *KeycloakAuthConfig) GetType() Type

GetType returns the type of the Auth Configuration.

func (*KeycloakAuthConfig) Login

func (ac *KeycloakAuthConfig) Login() error

Login authenticates user with the authentication server.

func (*KeycloakAuthConfig) Renew

func (ac *KeycloakAuthConfig) Renew() error

Renew renews AccessToken.

func (*KeycloakAuthConfig) Valid

func (ac *KeycloakAuthConfig) Valid() bool

Valid returns true if current AccessToken is valid or not expired.

type KeycloakDeviceAuthzResp

type KeycloakDeviceAuthzResp struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri"`
	VerificationURLComplete string `json:"verification_uri_complete"`
	ExpiresIn               int    `json:"expires_in"`
	Interval                int    `json:"interval"`
}

type Type

type Type string

Jump to

Keyboard shortcuts

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