Skip to content

Latest commit

 

History

History
68 lines (46 loc) · 2.14 KB

File metadata and controls

68 lines (46 loc) · 2.14 KB

auth

import "github.com/greenbone/opensight-golang-libraries/pkg/auth"

Package auth provides a client to authenticate against a Keycloak server.

Index

KeycloakClient can be used to authenticate against a Keycloak server.

type KeycloakClient struct {
    // contains filtered or unexported fields
}

func NewKeycloakClient(httpClient *http.Client, cfg KeycloakConfig) *KeycloakClient

NewKeycloakClient 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

KeycloakConfig holds the credentials and configuration details

type KeycloakConfig struct {
    ClientID      string
    Username      string
    Password      string
    AuthURL       string
    KeycloakRealm string
}

Generated by gomarkdoc