Documentation
¶
Overview ¶
Service assembly for the authentication subdomain. The per-flow logic keeps its explicit Dependencies structs from the earlier DI refactor; this file builds them per request from the module's injected collaborators and a runtime configuration snapshot.
Index ¶
- type AccountIdentityStore
- type BindDeviceDependencies
- type BindDeviceLogic
- type BindDeviceStore
- type CheckUserDependencies
- type CheckUserLogic
- type CheckUserTelephoneLogic
- type Deps
- type DeviceBinder
- type DeviceLoginConfig
- type DeviceLoginDependencies
- type DeviceLoginLogic
- type DeviceLoginStore
- type DeviceRegistrationPolicy
- type EmailLoginPolicy
- type EmailPasswordResetPolicy
- type EmailRegistrationPolicy
- type ResetPasswordConfig
- type ResetPasswordDependencies
- type ResetPasswordLogic
- type ResetPasswordStore
- type Service
- func (s *Service) AppleLoginCallback(ctx context.Context, req *dto.AppleLoginCallbackRequest) (*oauth.AppleLoginRedirect, error)
- func (s *Service) CheckUser(ctx context.Context, req *dto.CheckUserRequest) (*dto.CheckUserResponse, error)
- func (s *Service) CheckUserTelephone(ctx context.Context, req *dto.TelephoneCheckUserRequest) (*dto.TelephoneCheckUserResponse, error)
- func (s *Service) DeviceLogin(ctx context.Context, req *dto.DeviceLoginRequest) (*dto.LoginResponse, error)
- func (s *Service) OAuthLogin(ctx context.Context, req *dto.OAthLoginRequest) (*dto.OAuthLoginResponse, error)
- func (s *Service) OAuthLoginGetToken(ctx context.Context, req *dto.OAuthLoginGetTokenRequest, ip, userAgent string) (*dto.LoginResponse, error)
- func (s *Service) Policy() registerpolicy.ServicePolicy
- func (s *Service) ResetPassword(ctx context.Context, req *dto.ResetPasswordRequest) (*dto.LoginResponse, error)
- func (s *Service) TelephoneLogin(ctx context.Context, req *dto.TelephoneLoginRequest, ip, userAgent string) (*dto.LoginResponse, error)
- func (s *Service) TelephoneResetPassword(ctx context.Context, req *dto.TelephoneResetPasswordRequest) (*dto.LoginResponse, error)
- func (s *Service) TelephoneUserRegister(ctx context.Context, req *dto.TelephoneRegisterRequest) (*dto.LoginResponse, error)
- func (s *Service) UserLogin(ctx context.Context, req *dto.UserLoginRequest) (*dto.LoginResponse, error)
- func (s *Service) UserRegister(ctx context.Context, req *dto.UserRegisterRequest) (*dto.LoginResponse, error)
- type Snapshot
- type TelephoneLoginConfig
- type TelephoneLoginDependencies
- type TelephoneLoginLogic
- type TelephoneLoginPolicy
- type TelephoneLoginStore
- type TelephonePasswordResetPolicy
- type TelephoneRegistrationPolicy
- type TelephoneResetPasswordConfig
- type TelephoneResetPasswordDependencies
- type TelephoneResetPasswordLogic
- type TelephoneResetPasswordStore
- type TelephoneUserRegisterConfig
- type TelephoneUserRegisterDependencies
- type TelephoneUserRegisterLogic
- type TelephoneUserRegisterStore
- type UserLoginConfig
- type UserLoginDependencies
- type UserLoginLogic
- type UserLoginStore
- type UserRegisterConfig
- type UserRegisterDependencies
- type UserRegisterLogic
- type UserRegisterStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountIdentityStore ¶
type AccountIdentityStore interface {
UserAuth() repository.UserAuthRepo
}
AccountIdentityStore is the persistence surface used by account existence checks. It excludes unrelated application repositories.
type BindDeviceDependencies ¶
type BindDeviceDependencies struct {
Store BindDeviceStore
}
BindDeviceDependencies explicitly declares the collaborators of device binding instead of passing ServiceContext to business logic.
type BindDeviceLogic ¶
func NewBindDeviceLogic ¶
func NewBindDeviceLogic(ctx context.Context, deps BindDeviceDependencies) *BindDeviceLogic
func (*BindDeviceLogic) BindDeviceToUser ¶
func (l *BindDeviceLogic) BindDeviceToUser(identifier, ip, userAgent string, currentUserId int64) error
BindDeviceToUser binds a device to a user If the device is already bound to another user, it will disable that user and bind the device to the current user
type BindDeviceStore ¶
type BindDeviceStore interface {
User() repository.UserRepo
UserAuth() repository.UserAuthRepo
UserDevice() repository.UserDeviceRepo
InIdentityTx(ctx context.Context, fn func(repository.IdentityStore) error) error
}
BindDeviceStore is the persistence surface used by device binding. It excludes unrelated application repositories.
type CheckUserDependencies ¶
type CheckUserDependencies struct {
Store AccountIdentityStore
}
CheckUserDependencies explicitly declares the collaborators of account existence checks instead of passing ServiceContext to business logic.
type CheckUserLogic ¶
func NewCheckUserLogic ¶
func NewCheckUserLogic(ctx context.Context, deps CheckUserDependencies) *CheckUserLogic
NewCheckUserLogic Check user is exist
func (*CheckUserLogic) CheckUser ¶
func (l *CheckUserLogic) CheckUser(req *dto.CheckUserRequest) (resp *dto.CheckUserResponse, err error)
type CheckUserTelephoneLogic ¶
func NewCheckUserTelephoneLogic ¶
func NewCheckUserTelephoneLogic(ctx context.Context, deps CheckUserDependencies) *CheckUserTelephoneLogic
Check user telephone is exist
func (*CheckUserTelephoneLogic) CheckUserTelephone ¶
func (l *CheckUserTelephoneLogic) CheckUserTelephone(req *dto.TelephoneCheckUserRequest) (resp *dto.TelephoneCheckUserResponse, err error)
type Deps ¶
type Deps struct {
Store repository.Store
Redis *redis.Client
// Config snapshots the runtime-mutable settings per request.
Config func() Snapshot
}
Deps declares the subdomain's dependencies; the identity facade forwards them from the composition root.
type DeviceBinder ¶
type DeviceBinder interface {
BindDeviceToUser(identifier, ip, userAgent string, currentUserID int64) error
}
DeviceBinder attaches a device identifier to a newly registered user.
type DeviceLoginConfig ¶
type DeviceLoginConfig struct {
Enabled bool
OnlyRealDevice bool
InviteForced bool
OnlyFirstPurchase bool
TrialEnabled bool
TrialSubscribeID int64
TrialTime int64
TrialTimeUnit string
JWTAccessSecret string
JWTAccessExpire int64
}
DeviceLoginConfig is the configuration snapshot consumed by the device login and registration use case.
type DeviceLoginDependencies ¶
type DeviceLoginDependencies struct {
Store DeviceLoginStore
Redis *redis.Client
Config DeviceLoginConfig
Policy DeviceRegistrationPolicy
}
DeviceLoginDependencies explicitly declares the collaborators required by device login instead of passing ServiceContext to business logic.
type DeviceLoginLogic ¶
func NewDeviceLoginLogic ¶
func NewDeviceLoginLogic(ctx context.Context, deps DeviceLoginDependencies) *DeviceLoginLogic
Device Login
func (*DeviceLoginLogic) DeviceLogin ¶
func (l *DeviceLoginLogic) DeviceLogin(req *dto.DeviceLoginRequest) (resp *dto.LoginResponse, err error)
type DeviceLoginStore ¶
type DeviceLoginStore interface {
User() repository.UserRepo
UserAuth() repository.UserAuthRepo
UserDevice() repository.UserDeviceRepo
UserSubscription() repository.UserSubscriptionRepo
UserCache() repository.UserCacheRepo
Subscribe() repository.SubscribeRepo
Log() repository.LogRepo
InTx(ctx context.Context, fn func(repository.Store) error) error
}
DeviceLoginStore is the persistence surface used by device login and device registration. It excludes unrelated application repositories.
type DeviceRegistrationPolicy ¶
type DeviceRegistrationPolicy interface {
EnsureRegistrationOpen(ctx context.Context, method string) error
VerifyHuman(ctx context.Context, token, ip string) error
TakeIPPermit(ctx context.Context, ip string) error
}
DeviceRegistrationPolicy contains the registration checks needed when a previously unseen device creates an account.
type EmailLoginPolicy ¶
EmailLoginPolicy contains the authentication-method policy required by email login.
type EmailPasswordResetPolicy ¶
type EmailPasswordResetPolicy interface {
EnsureMethodEnabled(ctx context.Context, method string) error
}
EmailPasswordResetPolicy contains the authentication-method policy required by email password reset.
type EmailRegistrationPolicy ¶
type EmailRegistrationPolicy interface {
EnsureRegistrationOpen(ctx context.Context, method string) error
VerifyHuman(ctx context.Context, token, ip string) error
TakeIPPermit(ctx context.Context, ip string) error
}
EmailRegistrationPolicy contains the registration checks required by email registration.
type ResetPasswordConfig ¶
ResetPasswordConfig is the configuration snapshot consumed by email password reset.
type ResetPasswordDependencies ¶
type ResetPasswordDependencies struct {
Store ResetPasswordStore
Redis *redis.Client
Config ResetPasswordConfig
Policy EmailPasswordResetPolicy
DeviceBinder DeviceBinder
}
ResetPasswordDependencies explicitly declares the collaborators of email password reset instead of passing ServiceContext to business logic.
type ResetPasswordLogic ¶
func NewResetPasswordLogic ¶
func NewResetPasswordLogic(ctx context.Context, deps ResetPasswordDependencies) *ResetPasswordLogic
NewResetPasswordLogic Reset password
func (*ResetPasswordLogic) ResetPassword ¶
func (l *ResetPasswordLogic) ResetPassword(req *dto.ResetPasswordRequest) (resp *dto.LoginResponse, err error)
type ResetPasswordStore ¶
type ResetPasswordStore interface {
User() repository.UserRepo
UserAuth() repository.UserAuthRepo
Log() repository.LogRepo
}
ResetPasswordStore is the persistence surface used by email password reset. It excludes unrelated application repositories.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the authentication subdomain entry point used by the identity facade.
func NewService ¶
func (*Service) AppleLoginCallback ¶
func (s *Service) AppleLoginCallback(ctx context.Context, req *dto.AppleLoginCallbackRequest) (*oauth.AppleLoginRedirect, error)
func (*Service) CheckUser ¶
func (s *Service) CheckUser(ctx context.Context, req *dto.CheckUserRequest) (*dto.CheckUserResponse, error)
func (*Service) CheckUserTelephone ¶
func (s *Service) CheckUserTelephone(ctx context.Context, req *dto.TelephoneCheckUserRequest) (*dto.TelephoneCheckUserResponse, error)
func (*Service) DeviceLogin ¶
func (s *Service) DeviceLogin(ctx context.Context, req *dto.DeviceLoginRequest) (*dto.LoginResponse, error)
func (*Service) OAuthLogin ¶
func (s *Service) OAuthLogin(ctx context.Context, req *dto.OAthLoginRequest) (*dto.OAuthLoginResponse, error)
func (*Service) OAuthLoginGetToken ¶
func (s *Service) OAuthLoginGetToken(ctx context.Context, req *dto.OAuthLoginGetTokenRequest, ip, userAgent string) (*dto.LoginResponse, error)
func (*Service) Policy ¶
func (s *Service) Policy() registerpolicy.ServicePolicy
Policy exposes the register policy to sibling subdomains (the profile flows gate method rebinding on the same switches).
func (*Service) ResetPassword ¶
func (s *Service) ResetPassword(ctx context.Context, req *dto.ResetPasswordRequest) (*dto.LoginResponse, error)
func (*Service) TelephoneLogin ¶
func (s *Service) TelephoneLogin(ctx context.Context, req *dto.TelephoneLoginRequest, ip, userAgent string) (*dto.LoginResponse, error)
func (*Service) TelephoneResetPassword ¶
func (s *Service) TelephoneResetPassword(ctx context.Context, req *dto.TelephoneResetPasswordRequest) (*dto.LoginResponse, error)
func (*Service) TelephoneUserRegister ¶
func (s *Service) TelephoneUserRegister(ctx context.Context, req *dto.TelephoneRegisterRequest) (*dto.LoginResponse, error)
func (*Service) UserLogin ¶
func (s *Service) UserLogin(ctx context.Context, req *dto.UserLoginRequest) (*dto.LoginResponse, error)
func (*Service) UserRegister ¶
func (s *Service) UserRegister(ctx context.Context, req *dto.UserRegisterRequest) (*dto.LoginResponse, error)
type Snapshot ¶
type Snapshot struct {
JWTAccessSecret string
JWTAccessExpire int64
EmailEnabled bool
EmailVerifyEnabled bool
EmailDomainSuffixList string
EmailEnableDomainSuffix bool
MobileEnabled bool
DeviceEnabled bool
DeviceOnlyReal bool
InviteForced bool
OnlyFirstPurchase bool
TrialEnabled bool
TrialSubscribeID int64
TrialTime int64
TrialTimeUnit string
StopRegister bool
RegisterVerify bool
TurnstileSecret string
EnableIpRegisterLimit bool
IpRegisterLimit int64
IpRegisterLimitDuration int64
// SiteHost is the fallback redirect target for the Apple form-post
// callback.
SiteHost string
}
Snapshot is the per-request view of every runtime-mutable setting the authentication flows consume.
type TelephoneLoginConfig ¶
TelephoneLoginConfig is the configuration snapshot consumed by telephone login.
type TelephoneLoginDependencies ¶
type TelephoneLoginDependencies struct {
Store TelephoneLoginStore
Redis *redis.Client
Config TelephoneLoginConfig
Policy TelephoneLoginPolicy
DeviceBinder DeviceBinder
}
TelephoneLoginDependencies explicitly declares the collaborators of telephone login instead of passing ServiceContext to business logic.
type TelephoneLoginLogic ¶
func NewTelephoneLoginLogic ¶
func NewTelephoneLoginLogic(ctx context.Context, deps TelephoneLoginDependencies) *TelephoneLoginLogic
User Telephone login
func (*TelephoneLoginLogic) TelephoneLogin ¶
func (l *TelephoneLoginLogic) TelephoneLogin(req *dto.TelephoneLoginRequest, ip, userAgent string) (resp *dto.LoginResponse, err error)
type TelephoneLoginPolicy ¶
type TelephoneLoginPolicy interface {
EnsureMethodEnabled(ctx context.Context, method string) error
}
TelephoneLoginPolicy contains the authentication-method policy required by telephone login.
type TelephoneLoginStore ¶
type TelephoneLoginStore interface {
User() repository.UserRepo
UserAuth() repository.UserAuthRepo
Log() repository.LogRepo
}
TelephoneLoginStore is the persistence surface used by telephone login. It excludes unrelated application repositories.
type TelephonePasswordResetPolicy ¶
type TelephonePasswordResetPolicy interface {
EnsureMethodEnabled(ctx context.Context, method string) error
}
TelephonePasswordResetPolicy contains the authentication-method policy required by telephone password reset.
type TelephoneRegistrationPolicy ¶
type TelephoneRegistrationPolicy interface {
EnsureRegistrationOpen(ctx context.Context, method string) error
VerifyHuman(ctx context.Context, token, ip string) error
TakeIPPermit(ctx context.Context, ip string) error
}
TelephoneRegistrationPolicy contains the registration checks required by telephone registration.
type TelephoneResetPasswordConfig ¶
TelephoneResetPasswordConfig is the configuration snapshot consumed by telephone password reset.
type TelephoneResetPasswordDependencies ¶
type TelephoneResetPasswordDependencies struct {
Store TelephoneResetPasswordStore
Redis *redis.Client
Config TelephoneResetPasswordConfig
Policy TelephonePasswordResetPolicy
DeviceBinder DeviceBinder
}
TelephoneResetPasswordDependencies explicitly declares the collaborators of telephone password reset instead of passing ServiceContext to business logic.
type TelephoneResetPasswordLogic ¶
func NewTelephoneResetPasswordLogic ¶
func NewTelephoneResetPasswordLogic(ctx context.Context, deps TelephoneResetPasswordDependencies) *TelephoneResetPasswordLogic
Reset password
func (*TelephoneResetPasswordLogic) TelephoneResetPassword ¶
func (l *TelephoneResetPasswordLogic) TelephoneResetPassword(req *dto.TelephoneResetPasswordRequest) (resp *dto.LoginResponse, err error)
type TelephoneResetPasswordStore ¶
type TelephoneResetPasswordStore interface {
User() repository.UserRepo
UserAuth() repository.UserAuthRepo
Log() repository.LogRepo
}
TelephoneResetPasswordStore is the persistence surface used by telephone password reset. It excludes unrelated application repositories.
type TelephoneUserRegisterConfig ¶
type TelephoneUserRegisterConfig struct {
InviteForced bool
OnlyFirstPurchase bool
TrialEnabled bool
TrialSubscribeID int64
TrialTime int64
TrialTimeUnit string
JWTAccessSecret string
JWTAccessExpire int64
}
TelephoneUserRegisterConfig is the configuration snapshot consumed by telephone registration.
type TelephoneUserRegisterDependencies ¶
type TelephoneUserRegisterDependencies struct {
Store TelephoneUserRegisterStore
Redis *redis.Client
Config TelephoneUserRegisterConfig
Policy TelephoneRegistrationPolicy
DeviceBinder DeviceBinder
}
TelephoneUserRegisterDependencies explicitly declares the collaborators of telephone registration instead of passing ServiceContext to business logic.
type TelephoneUserRegisterLogic ¶
func NewTelephoneUserRegisterLogic ¶
func NewTelephoneUserRegisterLogic(ctx context.Context, deps TelephoneUserRegisterDependencies) *TelephoneUserRegisterLogic
NewTelephoneUserRegisterLogic User Telephone register
func (*TelephoneUserRegisterLogic) TelephoneUserRegister ¶
func (l *TelephoneUserRegisterLogic) TelephoneUserRegister(req *dto.TelephoneRegisterRequest) (resp *dto.LoginResponse, err error)
type TelephoneUserRegisterStore ¶
type TelephoneUserRegisterStore interface {
User() repository.UserRepo
UserAuth() repository.UserAuthRepo
UserSubscription() repository.UserSubscriptionRepo
UserCache() repository.UserCacheRepo
Subscribe() repository.SubscribeRepo
Log() repository.LogRepo
InTx(ctx context.Context, fn func(repository.Store) error) error
}
TelephoneUserRegisterStore is the persistence surface used by telephone registration. It excludes unrelated application repositories.
type UserLoginConfig ¶
UserLoginConfig is the configuration snapshot consumed by email login.
type UserLoginDependencies ¶
type UserLoginDependencies struct {
Store UserLoginStore
Redis *redis.Client
Config UserLoginConfig
Policy EmailLoginPolicy
DeviceBinder DeviceBinder
}
UserLoginDependencies explicitly declares the collaborators of email login instead of passing ServiceContext to business logic.
type UserLoginLogic ¶
func NewUserLoginLogic ¶
func NewUserLoginLogic(ctx context.Context, deps UserLoginDependencies) *UserLoginLogic
NewUserLoginLogic User login
func (*UserLoginLogic) UserLogin ¶
func (l *UserLoginLogic) UserLogin(req *dto.UserLoginRequest) (resp *dto.LoginResponse, err error)
type UserLoginStore ¶
type UserLoginStore interface {
User() repository.UserRepo
Log() repository.LogRepo
}
UserLoginStore is the persistence surface used by email login. It excludes unrelated application repositories.
type UserRegisterConfig ¶
type UserRegisterConfig struct {
EmailDomainSuffixList string
EmailEnableDomainSuffix bool
EmailVerifyEnabled bool
InviteForced bool
OnlyFirstPurchase bool
TrialEnabled bool
TrialSubscribeID int64
TrialTime int64
TrialTimeUnit string
JWTAccessSecret string
JWTAccessExpire int64
}
UserRegisterConfig is the configuration snapshot consumed by email registration.
type UserRegisterDependencies ¶
type UserRegisterDependencies struct {
Store UserRegisterStore
Redis *redis.Client
Config UserRegisterConfig
Policy EmailRegistrationPolicy
DeviceBinder DeviceBinder
}
UserRegisterDependencies explicitly declares the collaborators of email registration instead of passing ServiceContext to business logic.
type UserRegisterLogic ¶
func NewUserRegisterLogic ¶
func NewUserRegisterLogic(ctx context.Context, deps UserRegisterDependencies) *UserRegisterLogic
NewUserRegisterLogic User register
func (*UserRegisterLogic) UserRegister ¶
func (l *UserRegisterLogic) UserRegister(req *dto.UserRegisterRequest) (resp *dto.LoginResponse, err error)
type UserRegisterStore ¶
type UserRegisterStore interface {
User() repository.UserRepo
UserAuth() repository.UserAuthRepo
UserSubscription() repository.UserSubscriptionRepo
UserCache() repository.UserCacheRepo
Subscribe() repository.SubscribeRepo
Log() repository.LogRepo
InTx(ctx context.Context, fn func(repository.Store) error) error
}
UserRegisterStore is the persistence surface used by email registration. It excludes unrelated application repositories.
Source Files
¶
- bindDeviceDependencies.go
- bindDeviceLogic.go
- checkUserDependencies.go
- checkUserLogic.go
- checkUserTelephoneLogic.go
- deviceLoginDependencies.go
- deviceLoginLogic.go
- password_upgrade.go
- resetPasswordDependencies.go
- resetPasswordLogic.go
- service.go
- telephoneLoginDependencies.go
- telephoneLoginLogic.go
- telephoneResetPasswordDependencies.go
- telephoneResetPasswordLogic.go
- telephoneUserRegisterDependencies.go
- telephoneUserRegisterLogic.go
- userLoginDependencies.go
- userLoginLogic.go
- userRegisterDependencies.go
- userRegisterLogic.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package registerpolicy enforces the administrator-configured account policies shared by every authentication and registration path.
|
Package registerpolicy enforces the administrator-configured account policies shared by every authentication and registration path. |