service

package
Version: v0.0.0-...-9c4ca89 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 69 Imported by: 0

Documentation

Index

Constants

View Source
const DomainVerificationTimeout = 10 * time.Second

Variables

View Source
var DomainVerificationFailed = apierrors.Forbidden.WithReason("DomainVerificationFailed")
View Source
var ErrAppIDInvalid = apierrors.Invalid.WithReason("InvalidAppID").
	New("invalid app ID")
View Source
var ErrAppIDReserved = apierrors.Forbidden.WithReason("AppIDReserved").
	New("requested app ID is reserved")
View Source
var ErrCollaboratorDuplicate = apierrors.AlreadyExists.WithReason("CollaboratorDuplicate").New("collaborator duplicate")
View Source
var ErrCollaboratorInvitationDuplicate = apierrors.AlreadyExists.WithReason("CollaboratorInvitationDuplicate").New("collaborator invitation duplicate")
View Source
var ErrCollaboratorInvitationInvalidCode = apierrors.Invalid.WithReason("CollaboratorInvitationInvalidCode").New("collaborator invitation invalid code")
View Source
var ErrCollaboratorInvitationInvalidEmail = apierrors.Invalid.WithReason("CollaboratorInvitationInvalidEmail").New("the email with the actor does match the invitee email")
View Source
var ErrCollaboratorInvitationNotFound = apierrors.NotFound.WithReason("CollaboratorInvitationNotFound").New("collaborator invitation not found")
View Source
var ErrCollaboratorNotFound = apierrors.NotFound.WithReason("CollaboratorNotFound").New("collaborator not found")
View Source
var ErrCollaboratorSelfDeletion = apierrors.Forbidden.WithReason("CollaboratorSelfDeletion").New("cannot remove self from collaborator")
View Source
var ErrDomainDuplicated = apierrors.AlreadyExists.WithReason("DuplicatedDomain").
	New("requested domain is already in use")
View Source
var ErrDomainNotCustom = apierrors.Forbidden.WithReason("DomainNotCustom").
	New("requested domain is not a custom domain")
View Source
var ErrDomainNotFound = apierrors.NotFound.WithReason("DomainNotFound").
	New("domain not found")
View Source
var ErrDomainVerified = apierrors.AlreadyExists.WithReason("DomainVerified").
	New("requested domain is already verified")
View Source
var ErrDuplicatedAppID = apierrors.AlreadyExists.WithReason("DuplicatedAppID").
	New("duplicated app ID")
View Source
var ErrForbidden = apierrors.Forbidden.WithReason("Forbidden").New("forbidden")
View Source
var ErrGetStaticAppIDsNotSupported = errors.New("only local FS config source can get static app ID")
View Source
var InvalidDomain = apierrors.Invalid.WithReason("InvalidDomain")
View Source
var LabelAppID = "authgear.com/app-id"
View Source
var LabelDomainID = "authgear.com/domain-id"

Functions

This section is empty.

Types

type AdminAPIService

type AdminAPIService struct {
	AuthgearConfig *portalconfig.AuthgearConfig
	AdminAPIConfig *portalconfig.AdminAPIConfig
	ConfigSource   *configsource.ConfigSource
	AuthzAdder     AuthzAdder
}

func (*AdminAPIService) Director

func (s *AdminAPIService) Director(appID string) (director func(*http.Request), err error)

func (*AdminAPIService) ResolveConfig

func (s *AdminAPIService) ResolveConfig(appID string) (*config.Config, error)

func (*AdminAPIService) ResolveEndpoint

func (s *AdminAPIService) ResolveEndpoint(appID string) (*url.URL, error)

func (*AdminAPIService) ResolveHost

func (s *AdminAPIService) ResolveHost(appID string) (host string, err error)

func (*AdminAPIService) SelfDirector

func (s *AdminAPIService) SelfDirector() (director func(*http.Request), err error)

type AppAdminAPIService

type AppAdminAPIService interface {
	ResolveHost(appID string) (host string, err error)
}

type AppAuthzService

