login

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2017 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package login defines the basic entrypoint required to perform a remote oauth login.

Index

Constants

View Source
const ApprovedAttributeName = "approved"
View Source
const BioAttributeName = "bio"
View Source
const CompanyAttributeName = "company"
View Source
const ImageURLAttributeName = "imageURL"
View Source
const URLAttributeName = "url"

Variables

This section is empty.

Functions

func ContextIdentity

func ContextIdentity(ctx context.Context) (*uuid.UUID, error)

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 keyclaok 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 keyclaok 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) CreateOrUpdateKeycloakUser

func (keycloak *KeycloakOAuthProvider) CreateOrUpdateKeycloakUser(accessToken string, ctx context.Context, profileEndpoint string) (*account.Identity, *account.User, error)

CreateOrUpdateKeycloakUser creates a user and a keyclaok identity. If the user and identity already exist then update them.

func (keycloak *KeycloakOAuthProvider) Link(ctx *app.LinkLoginContext, 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.LinkcallbackLoginContext, 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.LinksessionLoginContext, 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.AuthorizeLoginContext, config *oauth2.Config, brokerEndpoint string, entitlementEndpoint string, profileEndpoint string, validRedirectURL string, userNotApprovedRedirectURL string) error

Perform performs authentication

type KeycloakOAuthService

type KeycloakOAuthService interface {
	Perform(ctx *app.AuthorizeLoginContext, config *oauth2.Config, brokerEndpoint string, entitlementEndpoint string, profileEndpoint string, validRedirectURL string, userNotApprovedRedirectURL string) error
	CreateOrUpdateKeycloakUser(accessToken string, ctx context.Context, profileEndpoint string) (*account.Identity, *account.User, error)
	Link(ctx *app.LinkLoginContext, brokerEndpoint string, clientID string, validRedirectURL string) error
	LinkSession(ctx *app.LinksessionLoginContext, brokerEndpoint string, clientID string, validRedirectURL string) error
	LinkCallback(ctx *app.LinkcallbackLoginContext, 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

type KeycloakUserProfileAttributes map[string][]string

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(accessToken string, keycloakProfileURL string) (*KeycloakUserProfileResponse, error)

Get gets the user profile information from Keycloak

func (*KeycloakUserProfileClient) Update

func (userProfileClient *KeycloakUserProfileClient) Update(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 LogoutService

type LogoutService interface {
	Logout(ctx *app.LogoutLogoutContext, logoutEndpoint string, validRedirectURL string) error
}

LogoutService represents logout service interface

type UserProfileService

type UserProfileService interface {
	Update(keycloakUserProfile *KeycloakUserProfile, accessToken string, keycloakProfileURL string) error
	Get(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.

Jump to

Keyboard shortcuts

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