service

package
v0.0.0-...-dfaa8e5 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const ApplicationWatcherChannel = "application"
View Source
const OneTimeTokenStoragePattern = "ott_data_%s"

Variables

View Source
var (
	ErrorInvalidSocialProviderName = "Invalid identity provider: %s"
	ErrorInvalidTemplate           = "Identity provider [%s] template not found"
	ErrorFuncNumberParameters      = "The number of parameters is not adapted"
)

Functions

This section is empty.

Types

type AppIdentityProviderService

type AppIdentityProviderService struct {
}

AppIdentityProviderService is the AppIdentityProvider service.

func NewAppIdentityProviderService

func NewAppIdentityProviderService() *AppIdentityProviderService

NewAppIdentityProviderService return new AppIdentityProvider service.

func (AppIdentityProviderService) FindByType

func (AppIdentityProviderService) FindByTypeAndName

func (s AppIdentityProviderService) FindByTypeAndName(app *models.Application, connType string, name string) *models.AppIdentityProvider

func (AppIdentityProviderService) Get

func (*AppIdentityProviderService) GetAllTemplates

func (s *AppIdentityProviderService) GetAllTemplates() []*models.AppIdentityProvider

func (*AppIdentityProviderService) GetAuthUrl

func (s *AppIdentityProviderService) GetAuthUrl(domain string, ip *models.AppIdentityProvider, form interface{}) (string, error)

func (*AppIdentityProviderService) GetAvailableTemplates

func (s *AppIdentityProviderService) GetAvailableTemplates() []string

func (*AppIdentityProviderService) GetSocialProfile

func (*AppIdentityProviderService) GetTemplate

func (AppIdentityProviderService) NormalizeSocialConnection

func (s AppIdentityProviderService) NormalizeSocialConnection(ipc *models.AppIdentityProvider) error

type AppIdentityProviderServiceInterface

type AppIdentityProviderServiceInterface interface {
	// Get return the identity provider by application and provider id.
	Get(*models.Application, bson.ObjectId) *models.AppIdentityProvider

	// FindByType find and return list of identity providers by type.
	FindByType(*models.Application, string) []*models.AppIdentityProvider

	// FindByTypeAndName find and return list of identity provider by name and type.
	FindByTypeAndName(*models.Application, string, string) *models.AppIdentityProvider

	// NormalizeSocialConnection fills in the default fields for social providers.
	NormalizeSocialConnection(*models.AppIdentityProvider) error

	// GetAvailableTemplates return list of string with available social networks.
	GetAvailableTemplates() []string

	// GetAllTemplates returns a list of social providers with default values for each provider.
	GetAllTemplates() []*models.AppIdentityProvider

	// GetTemplate returns a social provider with default values.
	GetTemplate(string) (*models.AppIdentityProvider, error)

	// GetAuthUrl generates an authorization string for the social provider oauth2.
	GetAuthUrl(string, *models.AppIdentityProvider, interface{}) (string, error)

	// GetSocialProfile swaps the authorization code for an access token on a social network and gets a user profile in it.
	GetSocialProfile(context.Context, string, string, *models.AppIdentityProvider) (*models.UserIdentitySocial, error)
}

AppIdentityProviderServiceInterface describes of methods for the AppIdentityProviderService.

type ApplicationService

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

ApplicationService is the Application service.

func NewApplicationService

func NewApplicationService(r InternalRegistry) *ApplicationService

NewApplicationService return new Application service.

func (ApplicationService) AddIdentityProvider

func (s ApplicationService) AddIdentityProvider(app *models.Application, ip *models.AppIdentityProvider) error

func (ApplicationService) Create

func (s ApplicationService) Create(app *models.Application) error

func (ApplicationService) Get

func (ApplicationService) LoadMfaConnection

func (s ApplicationService) LoadMfaConnection(connection string) ([]*models.MfaConnection, error)

func (ApplicationService) LoadSocialSettings

func (s ApplicationService) LoadSocialSettings() (*models.SocialSettings, error)

func (ApplicationService) Update

func (s ApplicationService) Update(app *models.Application) error

func (ApplicationService) UpdateIdentityProvider

