keycloak

package
v1.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package keycloak is a package for keycloak utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	CreateUser(ctx context.Context, realm string, user *libregraph.User, userActions []UserAction) (string, error)
	SendActionsMail(ctx context.Context, realm, userID string, userActions []UserAction) error
	GetUserByUsername(ctx context.Context, realm, username string) (*libregraph.User, error)
	GetPIIReport(ctx context.Context, realm, username string) (*PIIReport, error)
}

Client represents a keycloak client.

type ConcreteClient

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

ConcreteClient represents a concrete implementation of a keycloak client

func New

func New(
	baseURL, clientID, clientSecret, realm string,
	insecureSkipVerify bool,
) *ConcreteClient

New instantiates a new keycloak.Backend with a default gocloak client.

func NewWithClient

func NewWithClient(
	gocloakClient GoCloak,
	baseURL, clientID, clientSecret, realm string,
) *ConcreteClient

NewWithClient instantiates a new keycloak.Backend with a custom

func (*ConcreteClient) CreateUser

func (c *ConcreteClient) CreateUser(ctx context.Context, realm string, user *libregraph.User, userActions []UserAction) (string, error)

CreateUser creates a user from a libregraph user and returns its *keycloak* ID. TODO: For now we only call this from the invitation service where all the attributes are set correctly.

For more wider use, do some sanity checking on the user instance.

func (*ConcreteClient) GetPIIReport

func (c *ConcreteClient) GetPIIReport(ctx context.Context, realm, username string) (*PIIReport, error)

GetPIIReport returns a structure with all the PII for the user.

func (*ConcreteClient) GetUserByUsername

func (c *ConcreteClient) GetUserByUsername(ctx context.Context, realm, username string) (*libregraph.User, error)

GetUserByUsername looks up a user by username.

func (*ConcreteClient) SendActionsMail

func (c *ConcreteClient) SendActionsMail(ctx context.Context, realm, userID string, userActions []UserAction) error

SendActionsMail sends a mail to the user with userID instructing them to do the actions defined in userActions.

type GoCloak

type GoCloak interface {
	CreateUser(ctx context.Context, token, realm string, user gocloak.User) (string, error)
	GetUsers(ctx context.Context, token, realm string, params gocloak.GetUsersParams) ([]*gocloak.User, error)
	ExecuteActionsEmail(ctx context.Context, token, realm string, params gocloak.ExecuteActionsEmail) error
	LoginClient(ctx context.Context, clientID, clientSecret, realm string, scopes ...string) (*gocloak.JWT, error)
	RetrospectToken(ctx context.Context, accessToken, clientID, clientSecret, realm string) (*gocloak.IntroSpectTokenResult, error)
	GetCredentials(ctx context.Context, accessToken, realm, userID string) ([]*gocloak.CredentialRepresentation, error)
	GetUserSessions(ctx context.Context, token, realm, userID string) ([]*gocloak.UserSessionRepresentation, error)
}

GoCloak represents the parts of gocloak.GoCloak that we use, mainly here for mockery.

type PIIReport

type PIIReport struct {
	UserData *libregraph.User
	Sessions []*gocloak.UserSessionRepresentation
}

PIIReport is a structure of all the PersonalIdentifiableInformation contained in keycloak.

type UserAction

type UserAction int8

UserAction defines a type for user actions

const (
	// UserActionUpdatePassword sets it that the user needs to change their password.
	UserActionUpdatePassword UserAction = iota
	// UserActionVerifyEmail sets it that the user needs to verify their email address.
	UserActionVerifyEmail
)

An incomplete list of UserActions

Jump to

Keyboard shortcuts

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