sso

package
v0.0.0-...-5c487ac Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account interface {
	GetSingleSignOnUser(accessToken string) (entity.SSOUser, error)
}

Account accesses account data from the identity provider.

type AccountFake

type AccountFake struct {
	// contains filtered or unexported fields
}

AccountFake represents in memory implementation of account service that access account data from the identity provider.

func NewAccountFake

func NewAccountFake(user entity.SSOUser) AccountFake

NewAccountFake creates fake Account service.

func (AccountFake) GetSingleSignOnUser

func (a AccountFake) GetSingleSignOnUser(accessToken string) (entity.SSOUser, error)

GetSingleSignOnUser retrieves user information from identity provider using access token.

type AccountLinker

type AccountLinker struct {
	// contains filtered or unexported fields
}

AccountLinker maps external user accounts to Short user accounts.

func (AccountLinker) CreateAndLinkAccount

func (a AccountLinker) CreateAndLinkAccount(ssoUser entity.SSOUser) error

CreateAndLinkAccount creates an internal account when there is no internal account sharing the same email as the given external account and link them together afterwards.

func (AccountLinker) GetShortUser

func (a AccountLinker) GetShortUser(ssoUser entity.SSOUser) (entity.User, error)

GetShortUser fetches the internal user linked to the given external user.

func (AccountLinker) IsAccountLinked

func (a AccountLinker) IsAccountLinked(ssoUser entity.SSOUser) (bool, error)

IsAccountLinked checks whether a given external account is linked to any internal users already.

type AccountLinkerFactory

type AccountLinkerFactory struct {
	// contains filtered or unexported fields
}

AccountLinkerFactory creates AccountLinker.

func NewAccountLinkerFactory

func NewAccountLinkerFactory(
	keyGen keygen.KeyGenerator,
	userRepo repository.User,
) AccountLinkerFactory

NewAccountLinkerFactory creates AccountLinkerFactory.

func (AccountLinkerFactory) NewAccountLinker

func (a AccountLinkerFactory) NewAccountLinker(
	ssoMap repository.SSOMap,
) AccountLinker

NewAccountLinker creates a new account linker.

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory makes SingleSignOn.

func NewFactory

func NewFactory(
	authenticator authenticator.Authenticator,
) Factory

NewFactory creates single sign on factory.

func (Factory) NewSingleSignOn

func (s Factory) NewSingleSignOn(
	identityProvider IdentityProvider,
	account Account,
	accountLinker AccountLinker,
) SingleSignOn

NewSingleSignOn creates SingleSignOn.

type IdentityProvider

type IdentityProvider interface {
	GetAuthorizationURL() string
	RequestAccessToken(authorizationCode string) (accessToken string, err error)
}

IdentityProvider represents external service that verifies the user's identity.

type IdentityProviderFake

type IdentityProviderFake struct {
	// contains filtered or unexported fields
}

IdentityProviderFake represents in memory implementation of an external authentication service.

func NewIdentityProviderFake

func NewIdentityProviderFake(authURL string, accessToken string) IdentityProviderFake

NewIdentityProviderFake creates fake IdentityProvider.

func (IdentityProviderFake) GetAuthorizationURL

func (i IdentityProviderFake) GetAuthorizationURL() string

GetAuthorizationURL retrieves the URL where user can sign in and obtain authorization code.

func (IdentityProviderFake) RequestAccessToken

func (i IdentityProviderFake) RequestAccessToken(authorizationCode string) (accessToken string, err error)

RequestAccessToken retrieves access token given authorization code.

type SingleSignOn

type SingleSignOn struct {
	// contains filtered or unexported fields
}

SingleSignOn enables sign in through external identity providers, such as Github, Facebook, and Google.

func (o SingleSignOn) GetSignInLink() string

GetSignInLink retrieves the sign in link of the external account provider.

func (SingleSignOn) IsSignedIn

func (o SingleSignOn) IsSignedIn(authToken string) bool

IsSignedIn checks whether a user is authenticated by Short.

func (SingleSignOn) SignIn

func (o SingleSignOn) SignIn(authorizationCode string) (string, error)

SignIn generates access token for a user using authorization code obtained from external identity provider.

Jump to

Keyboard shortcuts

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