func (s ApplicationService) UpdateIdentityProvider(app *models.Application, ip *models.AppIdentityProvider) error

type ApplicationServiceInterface

type ApplicationServiceInterface interface {
	// Create is creating a new application.
	Create(*models.Application) error

	// Update is updating a application.
	Update(*models.Application) error

	// Get return the application by id.
	Get(bson.ObjectId) (*models.Application, error)

	// LoadSocialSettings return settings for generate one-time token on social network.
	LoadSocialSettings() (*models.SocialSettings, error)

	// LoadMfaConnection return settings for mfa providers.
	LoadMfaConnection(string) ([]*models.MfaConnection, error)

	// AddIdentityProvider adds the identity of the provider to the list available for the application.
	AddIdentityProvider(*models.Application, *models.AppIdentityProvider) error

	// UpdateIdentityProvider updates the provider identity of the application.
	UpdateIdentityProvider(*models.Application, *models.AppIdentityProvider) error
}

ApplicationServiceInterface describes of methods for the ApplicationService.

type AuthLogService

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

AuthLogService is the AuthLog service.

func NewAuthLogService

func NewAuthLogService(h database.MgoSession) *AuthLogService

NewAuthLogService return new AuthLog service.

func (AuthLogService) Add

func (s AuthLogService) Add(ipAddr string, userAgent string, user *models.User) error

type AuthLogServiceInterface

type AuthLogServiceInterface interface {
	// Add adds an authorization log for the user.
	Add(string, string, *models.User) error
}

AuthLogServiceInterface describes of methods for the AuthLog service.

type HydraAdminApi

type HydraAdminApi interface {
	// CreateOAuth2Client creates an o auth 2 0 client.
	CreateOAuth2Client(*admin.CreateOAuth2ClientParams) (*admin.CreateOAuth2ClientCreated, error)

	// GetOAuth2Client gets an o auth 2 0 client.
	GetOAuth2Client(*admin.GetOAuth2ClientParams) (*admin.GetOAuth2ClientOK, error)

	// UpdateOAuth2Client updates an o auth 2 0 client.
	UpdateOAuth2Client(*admin.UpdateOAuth2ClientParams) (*admin.UpdateOAuth2ClientOK, error)

	// GetLoginRequest gets an login request.
	GetLoginRequest(*admin.GetLoginRequestParams) (*admin.GetLoginRequestOK, error)

	// AcceptLoginRequest accepts an login request.
	AcceptLoginRequest(*admin.AcceptLoginRequestParams) (*admin.AcceptLoginRequestOK, error)

	// GetConsentRequest gets consent request information.
	GetConsentRequest(*admin.GetConsentRequestParams) (*admin.GetConsentRequestOK, error)

	// AcceptConsentRequest accepts an consent request.
	AcceptConsentRequest(*admin.AcceptConsentRequestParams) (*admin.AcceptConsentRequestOK, error)

	// IntrospectOAuth2Token introspects o auth2 tokens.
	IntrospectOAuth2Token(*admin.IntrospectOAuth2TokenParams, runtime.ClientAuthInfoWriter) (*admin.IntrospectOAuth2TokenOK, error)
}

HydraAdminApi describes of methods for the Hydra administration api. See the documentation for the methods in Hydra - https://www.ory.sh/docs/next/hydra/sdk/api

type InternalRegistry

type InternalRegistry interface {
	// Watcher creates and return watcher service.
	Watcher() persist.Watcher

	// MgoSession return the Mongo session.
	MgoSession() database.MgoSession

	// HydraAdminApi return the client of the Hydra administration api.
	HydraAdminApi() HydraAdminApi

	// MfaService return the client of MFA micro-service.
	MfaService() MfaApiInterface

	// ApplicationService return instance of the application service.
	ApplicationService() ApplicationServiceInterface

	// OneTimeTokenService return instance of the one time token service.
	OneTimeTokenService() OneTimeTokenServiceInterface

	// Mailer return client of the postman service.
	Mailer() MailerInterface
}

InternalRegistry describes of methods the registry service.

func NewRegistryBase

func NewRegistryBase(config *RegistryConfig) InternalRegistry

NewRegistryBase creates new registry service.

type Mailer

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

Mailer is the mailer service.

func (*Mailer) Send

