Documentation ¶
Overview ¶
Package login defines the basic entrypoint required to perform a remote oauth login.
Index ¶
- Constants
- func ContextIdentity(ctx context.Context) (*uuid.UUID, error)
- func InjectTokenManager(tokenManager token.Manager) goa.Middleware
- type KeycloakLogoutService
- type KeycloakOAuthProvider
- func (keycloak *KeycloakOAuthProvider) CreateOrUpdateIdentity(ctx context.Context, accessToken string) (*account.Identity, bool, error)
- func (keycloak *KeycloakOAuthProvider) Link(ctx *app.LinkLinkContext, brokerEndpoint string, clientID string, ...) error
- func (keycloak *KeycloakOAuthProvider) LinkCallback(ctx *app.CallbackLinkContext, brokerEndpoint string, clientID string) error
- func (keycloak *KeycloakOAuthProvider) LinkSession(ctx *app.SessionLinkContext, brokerEndpoint string, clientID string, ...) error
- func (keycloak *KeycloakOAuthProvider) Perform(ctx *app.LoginLoginContext, config *oauth2.Config, ...) error
- type KeycloakOAuthService
- type KeycloakUserProfile
- type KeycloakUserProfileAttributes
- type KeycloakUserProfileClient
- type KeycloakUserProfileResponse
- type LoginServiceConfiguration
- type LogoutService
- type UserProfileService
Constants ¶
const ApprovedAttributeName = "approved"
const BioAttributeName = "bio"
const CompanyAttributeName = "company"
const ImageURLAttributeName = "imageURL"
const URLAttributeName = "url"
Variables ¶
This section is empty.
Functions ¶
func ContextIdentity ¶
ContextIdentity returns the identity's ID found in given context Uses tokenManager.Locate to fetch the identity of currently logged in user
func InjectTokenManager ¶
func InjectTokenManager(tokenManager token.Manager) goa.Middleware
InjectTokenManager is a middleware responsible for setting up tokenManager in the context for every request.
Types ¶
type KeycloakLogoutService ¶
type KeycloakLogoutService struct { }
KeycloakLogoutService represents a keycloak logout service
func (*KeycloakLogoutService) Logout ¶
func (s *KeycloakLogoutService) Logout(ctx *app.LogoutLogoutContext, logoutEndpoint string, validRedirectURL string) error
Logout logs out user
type KeycloakOAuthProvider ¶
type KeycloakOAuthProvider struct { Identities account.IdentityRepository Users account.UserRepository TokenManager token.Manager // contains filtered or unexported fields }
KeycloakOAuthProvider represents a keycloak IDP
func NewKeycloakOAuthProvider ¶
func NewKeycloakOAuthProvider(identities account.IdentityRepository, users account.UserRepository, tokenManager token.Manager, db application.DB) *KeycloakOAuthProvider
NewKeycloakOAuthProvider creates a new login.Service capable of using keycloak for authorization
func (*KeycloakOAuthProvider) CreateOrUpdateIdentity ¶
func (keycloak *KeycloakOAuthProvider) CreateOrUpdateIdentity(ctx context.Context, accessToken string) (*account.Identity, bool, error)
CreateOrUpdateIdentity creates a user and a keycloak identity. If the user and identity already exist then update them. Returns the user, identity and true if a new user and identity have been created
func (*KeycloakOAuthProvider) Link ¶
func (keycloak *KeycloakOAuthProvider) Link(ctx *app.LinkLinkContext, brokerEndpoint string, clientID string, validRedirectURL string) error
Link links identity provider(s) to the user's account using user's access token
func (*KeycloakOAuthProvider) LinkCallback ¶
func (keycloak *KeycloakOAuthProvider) LinkCallback(ctx *app.CallbackLinkContext, brokerEndpoint string, clientID string) error
LinkCallback redirects to original referrer when Identity Provider account are linked to the user account
func (*KeycloakOAuthProvider) LinkSession ¶
func (keycloak *KeycloakOAuthProvider) LinkSession(ctx *app.SessionLinkContext, brokerEndpoint string, clientID string, validRedirectURL string) error
LinkSession links identity provider(s) to the user's account using session state
func (*KeycloakOAuthProvider) Perform ¶
func (keycloak *KeycloakOAuthProvider) Perform(ctx *app.LoginLoginContext, config *oauth2.Config, serviceConfig LoginServiceConfiguration) error
Perform performs authentication
type KeycloakOAuthService ¶
type KeycloakOAuthService interface { Perform(ctx *app.LoginLoginContext, config *oauth2.Config, serviceConfig LoginServiceConfiguration) error CreateOrUpdateIdentity(ctx context.Context, accessToken string) (*account.Identity, bool, error) Link(ctx *app.LinkLinkContext, brokerEndpoint string, clientID string, validRedirectURL string) error LinkSession(ctx *app.SessionLinkContext, brokerEndpoint string, clientID string, validRedirectURL string) error LinkCallback(ctx *app.CallbackLinkContext, brokerEndpoint string, clientID string) error }
KeycloakOAuthService represents keycloak OAuth service interface
type KeycloakUserProfile ¶
type KeycloakUserProfile struct { ID *string `json:"id,omitempty"` CreatedAt int64 `json:"createdTimestamp,omitempty"` Username *string `json:"username,omitempty"` FirstName *string `json:"firstName,omitempty"` LastName *string `json:"lastName,omitempty"` Email *string `json:"email,omitempty"` Attributes *KeycloakUserProfileAttributes `json:"attributes,omitempty"` }
KeycloakUserProfile represents standard Keycloak User profile api request payload
func NewKeycloakUserProfile ¶
func NewKeycloakUserProfile(firstName *string, lastName *string, email *string, attributes *KeycloakUserProfileAttributes) *KeycloakUserProfile
NewKeycloakUserProfile creates a new keycloakUserProfile instance.
type KeycloakUserProfileAttributes ¶
KeycloakUserProfileAttributes represents standard Keycloak profile payload Attributes
type KeycloakUserProfileClient ¶
type KeycloakUserProfileClient struct {
// contains filtered or unexported fields
}
KeycloakUserProfileClient describes the interface between platform and Keycloak User profile service.
func NewKeycloakUserProfileClient ¶
func NewKeycloakUserProfileClient() *KeycloakUserProfileClient
NewKeycloakUserProfileClient creates a new KeycloakUserProfileClient
func (*KeycloakUserProfileClient) Get ¶
func (userProfileClient *KeycloakUserProfileClient) Get(ctx context.Context, accessToken string, keycloakProfileURL string) (*KeycloakUserProfileResponse, error)
Get gets the user profile information from Keycloak
func (*KeycloakUserProfileClient) Update ¶
func (userProfileClient *KeycloakUserProfileClient) Update(ctx context.Context, keycloakUserProfile *KeycloakUserProfile, accessToken string, keycloakProfileURL string) error
Update updates the user profile information in Keycloak
type KeycloakUserProfileResponse ¶
type KeycloakUserProfileResponse struct { ID *string `json:"id"` CreatedTimestamp *int64 `json:"createdTimestamp"` Username *string `json:"username"` Enabled *bool `json:"enabled"` Totp *bool `json:"totp"` EmailVerified *bool `json:"emailVerified"` FirstName *string `json:"firstName"` LastName *string `json:"lastName"` Email *string `json:"email"` Attributes *KeycloakUserProfileAttributes `json:"attributes"` DisableableCredentialTypes []*string `json:"disableableCredentialTypes"` RequiredActions []interface{} `json:"requiredActions"` }
KeycloakUserProfileResponse represents the user profile api response from keycloak
type LoginServiceConfiguration ¶
type LoginServiceConfiguration interface { GetKeycloakEndpointBroker(*goa.RequestData) (string, error) GetValidRedirectURLs() string GetNotApprovedRedirect() string GetWITURL(*goa.RequestData) (string, error) }
type LogoutService ¶
type LogoutService interface {
Logout(ctx *app.LogoutLogoutContext, logoutEndpoint string, validRedirectURL string) error
}
LogoutService represents logout service interface
type UserProfileService ¶
type UserProfileService interface { Update(ctx context.Context, conkeycloakUserProfile *KeycloakUserProfile, accessToken string, keycloakProfileURL string) error Get(ctx context.Context, accessToken string, keycloakProfileURL string) (*KeycloakUserProfileResponse, error) }
UserProfileService describes what the services need to be capable of doing.
Directories ¶
Path | Synopsis |
---|---|
Package token_context contains the code that extract token manager from the context.
|
Package token_context contains the code that extract token manager from the context. |