auth

package
v1.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

README

auth

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

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

Index

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) *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

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

type KeycloakClient

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

KeycloakClient can be used to authenticate against a Keycloak server.

func NewKeycloakClient

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

type KeycloakConfig

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

KeycloakConfig holds the credentials and configuration details

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL