Documentation
¶
Index ¶
- func ApplyEmailIdentityChange(identity *modeliamaccount.EmailIdentity, newEmail string, changedAt time.Time) error
- func ApplyEmailIdentityVerification(identity *modeliamaccount.EmailIdentity, verifiedAt time.Time) error
- func ApplyPasswordCredentialUpdate(ctx context.Context, credential *modeliamaccount.PasswordCredential, ...) error
- func CreateAccount(ctx context.Context, newUser *modeliamuser.User, password string, ...) error
- func LoadActor(ctx *gst.ServiceContext) (*modeliamuser.User, error)
- func LoadActorAndTarget(ctx *gst.ServiceContext, targetUserID string) (*modeliamuser.User, *modeliamuser.User, error)
- func LoadEmailIdentity(ctx context.Context, userID string) (*modeliamaccount.EmailIdentity, error)
- func LoadEmailIdentityByEmail(ctx context.Context, email string) (*modeliamaccount.EmailIdentity, error)
- func LoadPasswordCredential(ctx context.Context, userID string) (*modeliamaccount.PasswordCredential, error)
- func NewEmailIdentity(userID, email string) (*modeliamaccount.EmailIdentity, error)
- func NewPasswordCredential(ctx context.Context, userID, password string, mustChangePassword bool) (*modeliamaccount.PasswordCredential, error)
- func NormalizeEmailIdentity(email string) string
- func SeedRoot(ctx context.Context, _ map[string][]string) error
- func VerifyPasswordCredential(ctx context.Context, credential *modeliamaccount.PasswordCredential, ...) error
- type ChangePasswordService
- type LoginService
- type LogoutService
- type ResetPasswordService
- type SignupService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyEmailIdentityChange ¶
func ApplyEmailIdentityChange(identity *modeliamaccount.EmailIdentity, newEmail string, changedAt time.Time) error
ApplyEmailIdentityChange replaces the email address and marks the new address as verified.
func ApplyEmailIdentityVerification ¶
func ApplyEmailIdentityVerification(identity *modeliamaccount.EmailIdentity, verifiedAt time.Time) error
ApplyEmailIdentityVerification marks an email identity as verified.
func ApplyPasswordCredentialUpdate ¶
func ApplyPasswordCredentialUpdate(ctx context.Context, credential *modeliamaccount.PasswordCredential, newPassword string, mustChangePassword bool) error
ApplyPasswordCredentialUpdate replaces the credential hash and password-change state.
func CreateAccount ¶
func CreateAccount(ctx context.Context, newUser *modeliamuser.User, password string, mustChangePassword bool) error
CreateAccount writes newUser and its password credential, the two rows an account that logs in with a password is made of, in one transaction: its own, or the one ctx already carries. newUser is written as given, so an id set beforehand stays and an empty one is generated on insert; password is hashed the way the module stores and verifies one, and with mustChangePassword the first login asks for a replacement.
func LoadActor ¶
func LoadActor(ctx *gst.ServiceContext) (*modeliamuser.User, error)
LoadActor resolves the authenticated user for the current request.
IAM admin APIs use the session snapshot only as the authentication source; they still reload the user row from the database so status, IDs, and system role checks operate on the current persisted user.
func LoadActorAndTarget ¶
func LoadActorAndTarget(ctx *gst.ServiceContext, targetUserID string) (*modeliamuser.User, *modeliamuser.User, error)
LoadActorAndTarget resolves the actor and target users used by admin actions.
It intentionally does not authorize the relationship between the two users. Callers must pass both users to adminauth.EnsureTenantAdmin so target-specific rules, such as tenant membership and system-root protection, are evaluated in one place.
func LoadEmailIdentity ¶
func LoadEmailIdentity(ctx context.Context, userID string) (*modeliamaccount.EmailIdentity, error)
LoadEmailIdentity loads the primary email identity owned by the given IAM user.
func LoadEmailIdentityByEmail ¶
func LoadEmailIdentityByEmail(ctx context.Context, email string) (*modeliamaccount.EmailIdentity, error)
LoadEmailIdentityByEmail loads the primary email identity for a normalized email address.
func LoadPasswordCredential ¶
func LoadPasswordCredential(ctx context.Context, userID string) (*modeliamaccount.PasswordCredential, error)
LoadPasswordCredential loads the password credential owned by the given IAM user.
func NewEmailIdentity ¶
func NewEmailIdentity(userID, email string) (*modeliamaccount.EmailIdentity, error)
NewEmailIdentity creates the primary email identity for the given IAM user.
func NewPasswordCredential ¶
func NewPasswordCredential(ctx context.Context, userID, password string, mustChangePassword bool) (*modeliamaccount.PasswordCredential, error)
NewPasswordCredential creates a password credential for the given IAM user.
func NormalizeEmailIdentity ¶
NormalizeEmailIdentity normalizes an email address for exact identity lookup.
func SeedRoot ¶
SeedRoot is the startup hook that writes the built-in root account, the user whose id is rbac.UserRoot, which RBAC grants the system root role to, from the environment: IAM_ROOT_PASSWORD is the password, held to the rule a signup's password is held to, and an unset or empty variable writes nothing. The hook runs at every start and leaves the account alone once it exists, the password included: a changed variable rotates nothing, a password is changed through the module's routes. Register installs the hook; a project that copied the module installs it in assembly code of its own, router.OnRoutesReady(SeedRoot).
func VerifyPasswordCredential ¶
func VerifyPasswordCredential(ctx context.Context, credential *modeliamaccount.PasswordCredential, password string) error
VerifyPasswordCredential verifies a plaintext password against a credential hash. The bcrypt comparison is deliberately slow (tens of milliseconds) to resist brute-force attacks, so it runs inside an iam.VerifyPassword span to keep that cost visible in request traces. A password mismatch is an expected business outcome and never marks the span as failed; only unexpected verification errors are recorded as span errors.
Types ¶
type ChangePasswordService ¶
type ChangePasswordService struct {
service.Base[*modeliamaccount.ChangePassword, *modeliamaccount.ChangePasswordReq, *modeliamaccount.ChangePasswordRsp]
}
func (*ChangePasswordService) Create ¶
func (c *ChangePasswordService) Create(ctx *gst.ServiceContext, req *modeliamaccount.ChangePasswordReq) (rsp *modeliamaccount.ChangePasswordRsp, err error)
type LoginService ¶
type LoginService struct {
service.Base[*modeliamaccount.Login, *modeliamaccount.LoginReq, *modeliamaccount.LoginRsp]
}
func (*LoginService) Create ¶
func (l *LoginService) Create(ctx *gst.ServiceContext, req *modeliamaccount.LoginReq) (rsp *modeliamaccount.LoginRsp, err error)
Create authenticates an IAM account and creates a new session.
The local login path verifies username, password, and account status before creating the session.
type LogoutService ¶
type LogoutService struct {
service.Base[*modeliamaccount.Logout, *model.Empty, *modeliamaccount.LogoutRsp]
}
LogoutService handles logout requests for the current authenticated session.
func (*LogoutService) Create ¶
func (l *LogoutService) Create(ctx *gst.ServiceContext, req *model.Empty) (rsp *modeliamaccount.LogoutRsp, err error)
Create logs out the current session and always clears the session cookie on success.
type ResetPasswordService ¶
type ResetPasswordService struct {
service.Base[*modeliamaccount.ResetPassword, *modeliamaccount.ResetPasswordReq, *modeliamaccount.ResetPasswordRsp]
}
func (*ResetPasswordService) Create ¶
func (r *ResetPasswordService) Create(ctx *gst.ServiceContext, req *modeliamaccount.ResetPasswordReq) (rsp *modeliamaccount.ResetPasswordRsp, err error)
type SignupService ¶
type SignupService struct {
service.Base[*modeliamaccount.Signup, *modeliamaccount.SignupReq, *modeliamaccount.SignupRsp]
}
func (*SignupService) Create ¶
func (s *SignupService) Create(ctx *gst.ServiceContext, req *modeliamaccount.SignupReq) (rsp *modeliamaccount.SignupRsp, err error)