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 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 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.