keycloak

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoneOfConstructorArgsCanBeEmpty             = errors.New("none of the arguments can be empty; neither 'Realm', 'User', 'Password', 'BaseURI' or 'Port'")
	ErrResponseBodyMapNotContainKeyAccessToken     = errors.New("response body map does not contain key 'access_token'")
	ErrResponseBodyMapNotContainKeyRefreshToken    = errors.New("response body map does not contain key 'refresh_token'")
	ErrResponseBodyMapNotContainKeyPgcdiPrivileges = errors.New("response body map does not contain key 'pgcdi_privileges'")

	TemplateForErrorCannotCreateClusterInvalidRole    = "User '%s' is not allowed to create cluster. Only users assigned to role '%s' can create cluster. User roles: '%s'"
	TemplateForErrorCannotCreateClusterRealmsDiffer   = "Cannot create cluster. User realm and tenant differ. Realm: '%s', tenant: '%s'"
	TemplateForErrorCannotCreateClusterInDefaultRealm = "User '%s' is not allowed to create cluster in master realm '%s'"
)

Functions

This section is empty.

Types

type Keycloak

type Keycloak interface {
	IsInit() bool
	InitConnection() error
	UserIsAllowedToCreateCluster() error
	GetToken() string
}

type KeycloakClient

type KeycloakClient struct {
	Realm        string
	UserName     string
	UserPassword string

	AccessToken  string
	RefreshToken string
	// contains filtered or unexported fields
}

func NewKeycloak

func NewKeycloak(realm, userName, userPassword, baseURI, endpoint string) (*KeycloakClient, error)

NewKeycloak Creates and returns a new instance of the Keycloak

func (*KeycloakClient) GetToken

func (k *KeycloakClient) GetToken() string

GetToken Returns bearer token.

func (*KeycloakClient) InitConnection

func (k *KeycloakClient) InitConnection() error

InitConnection Init connection with Keycloak service. In this method bearer token is taken

func (*KeycloakClient) IsInit

func (k *KeycloakClient) IsInit() bool

func (*KeycloakClient) String

func (k *KeycloakClient) String() string

func (*KeycloakClient) UserIsAllowedToCreateCluster

func (k *KeycloakClient) UserIsAllowedToCreateCluster() error

UserIsAllowedToCreateCluster Verify if user is allowed to create cluster

type KeycloakHttpError

type KeycloakHttpError struct {
	Message string
	Code    int
}

func (*KeycloakHttpError) Error

func (e *KeycloakHttpError) Error() string

Implement the Error() method for the error interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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