kcconnection

package
v0.38.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultScopes = []string{
	"openid",
}

Functions

func SplitKeycloakRealmURL

func SplitKeycloakRealmURL(u *url.URL) (issuer string, realm string, ok bool)

SplitKeycloakRealmURL splits a Keycloak auth URL to retrieve the base path and realm separately

Types

type AuthError

type AuthError struct {
	Err error
}

AuthError defines an Authentication error

func AuthErrorf

func AuthErrorf(format string, a ...interface{}) *AuthError

func (*AuthError) Error

func (e *AuthError) Error() string

func (*AuthError) Unwrap

func (e *AuthError) Unwrap() error

type Connection

type Connection struct {
	Token    *token.Token
	MASToken *token.Token

	Config config.IConfig
	// contains filtered or unexported fields
}

Connection contains the data needed to connect to the `api.openshift.com`. Don't create instances of this type directly, use the builder instead

func (*Connection) API

func (c *Connection) API() api.API

API Creates a new API type which is a single type for multiple APIs

func (*Connection) Logout

func (c *Connection) Logout(ctx context.Context) (err error)

Logout logs the user out from the authentication server Invalidating and removing the access and refresh tokens The user will have to log in again to access the API

func (*Connection) RefreshTokens

func (c *Connection) RefreshTokens(ctx context.Context) (err error)

RefreshTokens will fetch a refreshed copy of the access token and refresh token from the authentication server The new tokens will have an increased expiry time and are persisted in the config and connection

type ConnectionBuilder

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

ConnectionBuilder contains the configuration and logic needed to connect to `api.openshift.com`. Don't create instances of this type directly, use the NewConnectionBuilder function instead

func NewConnectionBuilder

func NewConnectionBuilder() *ConnectionBuilder

NewConnectionBuilder create an builder that knows how to create connections with the default configuration.

func (*ConnectionBuilder) Build

func (b *ConnectionBuilder) Build() (connection *Connection, err error)

Build uses the configuration stored in the builder to create a new connection. The builder can be reused to create multiple connections with the same configuration. It returns a pointer to the connection, and an error if something fails when trying to create it.

This operation is potentially lengthy, as it may require network communications. Consider using a context and the BuildContext method.

func (*ConnectionBuilder) BuildContext

func (b *ConnectionBuilder) BuildContext(ctx context.Context) (connection *Connection, err error)

BuildContext uses the configuration stored in the builder to create a new connection. The builder can be reused to create multiple connections with the same configuration. It returns a pointer to the connection, and an error if something fails when trying to create it. nolint:funlen

func (*ConnectionBuilder) DisableKeepAlives

func (b *ConnectionBuilder) DisableKeepAlives(flag bool) *ConnectionBuilder

DisableKeepAlives disables HTTP keep-alives with the server. This is unrelated to similarly named TCP keep-alives.

func (*ConnectionBuilder) WithAccessToken

func (b *ConnectionBuilder) WithAccessToken(accessToken string) *ConnectionBuilder

func (*ConnectionBuilder) WithAuthURL

func (b *ConnectionBuilder) WithAuthURL(authURL string) *ConnectionBuilder

func (*ConnectionBuilder) WithClientID

func (b *ConnectionBuilder) WithClientID(clientID string) *ConnectionBuilder

func (*ConnectionBuilder) WithConfig

func (b *ConnectionBuilder) WithConfig(cfg config.IConfig) *ConnectionBuilder

func (*ConnectionBuilder) WithConnectionConfig

func (b *ConnectionBuilder) WithConnectionConfig(cfg *connection.Config) *ConnectionBuilder

WithConnectionConfig contains config for the connection instance

func (*ConnectionBuilder) WithConsoleURL

func (b *ConnectionBuilder) WithConsoleURL(url string) *ConnectionBuilder

func (*ConnectionBuilder) WithInsecure

func (b *ConnectionBuilder) WithInsecure(insecure bool) *ConnectionBuilder

func (*ConnectionBuilder) WithLogger

func (b *ConnectionBuilder) WithLogger(logger logging.Logger) *ConnectionBuilder

func (*ConnectionBuilder) WithMASAccessToken

func (b *ConnectionBuilder) WithMASAccessToken(accessToken string) *ConnectionBuilder

func (*ConnectionBuilder) WithMASAuthURL

func (b *ConnectionBuilder) WithMASAuthURL(authURL string) *ConnectionBuilder

func (*ConnectionBuilder) WithMASRefreshToken

func (b *ConnectionBuilder) WithMASRefreshToken(refreshToken string) *ConnectionBuilder

func (*ConnectionBuilder) WithRefreshToken

func (b *ConnectionBuilder) WithRefreshToken(refreshToken string) *ConnectionBuilder

func (*ConnectionBuilder) WithScopes

func (b *ConnectionBuilder) WithScopes(scopes ...string) *ConnectionBuilder

func (*ConnectionBuilder) WithTransportWrapper

func (b *ConnectionBuilder) WithTransportWrapper(transportWrapper TransportWrapper) *ConnectionBuilder

func (*ConnectionBuilder) WithTrustedCAs

func (b *ConnectionBuilder) WithTrustedCAs(value *x509.CertPool) *ConnectionBuilder

func (*ConnectionBuilder) WithURL

func (b *ConnectionBuilder) WithURL(url string) *ConnectionBuilder

type MasAuthError

type MasAuthError struct {
	Err error
}

func (*MasAuthError) Error

func (e *MasAuthError) Error() string

func (*MasAuthError) Unwrap

func (e *MasAuthError) Unwrap() error

type TransportWrapper

type TransportWrapper func(http.RoundTripper) http.RoundTripper

TransportWrapper is a wrapper for a transport of type http.RoundTripper. Creating a transport wrapper, enables to preform actions and manipulations on the transport request and response.

Jump to

Keyboard shortcuts

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