uaa

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken interface {
	Token
}

AccessToken is purely an access token. It does not contain a refresh token and cannot be refreshed for another token.

func NewAccessToken

func NewAccessToken(accessValueType, accessValue string) AccessToken

type AccessTokenImpl

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

func (AccessTokenImpl) IsValid

func (t AccessTokenImpl) IsValid() bool

func (AccessTokenImpl) Type

func (t AccessTokenImpl) Type() string

func (AccessTokenImpl) Value

func (t AccessTokenImpl) Value() string

type Client

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

func NewClient

func NewClient(endpoint string, clientID string, clientSecret string, httpClient *httpclient.DefaultHTTPClient) Client

func (Client) ClientCredentialsGrant

func (c Client) ClientCredentialsGrant() (TokenResp, error)

func (Client) OwnerPasswordCredentialsGrant

func (c Client) OwnerPasswordCredentialsGrant(params []TokenParameters) (TokenResp, error)

func (Client) RefreshTokenGrant

func (c Client) RefreshTokenGrant(refreshValue string) (TokenResp, error)

type ClientRequest

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

func NewClientRequest

func NewClientRequest(
	endpoint string,
	client string,
	clientSecret string,
	httpClient *httpclient.DefaultHTTPClient,
) ClientRequest

func (ClientRequest) Get

func (r ClientRequest) Get(path string, response interface{}) error

func (ClientRequest) Post

func (r ClientRequest) Post(path string, payload []byte, response interface{}) error

type ClientTokenSession

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

func NewClientTokenSession

func NewClientTokenSession(uaa UAA, opts ...Options) *ClientTokenSession

func (*ClientTokenSession) ClientCredentialsTokenFunc

func (c *ClientTokenSession) ClientCredentialsTokenFunc(retried bool) (string, error)

func (*ClientTokenSession) OwnerPasswordCredentialsTokenFunc

func (c *ClientTokenSession) OwnerPasswordCredentialsTokenFunc(retried bool) (string, error)

type Config

type Config struct {
	Host string
	Port int
	Path string

	ClientID     string
	ClientSecret string

	Username string
	Password string

	CACert   string
	AllProxy string

	TokenFunc func(bool) (string, error)
}

func NewConfigFromURL

func NewConfigFromURL(url string) (Config, error)

func (Config) CACertPool

func (c Config) CACertPool() (*x509.CertPool, error)

func (Config) Validate

func (c Config) Validate() error

type FactoryImpl

type FactoryImpl struct{}

func NewFactory

func NewFactory() FactoryImpl

func (FactoryImpl) New

func (f FactoryImpl) New(config Config) (UAA, error)

type Options

type Options func(*ClientTokenSession)

func WithPasswordCredentials

func WithPasswordCredentials(username, password string) Options

type RefreshableAccessToken

type RefreshableAccessToken interface {
	AccessToken
	RefreshValue() string
}

RefreshableAccessToken is an access token with a refresh token that can be used to get another access token.

func NewRefreshableAccessToken

func NewRefreshableAccessToken(accessValueType, accessValue, refreshValue string) RefreshableAccessToken

type RefreshableAccessTokenImpl

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

func (RefreshableAccessTokenImpl) IsValid

func (t RefreshableAccessTokenImpl) IsValid() bool

func (RefreshableAccessTokenImpl) RefreshValue

func (t RefreshableAccessTokenImpl) RefreshValue() string

func (RefreshableAccessTokenImpl) Type

func (RefreshableAccessTokenImpl) Value

type Token

type Token interface {
	Type() string
	Value() string
	IsValid() bool
}

Token is a plain token with a value.

type TokenInfo

type TokenInfo struct {
	Username  string   `json:"user_name"`
	Scopes    []string `json:"scope"`
	ExpiredAt int      `json:"exp"`
}

type TokenParameters

type TokenParameters struct {
	Key   string // e.g. "username"
	Value string
}

type TokenResp

type TokenResp struct {
	Type         string `json:"token_type"`    // e.g. "bearer"
	AccessToken  string `json:"access_token"`  // e.g. "eyJhbGciOiJSUzI1NiJ9.eyJq<snip>fQ.Mr<snip>RawG"
	RefreshToken string `json:"refresh_token"` // e.g. "eyJhbGciOiJSUzI1NiJ9.eyJq<snip>fQ.Mr<snip>RawG"
}

type UAA

type UAA interface {
	RefreshTokenGrant(string) (AccessToken, error)
	ClientCredentialsGrant() (AccessToken, error)
	OwnerPasswordCredentialsGrant([]TokenParameters) (AccessToken, error)
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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