type AppAuthzService interface {
	AddAuthorizedUser(appID string, userID string, role model.CollaboratorRole) error
	ListAuthorizedApps(userID string) ([]string, error)
}

type AppConfigService

type AppConfigService interface {
	ResolveContext(appID string) (*config.AppContext, error)
	UpdateResources(appID string, updates []*resource.ResourceFile) error
	Create(opts *CreateAppOptions) error
	CreateDomain(appID string, domainID string, domain string, isCustom bool) error
}

type AppDomainService

type AppDomainService interface {
	CreateDomain(appID string, domain string, isVerified bool, isCustom bool) (*model.Domain, error)
}

type AppPlanService

type AppPlanService interface {
	GetDefaultPlan() (*model.Plan, error)
}

type AppResourceManagerFactory

type AppResourceManagerFactory interface {
	NewManagerWithNewAppFS(appFs resource.Fs) *appresource.Manager
	NewManagerWithAppContext(appContext *config.AppContext) *appresource.Manager
}

type AppService

type AppService struct {
	Logger      AppServiceLogger
	SQLBuilder  *globaldb.SQLBuilder
	SQLExecutor *globaldb.SQLExecutor

	AppConfig        *portalconfig.AppConfig
	AppConfigs       AppConfigService
	AppAuthz         AppAuthzService
	AppAdminAPI      AppAdminAPIService
	AppDomains       AppDomainService
	Resources        ResourceManager
	AppResMgrFactory AppResourceManagerFactory
	Plan             AppPlanService
	Clock            clock.Clock
}

func (*AppService) Create

func (s *AppService) Create(userID string, id string) error

func (*AppService) Get

func (s *AppService) Get(id string) (*model.App, error)

func (*AppService) GetMany

func (s *AppService) GetMany(ids []string) (out []*model.App, err error)

func (*AppService) GetMaxOwnedApps

func (s *AppService) GetMaxOwnedApps(userID string) (int, error)

func (*AppService) List

func (s *AppService) List(userID string) ([]*model.App, error)

func (*AppService) LoadAppSecretConfig

func (s *AppService) LoadAppSecretConfig(app *model.App, sessionInfo *apimodel.SessionInfo) (*model.SecretConfig, error)

func (*AppService) LoadRawAppConfig

func (s *AppService) LoadRawAppConfig(app *model.App) (*config.AppConfig, error)

func (*AppService) UpdateResources

func (s *AppService) UpdateResources(app *model.App, updates []appresource.Update) error

type AppServiceLogger

type AppServiceLogger struct{ *log.Logger }

func NewAppServiceLogger

func NewAppServiceLogger(lf *log.Factory) AppServiceLogger

type AuthzAdder

type AuthzAdder interface {
	AddAuthz(auth config.AdminAPIAuth, appID config.AppID, authKey *config.AdminAPIAuthKey, hdr http.Header) (err error)
}

type AuthzCollaboratorService

type AuthzCollaboratorService interface {
	NewCollaborator(appID string, userID string, role model.CollaboratorRole) *model.Collaborator
	CreateCollaborator(c *model.Collaborator) error
	ListCollaboratorsByUser(userID string) ([]*model.Collaborator, error)
	GetCollaboratorByAppAndUser(appID string, userID string) (*model.Collaborator, error)
}

type AuthzConfigService

type AuthzConfigService interface {
	GetStaticAppIDs() ([]string, error)
}

type AuthzService

type AuthzService struct {
	Context       context.Context
	Configs       AuthzConfigService
	Collaborators AuthzCollaboratorService
}

func (*AuthzService) AddAuthorizedUser

func (s *AuthzService) AddAuthorizedUser(appID string, userID string, role model.CollaboratorRole) error

func (*AuthzService) CheckAccessOfViewer

func (s *AuthzService) CheckAccessOfViewer(appID string) (userID string, err error)

func (*AuthzService) ListAuthorizedApps

func (s *AuthzService) ListAuthorizedApps(userID string) ([]string, error)

type CollaboratorService

