Documentation
¶
Index ¶
- type KClient
- func (client *KClient) Authenticate(clientId string, clientSecret string) error
- func (client *KClient) CreateUser(opts *KUserCreateOpts) (*KUser, error)
- func (client *KClient) GetOpenIDToken(grantType KGrantType, opts *KTokenOpts) (*KToken, error)
- func (client *KClient) IntrospectToken(token string) (*KIntrospectionResponse, bool)
- func (client *KClient) InvalidateToken(refreshToken string) error
- func (client *KClient) RefreshToken(accessToken string, refreshToken string) (*KToken, error)
- func (client *KClient) SignInWithPassword(opts *KSignInOpts) (*KToken, error)
- func (client *KClient) UpdateUser(token string, opts *KUserUpdateOpts) (*KUser, error)
- func (client *KClient) UserInfo(token string) (*KUserInfo, bool)
- type KGrantType
- type KIntrospectionResponse
- type KSignInOpts
- type KToken
- type KTokenError
- type KTokenOpts
- type KUser
- type KUserCreateOpts
- type KUserCredential
- type KUserError
- type KUserInfo
- type KUserUpdateOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KClient ¶
type KClient struct {
Domain string
Realm string
BaseURL string
AdminURL string
ClientID string
ClientSecret string
ClientToken *KToken
}
func NewFromEnv ¶
Initializes your Keycloak instance config from the following environment variables.
- KC_DOMAIN=example.org
- KC_REALM=example
func (*KClient) Authenticate ¶
Authenticates your Keycloak client using the clientId and clientSecret values
func (*KClient) CreateUser ¶
func (client *KClient) CreateUser(opts *KUserCreateOpts) (*KUser, error)
Creates a new user inside the realm you set in your instance config.
Client has to be previously authenticated using the Authenticate() method
func (*KClient) GetOpenIDToken ¶
func (client *KClient) GetOpenIDToken(grantType KGrantType, opts *KTokenOpts) (*KToken, error)
Retrieves a new JWT token from Keycloak using KTokenOptions
Avoid using this method directly
func (*KClient) IntrospectToken ¶
func (client *KClient) IntrospectToken(token string) (*KIntrospectionResponse, bool)
Executes a token introspection
func (*KClient) InvalidateToken ¶
Invalidates the token session
func (*KClient) RefreshToken ¶
Validates the given accessToken and tries to refresh it if invalid
func (*KClient) SignInWithPassword ¶
func (client *KClient) SignInWithPassword(opts *KSignInOpts) (*KToken, error)
Retrieves a token for the user with the provided username, password and optional totp
func (*KClient) UpdateUser ¶
func (client *KClient) UpdateUser(token string, opts *KUserUpdateOpts) (*KUser, error)
Updates the user inside the realm you set in your instance config.
Client has to be previously authenticated using the Authenticate() method
type KGrantType ¶
type KGrantType string
const ( KGrantTypeAuthCode KGrantType = "authorization_code" KGrantTypeClient KGrantType = "client_credentials" KGrantTypePassword KGrantType = "password" KGrantTypeRefresh KGrantType = "refresh_token" )
type KIntrospectionResponse ¶
type KSignInOpts ¶
type KTokenError ¶
type KTokenError struct {
Message string `json:"error_description"`
}
type KTokenOpts ¶
type KUserCreateOpts ¶
type KUserCredential ¶
type KUserError ¶
type KUserError struct {
Message string `json:"errorMessage"`
}