func (mailer *Mailer) Send(to, subject, body string) (err error)

type MailerInterface

type MailerInterface interface {
	// Send sends mail for the specified email address with the specified header and content.
	Send(to, subject, body string) error
}

MailerInterface describes of methods for the mailer.

func NewMailer

func NewMailer(config *config.Mailer) (mailer MailerInterface)

NewMailer return new mailer service.

type MfaApiInterface

type MfaApiInterface interface {
	Create(ctx context.Context, in *mfa.MfaCreateDataRequest, opts ...client.CallOption) (*mfa.MfaCreateDataResponse, error)
	Check(ctx context.Context, in *mfa.MfaCheckDataRequest, opts ...client.CallOption) (*mfa.MfaCheckDataResponse, error)
}

MfaApiInterface describes of methods for the mfa micro-service. See more on https://github.com/ProtocolONE/mfa-service.

type MfaService

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

MfaService is the mfa service.

func NewMfaService

func NewMfaService(dbHandler database.MgoSession) *MfaService

NewMfaService return new mfa service.

func (MfaService) Add

func (s MfaService) Add(provider *models.MfaProvider) error

func (*MfaService) AddUserProvider

func (s *MfaService) AddUserProvider(up *models.MfaUserProvider) error

func (*MfaService) Get

func (s *MfaService) Get(id bson.ObjectId) (provider *models.MfaProvider, err error)

func (*MfaService) GetUserProviders

func (s *MfaService) GetUserProviders(u *models.User) (providers []*models.MfaProvider, err error)

func (*MfaService) List

func (s *MfaService) List(appId bson.ObjectId) (providers []*models.MfaProvider, err error)

func (*MfaService) RemoveUserProvider

func (s *MfaService) RemoveUserProvider(provider *models.MfaUserProvider) error

type MfaServiceInterface

type MfaServiceInterface interface {
	// Add adds a new MFA provider for the application.
	Add(*models.MfaProvider) error

	// List returns a list of available mfa providers for the application.
	List(bson.ObjectId) ([]*models.MfaProvider, error)

	// // Get return the mfa providers by id.
	Get(bson.ObjectId) (*models.MfaProvider, error)

	// AddUserProvider adds mfa provider for the user.
	AddUserProvider(*models.MfaUserProvider) error

	// GetUserProviders returns a list of available mfa providers for the user.
	GetUserProviders(*models.User) ([]*models.MfaProvider, error)

	// RemoveUserProvider removes the mfa provider by id for user.
	RemoveUserProvider(*models.MfaUserProvider) error
}

MfaServiceInterface describes of methods for the mfa service.

type OneTimeTokenService

type OneTimeTokenService struct {
	Redis    *redis.Client
	Settings *models.OneTimeTokenSettings
}

OneTimeTokenService is the one-time token service.

func NewOneTimeTokenService

func NewOneTimeTokenService(redis *redis.Client) *OneTimeTokenService

NewOneTimeTokenService return new one-time token service.

func (*OneTimeTokenService) Create

func (s *OneTimeTokenService) Create(obj interface{}, settings *models.OneTimeTokenSettings) (*models.OneTimeToken, error)

func (*OneTimeTokenService) Get

func (s *OneTimeTokenService) Get(token string, obj interface{}) error

func (*OneTimeTokenService) Use

func (s *OneTimeTokenService) Use(token string, d interface{}) error

type OneTimeTokenServiceInterface

type OneTimeTokenServiceInterface interface {
	// Create creates a one-time token with arbitrary data and the specified settings
	// for the length of the token and its lifetime.
	Create(interface{}, *models.OneTimeTokenSettings) (*models.OneTimeToken, error)

	// Get returns the contents of a one-time token by its code.
	Get(string, interface{}) error

	// Use returns the contents of a one-time token by its code and deletes it.
	Use(string, interface{}) error
}

OneTimeTokenServiceInterface describes of methods for the one-time token service.

type RegistryBase

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

RegistryBase contains common services.

func (*RegistryBase) ApplicationService

func (r *RegistryBase) ApplicationService() ApplicationServiceInterface

func (*RegistryBase) HydraAdminApi

func (r *RegistryBase) HydraAdminApi() HydraAdminApi