type CollaboratorService struct {
	Context     context.Context
	Clock       clock.Clock
	SQLBuilder  *globaldb.SQLBuilder
	SQLExecutor *globaldb.SQLExecutor

	MailConfig     *portalconfig.MailConfig
	TaskQueue      CollaboratorServiceTaskQueue
	Endpoints      CollaboratorServiceEndpointsProvider
	TemplateEngine *template.Engine
	AdminAPI       CollaboratorServiceAdminAPIService
}

func (*CollaboratorService) AcceptInvitation

func (s *CollaboratorService) AcceptInvitation(code string) (*model.Collaborator, error)

func (*CollaboratorService) CheckInviteeEmail

func (s *CollaboratorService) CheckInviteeEmail(i *model.CollaboratorInvitation, actorID string) error

func (*CollaboratorService) CreateCollaborator

func (s *CollaboratorService) CreateCollaborator(c *model.Collaborator) error

func (*CollaboratorService) DeleteCollaborator

func (s *CollaboratorService) DeleteCollaborator(c *model.Collaborator) error

func (*CollaboratorService) DeleteInvitation

func (s *CollaboratorService) DeleteInvitation(i *model.CollaboratorInvitation) error

func (*CollaboratorService) GetCollaborator

func (s *CollaboratorService) GetCollaborator(id string) (*model.Collaborator, error)

func (*CollaboratorService) GetCollaboratorByAppAndUser

func (s *CollaboratorService) GetCollaboratorByAppAndUser(appID string, userID string) (*model.Collaborator, error)

func (*CollaboratorService) GetInvitation

func (s *CollaboratorService) GetInvitation(id string) (*model.CollaboratorInvitation, error)

func (*CollaboratorService) GetInvitationWithCode

func (s *CollaboratorService) GetInvitationWithCode(code string) (*model.CollaboratorInvitation, error)

func (*CollaboratorService) GetManyCollaborators

func (s *CollaboratorService) GetManyCollaborators(ids []string) ([]*model.Collaborator, error)

func (*CollaboratorService) GetManyInvitations

func (s *CollaboratorService) GetManyInvitations(ids []string) ([]*model.CollaboratorInvitation, error)

func (*CollaboratorService) ListCollaborators

func (s *CollaboratorService) ListCollaborators(appID string) ([]*model.Collaborator, error)

func (*CollaboratorService) ListCollaboratorsByUser

func (s *CollaboratorService) ListCollaboratorsByUser(userID string) ([]*model.Collaborator, error)

func (*CollaboratorService) ListInvitations

func (s *CollaboratorService) ListInvitations(appID string) ([]*model.CollaboratorInvitation, error)

func (*CollaboratorService) NewCollaborator

func (s *CollaboratorService) NewCollaborator(appID string, userID string, role model.CollaboratorRole) *model.Collaborator

func (*CollaboratorService) SendInvitation

func (s *CollaboratorService) SendInvitation(
	appID string,
	inviteeEmail string,
) (*model.CollaboratorInvitation, error)

type CollaboratorServiceAdminAPIService

type CollaboratorServiceAdminAPIService interface {
	SelfDirector() (func(*http.Request), error)
}

type CollaboratorServiceEndpointsProvider

type CollaboratorServiceEndpointsProvider interface {
	AcceptCollaboratorInvitationEndpointURL() *url.URL
}

type CollaboratorServiceTaskQueue

type CollaboratorServiceTaskQueue interface {
	Enqueue(param task.Param)
}

type ConfigService

type ConfigService struct {
	Context              context.Context
	Logger               ConfigServiceLogger
	AppConfig            *portalconfig.AppConfig
	Controller           *configsource.Controller
	ConfigSource         *configsource.ConfigSource
	DomainImplementation portalconfig.DomainImplementationType
	Kubernetes           *Kubernetes
}

func (*ConfigService) Create

func (s *ConfigService) Create(opts *CreateAppOptions) error

func (*ConfigService) CreateDomain

func (s *ConfigService) CreateDomain(appID string, domainID string, domain string, isCustom bool) error

func (*ConfigService) DeleteDomain

func (s *ConfigService) DeleteDomain(domain *model.Domain) error

func (*ConfigService) GetStaticAppIDs

func (s *ConfigService) GetStaticAppIDs() ([]string, error)

