keycloak

package
v0.0.0-...-cd501f3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGlobalHelper

func NewGlobalHelper(opts ...Option) error

Types

type Auth

type Auth struct {
	Realm    string `json:"realm" yaml:"realm"`
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
}

type Client

type Client interface {
	RestyClient() *resty.Client
	Login(context.Context, string, string, string, string, string) (*gocloak.JWT, error)
	LoginAdmin(context.Context, string, string, string) (*gocloak.JWT, error)
	GetUsers(context.Context, string, string, gocloak.GetUsersParams) ([]*gocloak.User, error)
	GetClients(context.Context, string, string, gocloak.GetClientsParams) ([]*gocloak.Client, error)
	CreateClient(context.Context, string, string, gocloak.Client) (string, error)
	CreateClientProtocolMapper(context.Context, string, string, string, gocloak.ProtocolMapperRepresentation) (string, error)
	GetClientSecret(ctx context.Context, token, realm, idOfClient string) (*gocloak.CredentialRepresentation, error)
	CreateUser(context.Context, string, string, gocloak.User) (string, error)
	SetPassword(context.Context, string, string, string, string, bool) error
	UpdateUser(context.Context, string, string, gocloak.User) error
	GetClientRole(ctx context.Context, token string, realm string, idOfClient string, roleName string) (*gocloak.Role, error)
	AddClientRolesToUser(ctx context.Context, token string, realm string, idOfClient string, userID string, roles []gocloak.Role) error
	GetGroups(ctx context.Context, token string, realm string, params gocloak.GetGroupsParams) ([]*gocloak.Group, error)
	AddUserToGroup(ctx context.Context, token string, realm string, userID string, groupID string) error
	DeleteUserFromGroup(ctx context.Context, token string, realm string, userID string, groupID string) error
	GetRealmRole(ctx context.Context, token string, realm string, roleName string) (*gocloak.Role, error)
	AddRealmRoleToUser(ctx context.Context, token string, realm string, userID string, roles []gocloak.Role) error
	LogoutUserSession(context.Context, string, string, string) error
}

type Helper

type Helper struct {
	Client
	Token string

	Options
}

func GetGlobalHelper

func GetGlobalHelper() *Helper

func NewHelper

func NewHelper(opts ...Option) (*Helper, error)

func (*Helper) AddClientRolesToUser

func (h *Helper) AddClientRolesToUser(realm, clientId, userID string, roles []gocloak.Role) error

func (*Helper) AddRealmRoleToUser

func (h *Helper) AddRealmRoleToUser(realm, userID string, roles []gocloak.Role) error

func (*Helper) AddUserToGroup

func (h *Helper) AddUserToGroup(realm, userID, groupID string) error

func (*Helper) CreateClient

func (h *Helper) CreateClient(realm string, opts gocloak.Client) (string, error)

func (*Helper) CreateClientProtocolMapper

func (h *Helper) CreateClientProtocolMapper(realm, clientId string, opts gocloak.ProtocolMapperRepresentation) (string, error)

func (*Helper) CreateUser

func (h *Helper) CreateUser(realm string, user gocloak.User) (string, error)

func (*Helper) DeleteUserFromGroup

func (h *Helper) DeleteUserFromGroup(realm, userID, groupID string) error

func (*Helper) GetClientRole

func (h *Helper) GetClientRole(realm, clientId, roleName string) (*gocloak.Role, error)

func (*Helper) GetClientSecret

func (h *Helper) GetClientSecret(realm, clientId string) (*gocloak.CredentialRepresentation, error)

func (*Helper) GetClients

func (h *Helper) GetClients(realm string, params gocloak.GetClientsParams) ([]*gocloak.Client, error)

func (*Helper) GetGroup

func (h *Helper) GetGroup(realm, name string) (*gocloak.Group, error)

func (*Helper) GetGroups

func (h *Helper) GetGroups(realm string, params gocloak.GetGroupsParams) ([]*gocloak.Group, error)

func (*Helper) GetRealmRole

func (h *Helper) GetRealmRole(realm, roleName string) (*gocloak.Role, error)

func (*Helper) GetUser

func (h *Helper) GetUser(realm, name string) (*gocloak.User, error)

func (*Helper) LoginAdmin

func (h *Helper) LoginAdmin() error

func (*Helper) LogoutUserSession

func (h *Helper) LogoutUserSession(realm, sessionID string) error

func (*Helper) SetKeycloakClient

func (h *Helper) SetKeycloakClient() error

func (*Helper) SetPassword

func (h *Helper) SetPassword(realm, userID, password string) error

func (*Helper) UpdateUser

func (h *Helper) UpdateUser(realm string, user gocloak.User) error

type Host

type Host struct {
	Scheme                string `json:"scheme" yaml:"scheme"`
	Ip                    string `json:"ip" yaml:"ip"`
	Port                  int    `json:"port" yaml:"port"`
	Path                  string `json:"path" yaml:"path"`
	TlsInsecureSkipVerify bool   `json:"tlsInsecureSkipVerify" yaml:"tlsInsecureSkipVerify"`
}

type Option

type Option func(*Options)

func Insecure

func Insecure(insecure bool) Option

func Ip

func Ip(ip string) Option

func Password

func Password(password string) Option

func Path

func Path(path string) Option

func Port

func Port(port int) Option

func Realm

func Realm(realm string) Option

func Scheme

func Scheme(scheme string) Option

func Username

func Username(username string) Option

type Options

type Options struct {
	Host `json:"host" yaml:"host"`
	Auth `json:"auth" yaml:"auth"`
}

Jump to

Keyboard shortcuts

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