Documentation ¶
Overview ¶
Package core provides the domain models and application services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct { Name string `json:"name"` URL string `json:"url"` Realm string `json:"realm"` ClientID string `json:"client_id"` Token gocloak.JWT `json:"token"` Created jwt.Time `json:"created_at"` SkipVerify bool `json:"skip_verify"` }
Session represents static session information, that are used to get access to resources of Keycloak.
func (*Session) CanBeRefreshed ¶
CanBeRefreshed returns true, if the access token can be refreshed using the refresh token, else false.
type SessionProvider ¶
type SessionProvider interface { // CreateWithUsernamePassword creates a new session by logging into the // service provider using a username and password. CreateWithUsernamePassword(name, url, realm, clientID, user, password string, skipVerify bool) (*Session, error) // CreateWithUsernamePassword creates a new session by logging into the // service provider using a client secret. CreateWithClientSecret(name, url, realm, clientID, secret string, skipVerify bool) (*Session, error) // Logout logs out of the session provider and thereby ending a session. End(session *Session) error // Refresh refreshes an existing session. Refresh(session *Session) (bool, error) }
SessionProvider provides the means to create, refresh and end a session.
type SessionRepository ¶
type SessionRepository interface { // Exists indicates that a session with a given name exists or not. Exists(name string) (bool, error) // Open opens the session repository with exclusive access. Open(name string) error // Close closes the session repository. Close() error // Read reads the content of the session repository. Read() (*Session, error) // Write writes a session to the repository. Write(session *Session) error // Remove removes a stored session repository. Has no effect, if the file // doesn't exist. Remove(name string) error }
SessionRepository is used for loading and storing from and to a repository. The access to the repository is managed to be exclusive between multiple processes.
type SessionService ¶
type SessionService interface { // Load loads a session from a stored session. Load(name string) (*Session, error) // LoadRefresh loads and refreshes a session. LoadRefresh(name string, refreshBeforeExpiry bool) (*Session, error) // CreateWithUsernamePassword creates a new session by loging into a session // provider with username and password. It also writes the newly created // session to a session repository. CreateWithUsernamePassword(name, url, realm, clientID, user, password string, skipVerify bool) (*Session, error) // CreateWithClientSecret creates a new session by loging into a session // provider with a client secret. It also writes the newly created session // to a session repository. CreateWithClientSecret(name, url, realm, clientID, secret string, skipVerify bool) (*Session, error) // Refresh refreshes a session, if it can be refreshed. Returns true, if the // access token was refreshed. Refresh(session *Session, beforeExpiry bool) (bool, error) // End ends the session and removes it from a session repository. End(session *Session, force bool) error }
SessionService manages the creation and destruction of Keycloak sessions.
func NewSessionService ¶
func NewSessionService(repo SessionRepository, provider SessionProvider) SessionService
NewSessionService initializes a `SessionService`.
Click to show internal directories.
Click to hide internal directories.