func (*ConfigService) ResolveContext

func (s *ConfigService) ResolveContext(appID string) (*config.AppContext, error)

func (*ConfigService) UpdateResources

func (s *ConfigService) UpdateResources(appID string, files []*resource.ResourceFile) error

type ConfigServiceLogger

type ConfigServiceLogger struct{ *log.Logger }

func NewConfigServiceLogger

func NewConfigServiceLogger(lf *log.Factory) ConfigServiceLogger

type CreateAppOptions

type CreateAppOptions struct {
	AppID     string
	Resources map[string][]byte
	PlanName  string
}

type DomainConfigService

type DomainConfigService interface {
	CreateDomain(appID string, domainID string, domain string, isCustom bool) error
	DeleteDomain(domain *model.Domain) error
}

type DomainService

type DomainService struct {
	Context      context.Context
	Clock        clock.Clock
	DomainConfig DomainConfigService
	SQLBuilder   *globaldb.SQLBuilder
	SQLExecutor  *globaldb.SQLExecutor
}

func (*DomainService) CreateCustomDomain

func (s *DomainService) CreateCustomDomain(appID string, domain string) (*model.Domain, error)

func (*DomainService) CreateDomain

func (s *DomainService) CreateDomain(appID string, domain string, isVerified bool, isCustom bool) (*model.Domain, error)

func (*DomainService) DeleteDomain

func (s *DomainService) DeleteDomain(appID string, id string) error

func (*DomainService) GetMany

func (s *DomainService) GetMany(ids []string) ([]*model.Domain, error)

func (*DomainService) ListDomains

func (s *DomainService) ListDomains(appID string) ([]*model.Domain, error)

func (*DomainService) VerifyDomain

func (s *DomainService) VerifyDomain(appID string, id string) (*model.Domain, error)

type IngressTemplateData

type IngressTemplateData struct {
	AppID         string
	DomainID      string
	IsCustom      bool
	Host          string
	TLSSecretName string
}

type Kubernetes

type Kubernetes struct {
	KubernetesConfig *portalconfig.KubernetesConfig
	AppConfig        *portalconfig.AppConfig
	Logger           KubernetesLogger

	Context             context.Context                `wire:"-"`
	Namespace           string                         `wire:"-"`
	KubeConfig          *rest.Config                   `wire:"-"`
	Client              kubernetes.Interface           `wire:"-"`
	CertManagerClient   certmanagerclientset.Interface `wire:"-"`
	DynamicClient       dynamic.Interface              `wire:"-"`
	DiscoveryRESTMapper meta.RESTMapper                `wire:"-"`
}

func (*Kubernetes) CreateResourcesForDomain

func (k *Kubernetes) CreateResourcesForDomain(
	appID string,
	domainID string,
	domain string,
	isCustom bool,
) error

func (*Kubernetes) DeleteResourcesForDomain

func (k *Kubernetes) DeleteResourcesForDomain(domainID string) error

type KubernetesLogger

type KubernetesLogger struct{ *log.Logger }

func NewKubernetesLogger

func NewKubernetesLogger(lf *log.Factory) KubernetesLogger

type KubernetesResource

type KubernetesResource struct {
	Object *unstructured.Unstructured
	GVK    *schema.GroupVersionKind
}

func GenerateResources

func GenerateResources(def *ResourceTemplateData, templateBytes []byte) ([]*KubernetesResource, error)

type ResourceManager

type ResourceManager interface {
	Read(desc resource.Descriptor, view resource.View) (interface{}, error)
}

type ResourceTemplateData

type ResourceTemplateData struct {
	AppID    string
	DomainID string
	IsCustom bool
	Host     string
}

type SystemConfigProvider

type SystemConfigProvider struct {
	AuthgearConfig *config.AuthgearConfig
	AppConfig      *config.AppConfig
	SearchConfig   *config.SearchConfig
	AuditLogConfig *config.AuditLogConfig
	Resources      ResourceManager
}

func (*SystemConfigProvider) SystemConfig

func (p *SystemConfigProvider) SystemConfig() (*model.SystemConfig, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL