identity

package
v1.15.14 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package identity is the facade of the identity module (accounts, auth methods, devices; the authentication flows join as migration proceeds). See docs/adr-001-modular-monolith.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRepoBuilder added in v1.15.2

func NewRepoBuilder() repository.IdentityBuilder

NewRepoBuilder exports the module-owned repository implementations for store assembly (ADR-001 step-6 preparation).

Types

type AppleLoginRedirect

type AppleLoginRedirect = oauth.AppleLoginRedirect

AppleLoginRedirect re-exports the Apple form-post callback's redirect result for the transport handler.

type AuthSnapshot

type AuthSnapshot = authn.Snapshot

AuthSnapshot re-exports the authentication subdomain's per-request view of the runtime-mutable settings; the composition root supplies the snapshot closure.

type Deps

type Deps struct {
	Users     repository.UserRepo
	UserAuths repository.UserAuthRepo
	Devices   repository.UserDeviceRepo
	Cache     repository.UserCacheRepo
	UserSubs  repository.UserSubscriptionRepo
	Plans     repository.SubscribeRepo
	Traffic   repository.TrafficRepo
	Logs      repository.LogRepo
	Store     repository.Store
	// KickDevice force-disconnects a bound device.
	KickDevice func(userID int64, identifier string)

	// Wallet is the read port onto the billing domain's wallet table for
	// the admin and self-service account views.
	Wallet repository.WalletRepo

	// Profile-specific dependencies.
	Auths repository.AuthRepo
	Redis *redis.Client
	// EmailDomains snapshots the runtime-mutable email domain-suffix policy.
	EmailDomains func() (domainList string, restrict bool)
	// TelegramBotName snapshots the runtime-mutable Telegram bot name.
	TelegramBotName func() string
	// NotifyTelegramUnbind sends the best-effort unbind notice.
	NotifyTelegramUnbind func(userID, chatID int64) error
	// AuthConfig snapshots the runtime-mutable settings consumed by the
	// authentication flows per request.
	AuthConfig func() AuthSnapshot
	// VerifyQueue publishes verification-code delivery tasks; the asynq
	// client satisfies it structurally.
	VerifyQueue VerificationTaskQueue
	// VerifyCodeConfig snapshots the runtime-mutable settings consumed by
	// the verification-code flows per request.
	VerifyCodeConfig func() VerifyCodeSnapshot
	// SenderConfig snapshots the runtime-mutable sender platform settings
	// per request, and Reinitialize re-runs a sender subsystem's
	// initialization after its configuration changed.
	SenderConfig func() SenderSnapshot
	Reinitialize func(subsystem string)
}

Deps declares everything the module needs; the composition root (internal/svc) provides them.

type SenderSnapshot

type SenderSnapshot = authmethodadmin.Snapshot

SenderSnapshot re-exports the auth-method subdomain's sender settings view for the composition root.

type Service

type Service interface {
	CreateUser(ctx context.Context, req *dto.CreateUserRequest) error
	DeleteUser(ctx context.Context, req *dto.GetDetailRequest) error
	BatchDeleteUser(ctx context.Context, req *dto.BatchDeleteUserRequest) error
	GetUserDetail(ctx context.Context, req *dto.GetDetailRequest) (*dto.User, error)
	GetUserList(ctx context.Context, req *dto.GetUserListRequest) (*dto.GetUserListResponse, error)
	CurrentUser(ctx context.Context) (*dto.User, error)
	CreateUserAuthMethod(ctx context.Context, req *dto.CreateUserAuthMethodRequest) error
	DeleteUserAuthMethod(ctx context.Context, req *dto.DeleteUserAuthMethodRequest) error
	GetUserAuthMethod(ctx context.Context, req *dto.GetUserAuthMethodRequest) (*dto.GetUserAuthMethodResponse, error)
	UpdateUserAuthMethod(ctx context.Context, req *dto.UpdateUserAuthMethodRequest) error
	DeleteUserDevice(ctx context.Context, req *dto.DeleteUserDeivceRequest) error
	UpdateUserDevice(ctx context.Context, req *dto.UserDevice) error
	KickOfflineByUserDevice(ctx context.Context, req *dto.KickOfflineRequest) error
	GetUserLoginLogs(ctx context.Context, req *dto.GetUserLoginLogsRequest) (*dto.GetUserLoginLogsResponse, error)
	UpdateUserBasicInfo(ctx context.Context, req *dto.UpdateUserBasiceInfoRequest) error
	UpdateUserNotifySetting(ctx context.Context, req *dto.UpdateUserNotifySettingRequest) error

	// The profile flows resolve the current user from the request context:
	// account info, credentials, third-party bindings, devices and
	// notification preferences.
	QueryUserInfo(ctx context.Context) (*dto.User, error)
	UpdateUserPassword(ctx context.Context, req *dto.UpdateUserPasswordRequest) error
	UpdateUserNotify(ctx context.Context, req *dto.UpdateUserNotifyRequest) error
	UpdateUserRules(ctx context.Context, req *dto.UpdateUserRulesRequest) error
	GetLoginLog(ctx context.Context, req *dto.GetLoginLogRequest) (*dto.GetLoginLogResponse, error)
	GetDeviceList(ctx context.Context) (*dto.GetDeviceListResponse, error)
	UnbindDevice(ctx context.Context, req *dto.UnbindDeviceRequest) error
	GetOAuthMethods(ctx context.Context) (*dto.GetOAuthMethodsResponse, error)
	BindOAuth(ctx context.Context, req *dto.BindOAuthRequest) (*dto.BindOAuthResponse, error)
	BindOAuthCallback(ctx context.Context, req *dto.BindOAuthCallbackRequest) error
	UnbindOAuth(ctx context.Context, req *dto.UnbindOAuthRequest) error
	BindTelegram(ctx context.Context) (*dto.BindTelegramResponse, error)
	UnbindTelegram(ctx context.Context) error
	UpdateBindEmail(ctx context.Context, req *dto.UpdateBindEmailRequest) error
	VerifyEmail(ctx context.Context, req *dto.VerifyEmailRequest) error
	UpdateBindMobile(ctx context.Context, req *dto.UpdateBindMobileRequest) error

	// The authentication flows: existence checks, credential/telephone/device
	// login and registration, password resets and the OAuth handshakes.
	// Transport concerns (client IP, user agent, login turnstile) stay in the
	// handlers.
	CheckUser(ctx context.Context, req *dto.CheckUserRequest) (*dto.CheckUserResponse, error)
	CheckUserTelephone(ctx context.Context, req *dto.TelephoneCheckUserRequest) (*dto.TelephoneCheckUserResponse, error)
	UserLogin(ctx context.Context, req *dto.UserLoginRequest) (*dto.LoginResponse, error)
	UserRegister(ctx context.Context, req *dto.UserRegisterRequest) (*dto.LoginResponse, error)
	TelephoneLogin(ctx context.Context, req *dto.TelephoneLoginRequest, ip, userAgent string) (*dto.LoginResponse, error)
	TelephoneUserRegister(ctx context.Context, req *dto.TelephoneRegisterRequest) (*dto.LoginResponse, error)
	ResetPassword(ctx context.Context, req *dto.ResetPasswordRequest) (*dto.LoginResponse, error)
	TelephoneResetPassword(ctx context.Context, req *dto.TelephoneResetPasswordRequest) (*dto.LoginResponse, error)
	DeviceLogin(ctx context.Context, req *dto.DeviceLoginRequest) (*dto.LoginResponse, error)
	OAuthLogin(ctx context.Context, req *dto.OAthLoginRequest) (*dto.OAuthLoginResponse, error)
	OAuthLoginGetToken(ctx context.Context, req *dto.OAuthLoginGetTokenRequest, ip, userAgent string) (*dto.LoginResponse, error)
	AppleLoginCallback(ctx context.Context, req *dto.AppleLoginCallbackRequest) (*AppleLoginRedirect, error)

	// The admin-side authentication-method management: configuration,
	// sender platforms and test sends.
	GetAuthMethodList(ctx context.Context) (*dto.GetAuthMethodListResponse, error)
	GetAuthMethodConfig(ctx context.Context, req *dto.GetAuthMethodConfigRequest) (*dto.AuthMethodConfig, error)
	UpdateAuthMethodConfig(ctx context.Context, req *dto.UpdateAuthMethodConfigRequest) (*dto.AuthMethodConfig, error)
	GetEmailPlatform(ctx context.Context) (*dto.PlatformResponse, error)
	GetSmsPlatform(ctx context.Context) (*dto.PlatformResponse, error)
	TestEmailSend(ctx context.Context, req *dto.TestEmailSendRequest) error
	TestSmsSend(ctx context.Context, req *dto.TestSmsSendRequest) error

	// The verification-code flows issue and pre-check the email/SMS codes
	// gating registration and account mutations.
	SendEmailCode(ctx context.Context, req *dto.SendCodeRequest) (*dto.SendCodeResponse, error)
	SendSmsCode(ctx context.Context, req *dto.SendSmsCodeRequest) (*dto.SendCodeResponse, error)
	CheckVerificationCode(ctx context.Context, req *dto.CheckVerificationCodeRequest) (*dto.CheckVerificationCodeRespone, error)
}

Service is the only surface other code may depend on; the implementation lives under internal/ where the compiler seals it off.

func New

func New(deps Deps) Service

type VerificationTaskQueue

type VerificationTaskQueue = verifycode.VerificationTaskQueue

VerificationTaskQueue and VerifyCodeSnapshot re-export the verification-code subdomain's ports for the composition root.

type VerifyCodeSnapshot

type VerifyCodeSnapshot = verifycode.Snapshot

VerificationTaskQueue and VerifyCodeSnapshot re-export the verification-code subdomain's ports for the composition root.

Directories

Path Synopsis
entity
internal
adminuser
Package adminuser implements the admin-side account management subdomain of the identity module: user CRUD, auth methods, devices and login logs.
Package adminuser implements the admin-side account management subdomain of the identity module: user CRUD, auth methods, devices and login logs.
authmethodadmin
Service assembly for the admin-side authentication-method subdomain of the identity module: method configuration, sender platforms and test sends.
Service assembly for the admin-side authentication-method subdomain of the identity module: method configuration, sender platforms and test sends.
authn
Service assembly for the authentication subdomain.
Service assembly for the authentication subdomain.
authn/registerpolicy
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.
profile
Package profile implements the self-service identity subdomain of the identity module: account info, credentials, third-party bindings, devices and notification preferences.
Package profile implements the self-service identity subdomain of the identity module: account info, credentials, third-party bindings, devices and notification preferences.
repo
Package repo holds the identity module's repository implementations: the user account rows, auth methods, devices and the cross-domain cache facade (ADR-001 step-6 preparation).
Package repo holds the identity module's repository implementations: the user account rows, auth methods, devices and the cross-domain cache facade (ADR-001 step-6 preparation).
verifycode
Service assembly for the verification-code subdomain: issuing and pre-checking the email/SMS codes that gate registration and account mutations.
Service assembly for the verification-code subdomain: issuing and pre-checking the email/SMS codes that gate registration and account mutations.

Jump to

Keyboard shortcuts

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