auth

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 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 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) *KeycloakClient

NewKeycloakClient creates a new KeycloakClient. Passed Credentials determines the used auth type.

func (*KeycloakClient) Config
func (c *KeycloakClient) Config() KeycloakConfig

Config returns the KeycloakConfig used by the 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.

func (*KeycloakClient) HTTPClient
func (c *KeycloakClient) HTTPClient() *http.Client

HTTPClient returns the underlying http.Client used by the KeycloakClient.

type KeycloakConfig

KeycloakConfig holds the credentials and configuration details

type KeycloakConfig struct {
    AuthURL string
    Realm   string
}

type ResourceOwnerCredentials

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

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 ClientCredentials added in v1.32.0

type ClientCredentials struct {
	ClientID     string
	ClientSecret string
}

ClientCredentials to authenticate via `Client credentials grant` flow. Ref: https://www.keycloak.org/docs/latest/server_admin/index.html#_client_credentials_grant

type Clock

type Clock interface {
	Now() time.Time
}

type Credentials added in v1.32.0

type Credentials interface {
	// contains filtered or unexported methods
}

Credentials holds the required credentials and determines the used auth type.

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, credentials Credentials) *KeycloakClient

NewKeycloakClient creates a new KeycloakClient. Passed Credentials determines the used auth type.

func (*KeycloakClient) Config added in v1.34.0

func (c *KeycloakClient) Config() KeycloakConfig

Config returns the KeycloakConfig used by the 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.

func (*KeycloakClient) HTTPClient added in v1.34.0

func (c *KeycloakClient) HTTPClient() *http.Client

HTTPClient returns the underlying http.Client used by the KeycloakClient.

type KeycloakConfig

type KeycloakConfig struct {
	AuthURL string
	Realm   string
}

KeycloakConfig holds the credentials and configuration details

type ResourceOwnerCredentials added in v1.32.0

type ResourceOwnerCredentials struct {
	ClientID string
	Username string
	Password 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

Jump to

Keyboard shortcuts

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