Documentation ¶
Index ¶
- Constants
- func CreateQueryPlugins(paramKV ...string) []plugin.Plugin
- func SetAccessToken(accessToken string) plugin.Plugin
- func SetAccessTokenE(accessToken string) (plugin.Plugin, error)
- type Client
- func New(addrAPI string, reqTimeout time.Duration, ...) (*Client, error)
- func NewBasicAuthClient(addrAPI string, reqTimeout time.Duration, username, password string) (*Client, error)
- func NewBearerAuthClient(addrAPI string, reqTimeout time.Duration, tokenProvider func() (string, error)) (*Client, error)
- type HTTPError
- type MultiRealmTokenClient
- func (mrtc *MultiRealmTokenClient) Delete(plugins ...plugin.Plugin) error
- func (mrtc *MultiRealmTokenClient) ForRealm(realm string) RestClient
- func (mrtc *MultiRealmTokenClient) Get(data interface{}, plugins ...plugin.Plugin) error
- func (mrtc *MultiRealmTokenClient) Post(data interface{}, plugins ...plugin.Plugin) (string, error)
- func (mrtc *MultiRealmTokenClient) Put(plugins ...plugin.Plugin) error
- type OidcTokenProvider
- type RestClient
- type Token
Constants ¶
const ( MsgErrCannotObtain = "cannotObtain" MsgErrCannotUnmarshal = "cannotUnmarshal" MsgErrCannotParse = "cannotParse" MsgErrUnkownHTTPContentType = "unkownHTTPContentType" MsgErrUnknownResponseStatusCode = "unknownResponseStatusCode" PrmTokenProviderURL = "tokenProviderURL" PrmAPIURL = "APIURL" PrmTokenMsg = "token" PrmResponse = "response" )
Constants for error management
Variables ¶
This section is empty.
Functions ¶
func CreateQueryPlugins ¶
CreateQueryPlugins create query parameters with the key values paramKV.
func SetAccessToken ¶
SetAccessToken creates a plugin to set an access token which is a valid token
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the HTTP client.
func New ¶
func New(addrAPI string, reqTimeout time.Duration, reqUpdaters ...func(*gentleman.Request) (*gentleman.Request, error)) (*Client, error)
New returns a keycloak client.
func NewBasicAuthClient ¶
func NewBasicAuthClient(addrAPI string, reqTimeout time.Duration, username, password string) (*Client, error)
NewBasicAuthClient creates a new HTTP client using a basic authentication
func NewBearerAuthClient ¶
func NewBearerAuthClient(addrAPI string, reqTimeout time.Duration, tokenProvider func() (string, error)) (*Client, error)
NewBearerAuthClient creates a new HTTP client using a bearer authentication
type HTTPError ¶
HTTPError is returned when an error occured while contacting the keycloak instance.
func (HTTPError) ErrorMessage ¶
ErrorMessage returns the HTTP error message
func (HTTPError) IsErrorFromClient ¶
IsErrorFromClient is true when HTTP request failed and the cause was related to the client request
func (HTTPError) IsErrorFromServer ¶
IsErrorFromServer is true when HTTP request failed and the cause was related to the HTTP server
type MultiRealmTokenClient ¶ added in v1.1.0
type MultiRealmTokenClient struct {
// contains filtered or unexported fields
}
func NewMultiRealmTokenClient ¶ added in v1.1.0
func NewMultiRealmTokenClient(addrAPI string, reqTimeout time.Duration, tokenProvider OidcTokenProvider) (*MultiRealmTokenClient, error)
func (*MultiRealmTokenClient) Delete ¶ added in v1.1.0
func (mrtc *MultiRealmTokenClient) Delete(plugins ...plugin.Plugin) error
Delete is a HTTP DELETE method
func (*MultiRealmTokenClient) ForRealm ¶ added in v1.1.0
func (mrtc *MultiRealmTokenClient) ForRealm(realm string) RestClient
func (*MultiRealmTokenClient) Get ¶ added in v1.1.0
func (mrtc *MultiRealmTokenClient) Get(data interface{}, plugins ...plugin.Plugin) error
Get is a HTTP GET method.
type OidcTokenProvider ¶ added in v1.1.0
type OidcTokenProvider interface { ProvideToken(ctx context.Context) (string, error) ProvideTokenForRealm(ctx context.Context, realm string) (string, error) }
OidcTokenProvider provides OIDC tokens
type RestClient ¶ added in v1.1.0
type RestClient interface { Get(data interface{}, plugins ...plugin.Plugin) error Post(data interface{}, plugins ...plugin.Plugin) (string, error) Delete(plugins ...plugin.Plugin) error Put(plugins ...plugin.Plugin) error }
RestClient interface
type Token ¶
type Token struct { Issuer string `json:"iss,omitempty"` Subject string `json:"sub,omitempty"` ExpirationTime int64 `json:"exp,omitempty"` NotBefore int64 `json:"nbf,omitempty"` IssuedAt int64 `json:"iat,omitempty"` ID string `json:"jti,omitempty"` Username string `json:"preferred_username,omitempty"` // contains filtered or unexported fields }
Token is JWT token. We need to define our own structure as the library define aud as a string but it can also be a string array. To fix this issue, we remove aud as we do not use it here.