import "github.com/greenbone/opensight-golang-libraries/pkg/auth"Package auth provides a client to authenticate against a Keycloak server.
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) *KeycloakClientNewKeycloakClient creates a new KeycloakClient.
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. The token is obtained by `Resource owner password credentials grant` flow. Ref: https://www.keycloak.org/docs/latest/server_admin/index.html#_oidc-auth-flows-direct
type KeycloakConfig
KeycloakConfig holds the credentials and configuration details
type KeycloakConfig struct {
ClientID string
Username string
Password string
AuthURL string
KeycloakRealm string
}Generated by gomarkdoc