Documentation
¶
Overview ¶
Package keycloak is a package for keycloak utility functions.
Index ¶
- type Client
- type ConcreteClient
- func (c *ConcreteClient) CreateUser(ctx context.Context, realm string, user *libregraph.User, ...) (string, error)
- func (c *ConcreteClient) GetPIIReport(ctx context.Context, realm, username string) (*PIIReport, error)
- func (c *ConcreteClient) GetUserByUsername(ctx context.Context, realm, username string) (*libregraph.User, error)
- func (c *ConcreteClient) SendActionsMail(ctx context.Context, realm, userID string, userActions []UserAction) error
- type GoCloak
- type PIIReport
- type UserAction
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