func (*RegistryBase) Mailer

func (r *RegistryBase) Mailer() MailerInterface

func (*RegistryBase) MfaService

func (r *RegistryBase) MfaService() MfaApiInterface

func (*RegistryBase) MgoSession

func (r *RegistryBase) MgoSession() database.MgoSession

func (*RegistryBase) OneTimeTokenService

func (r *RegistryBase) OneTimeTokenService() OneTimeTokenServiceInterface

func (*RegistryBase) Watcher

func (r *RegistryBase) Watcher() persist.Watcher

type RegistryConfig

type RegistryConfig struct {
	// MgoSession is the interface for the Mongo session.
	MgoSession database.MgoSession

	// RedisClient is the client of the Redis.
	RedisClient *redis.Client

	// MfaService is the interface for the MFA micro-service.
	MfaService MfaApiInterface

	// HydraAdminApi is the interface for the Hydra administration api.
	HydraAdminApi HydraAdminApi

	// Mailer is the interface for the postman.
	Mailer MailerInterface
}

RegistryConfig contains the configuration parameters of Registry

type SessionService

type SessionService interface {
	// Get returns value from session by parameter name.
	Get(echo.Context, string) (interface{}, error)

	// Set sets the value in the session.
	Set(echo.Context, string, interface{}) error
}

SessionService describes of methods for the session service.

func NewSessionService

func NewSessionService(name string) SessionService

NewSessionService return new session service.

type SessionSettings

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

SessionSettings is the session service.

func (*SessionSettings) Get

func (s *SessionSettings) Get(ctx echo.Context, name string) (interface{}, error)

func (*SessionSettings) Set

func (s *SessionSettings) Set(ctx echo.Context, name string, value interface{}) error

type SpaceService

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

func NewSpaceService

func NewSpaceService(dbHandler database.MgoSession) *SpaceService

func (SpaceService) CreateSpace

func (ss SpaceService) CreateSpace(space *models.Space) error

func (SpaceService) GetSpace

func (ss SpaceService) GetSpace(id bson.ObjectId) (*models.Space, error)

func (SpaceService) UpdateSpace

func (ss SpaceService) UpdateSpace(space *models.Space) error

type SpaceServiceInterface

type SpaceServiceInterface interface {
	CreateSpace(*models.Space) error
	UpdateSpace(*models.Space) error
	GetSpace(bson.ObjectId) (*models.Space, error)
}

type UserIdentityService

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

UserIdentityService is the user identity service.

func NewUserIdentityService

func NewUserIdentityService(dbHandler database.MgoSession) *UserIdentityService

NewUserIdentityService return new user identity service.

func (UserIdentityService) Create

func (us UserIdentityService) Create(userIdentity *models.UserIdentity) error

func (UserIdentityService) Get

func (us UserIdentityService) Get(app *models.Application, identityProvider *models.AppIdentityProvider, externalId string) (*models.UserIdentity, error)

func (UserIdentityService) Update

func (us UserIdentityService) Update(userIdentity *models.UserIdentity) error

type UserIdentityServiceInterface

type UserIdentityServiceInterface interface {
	// Create creates a new user identity.
	Create(*models.UserIdentity) error

	// Update updates user identity data.
	Update(*models.UserIdentity) error

	// Get return the user identity by id.
	Get(*models.Application, *models.AppIdentityProvider, string) (*models.UserIdentity, error)
}

UserIdentityServiceInterface describes of methods for the user identity service.

type UserService

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

UserService is the user service.

func NewUserService

func NewUserService(dbHandler database.MgoSession) *UserService

NewUserService return new user service.

func (UserService) Create

func (us UserService) Create(user *models.User) error

func (UserService) Get

func (us UserService) Get(id bson.ObjectId) (*models.User, error)

func (UserService) Update

func (us UserService) Update(user *models.User) error

type UserServiceInterface

type UserServiceInterface interface {
	// Create creates a new user.
	Create(*models.User) error

	// Update updates user data.
	Update(*models.User) error

	// Get return the user by id.
	Get(bson.ObjectId) (*models.User, error)
}

UserServiceInterface describes of methods for the user service.

Jump to

Keyboard shortcuts

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