serviceiamaccount

package
v0.0.0-...-779303e Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

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

func NormalizeEmailIdentity(email string) string

NormalizeEmailIdentity normalizes an email address for exact identity lookup.

func SeedRoot

func SeedRoot(ctx context.Context, _ map[string][]string) error

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 LoginService

func (*LoginService) Create

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 SignupService

func (*SignupService) Create

Jump to

Keyboard shortcuts

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