import "github.com/greenbone/opensight-golang-libraries/pkg/auth"Package auth provides a client to authenticate against a Keycloak server.
- type ClientCredentials
- type Clock
- type Credentials
- type KeycloakClient
- type KeycloakConfig
- type ResourceOwnerCredentials
type ClientCredentials
ClientCredentials to authenticate via `Client credentials grant` flow. Ref: https://www.keycloak.org/docs/latest/server_admin/index.html#_client_credentials_grant
type ClientCredentials struct {
ClientID string
ClientSecret string
}type Clock
type Clock interface {
Now() time.Time
}type Credentials
Credentials holds the required credentials and determines the used auth type.
type Credentials interface {
// contains filtered or unexported methods
}type KeycloakClient
KeycloakClient can be used to authenticate against a Keycloak server.
type KeycloakClient struct {
// contains filtered or unexported fields
}func NewKeycloakClient
func NewKeycloakClient(httpClient *http.Client, cfg KeycloakConfig, credentials Credentials) *KeycloakClientNewKeycloakClient creates a new KeycloakClient. Passed Credentials determines the used auth type.
func (*KeycloakClient) GetToken
func (c *KeycloakClient) GetToken(ctx context.Context) (string, error)GetToken retrieves a valid access token. The token is cached and refreshed before expiry.
type KeycloakConfig
KeycloakConfig holds the credentials and configuration details
type KeycloakConfig struct {
AuthURL string
KeycloakRealm string
}ResourceOwnerCredentials to authenticate via `Resource owner password credentials grant` flow. Ref: https://www.keycloak.org/docs/latest/server_admin/index.html#_oidc-auth-flows-direct
type ResourceOwnerCredentials struct {
ClientID string
Username string
Password string
}Generated by gomarkdoc