Documentation
¶
Overview ¶
Package modules hosts the core-side adapters between the composition root and the real v1 modules under modules/: repository-to-seam bridges whose only layer may import both sides (user policy, auth notifications, soft delete, profile pictures), plus the logger adapter. The Phase 1 transitional wrappers are fully retired — every first-party feature is a real module — so only DefaultEdition (kept for the Phase 4.1 disabled/cascade work) and the adapters remain.
Index ¶
- func ApplyDisabled(registry *kernel.Registry, candidates []kernel.Module, disabled []string, ...) (map[string]bool, error)
- func DefaultEdition() []kernel.Module
- func EffectiveCommentsEnabled(legacyEnabled bool, modulesDisabled []string, kept map[string]bool) bool
- func NewAgentMediaRoleCapabilities(service *roledomain.Service) mediaagent.RoleCapabilities
- func NewLogger(logger *util.Logger) kernel.Logger
- func NewMFACodeDeliverer(sender MFACodeSender, logger kernel.Logger, devMode bool, emailEnabled bool) authapi.MFACodeDeliverer
- func NewMediaPrivacyRedactor(service *privacydomain.Service) mediadomain.Redactor
- func NewMediaRoleCapabilities(service *roledomain.Service) mediaapi.RoleCapabilities
- func NewProfilePicturePrivacyRedactor(service *privacydomain.Service) profilepicture.Redactor
- func NewRoleCapabilities(service *roledomain.Service) api.RoleCapabilities
- type AuthNotificationRecorder
- type EmailMFACodeDeliverer
- type JWTTokenIssuer
- type LogMFACodeDeliverer
- type MFACodeSender
- type ProfilePictureUserRepo
- func (r *ProfilePictureUserRepo) DeleteProfilePicture(ctx context.Context, userID int) error
- func (r *ProfilePictureUserRepo) GetUserByID(ctx context.Context, userID int) (string, error)
- func (r *ProfilePictureUserRepo) UpdateProfilePicture(ctx context.Context, userID int, profilePicture string) error
- type SoftDeleteStore
- func (s *SoftDeleteStore) GetSoftDeletedContentByID(ctx context.Context, id int) (*usersapi.SoftDeletedContent, error)
- func (s *SoftDeleteStore) GetSoftDeletedContentByUser(ctx context.Context, userID int) ([]*usersapi.SoftDeletedContent, error)
- func (s *SoftDeleteStore) RestoreContent(ctx context.Context, contentType string, contentID int) error
- type UserCredentialPolicy
- func (UserCredentialPolicy) GeneratePassword(length int) (string, error)
- func (UserCredentialPolicy) HashPassword(password string) (string, error)
- func (UserCredentialPolicy) NeedsRehash(hash string) bool
- func (UserCredentialPolicy) ValidateEmail(email string) error
- func (UserCredentialPolicy) ValidatePassword(password string) error
- func (UserCredentialPolicy) ValidateUsername(username string) error
- func (UserCredentialPolicy) VerifyPassword(hash, password string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyDisabled ¶
func ApplyDisabled( registry *kernel.Registry, candidates []kernel.Module, disabled []string, warnf func(format string, args ...any), ) (map[string]bool, error)
ApplyDisabled prunes the disabled modules (plus cascade) from the candidates, reports each drop and each unknown name through warnf, and registers only the kept modules. It returns the kept name set for back-compat flag mapping. Register errors return; the composition root fails startup on them. Unknown names warn and are ignored so configs stay portable across editions.
func DefaultEdition ¶
DefaultEdition returns every first-party wrapper — the default composition root. Registration order is irrelevant; the registry topologically sorts. All wrappers are retired: every first-party feature is a real module, so the edition is empty until Phase 4.1 rebuilds it on the disabled/cascade matrix.
func EffectiveCommentsEnabled ¶
func EffectiveCommentsEnabled(legacyEnabled bool, modulesDisabled []string, kept map[string]bool) bool
EffectiveCommentsEnabled folds the legacy [comments] toggle and the v1 modules disabled list into the single flag every consumer reads. Disabling the comments module is equivalent to the legacy toggle; a cascaded drop (kept lacks comments) unmounts the routes the same way. Headless mode is independent: it never reaches this function.
func NewAgentMediaRoleCapabilities ¶
func NewAgentMediaRoleCapabilities(service *roledomain.Service) mediaagent.RoleCapabilities
NewAgentMediaRoleCapabilities adapts the config-driven role registry to the media module's agent seam (upload gate). A nil service yields nil, and the module preserves the legacy allow-all behavior.
func NewLogger ¶
NewLogger adapts *util.Logger to kernel.Logger. A nil logger yields nil, and kernel.NewHost substitutes its discard sink.
func NewMFACodeDeliverer ¶ added in v1.1.0
func NewMFACodeDeliverer( sender MFACodeSender, logger kernel.Logger, devMode bool, emailEnabled bool, ) authapi.MFACodeDeliverer
NewMFACodeDeliverer selects the delivery channel from configuration: email whenever SMTP is enabled, and the stdout sink only for the explicitly gated dev combination.
func NewMediaPrivacyRedactor ¶ added in v1.2.1
func NewMediaPrivacyRedactor(service *privacydomain.Service) mediadomain.Redactor
NewMediaPrivacyRedactor creates a media Redactor over the privacy service. A nil service yields an inert redactor that returns its input unchanged, preserving the legacy pipeline when SAM is disabled.
func NewMediaRoleCapabilities ¶
func NewMediaRoleCapabilities(service *roledomain.Service) mediaapi.RoleCapabilities
NewMediaRoleCapabilities adapts the config-driven role registry to the media module's browser seam (upload/generate/delete gates). A nil service yields nil, and the module preserves the legacy allow-all behavior.
func NewProfilePicturePrivacyRedactor ¶ added in v1.2.1
func NewProfilePicturePrivacyRedactor(service *privacydomain.Service) profilepicture.Redactor
NewProfilePicturePrivacyRedactor creates a profile-picture Redactor over the privacy service. A nil service yields nil, and the service preserves the legacy pipeline when SAM is disabled.
func NewRoleCapabilities ¶
func NewRoleCapabilities(service *roledomain.Service) api.RoleCapabilities
NewRoleCapabilities adapts the config-driven role registry to the posttypes-basic module's narrow seam. It lives in core — the only layer that may import both sides — until the users module implements the seam natively, at which point this adapter is deleted. A nil service yields nil, and the module fails its roles endpoint closed.
Types ¶
type AuthNotificationRecorder ¶
type AuthNotificationRecorder struct {
// contains filtered or unexported fields
}
AuthNotificationRecorder adapts the notification repository to the auth module's NotificationRecorder seam. Message formatting (HTML-escaped, matching the pre-module handler text byte-for-byte) lives here so the module never imports repository notification types. It lives in core — the only layer that may import both sides.
func NewAuthNotificationRecorder ¶
func NewAuthNotificationRecorder(repo repository.NotificationRepo) *AuthNotificationRecorder
NewAuthNotificationRecorder creates an AuthNotificationRecorder.
func (*AuthNotificationRecorder) RecordUserRegistered ¶
func (r *AuthNotificationRecorder) RecordUserRegistered(ctx context.Context, username, email string) error
RecordUserRegistered records a new-registration admin notification.
func (*AuthNotificationRecorder) RecordUserVerified ¶
func (r *AuthNotificationRecorder) RecordUserVerified(ctx context.Context, username, email string) error
RecordUserVerified records an email-verified admin notification.
type EmailMFACodeDeliverer ¶ added in v1.1.0
type EmailMFACodeDeliverer struct {
// contains filtered or unexported fields
}
EmailMFACodeDeliverer delivers login verification codes through the account mailer.
func NewEmailMFACodeDeliverer ¶ added in v1.1.0
func NewEmailMFACodeDeliverer(sender MFACodeSender) *EmailMFACodeDeliverer
NewEmailMFACodeDeliverer creates an email-backed code deliverer.
func (*EmailMFACodeDeliverer) DeliverMFACode ¶ added in v1.1.0
func (d *EmailMFACodeDeliverer) DeliverMFACode(ctx context.Context, to, username, code string) error
DeliverMFACode sends the code to the user's email address.
type JWTTokenIssuer ¶ added in v1.1.0
type JWTTokenIssuer struct {
// contains filtered or unexported fields
}
JWTTokenIssuer adapts the platform JWT manager to the auth module's TokenIssuer seam. It lives in core — the only layer that may import both sides — so the module never reaches into internal packages.
func NewJWTTokenIssuer ¶ added in v1.1.0
func NewJWTTokenIssuer(manager *auth.JWTManager) *JWTTokenIssuer
NewJWTTokenIssuer creates a TokenIssuer backed by the platform JWT manager.
func (*JWTTokenIssuer) GenerateToken ¶ added in v1.1.0
func (a *JWTTokenIssuer) GenerateToken( userID, username, role string, tokenVersion int, ) (string, error)
GenerateToken mints a JWT for an authenticated session.
func (*JWTTokenIssuer) ValidateTokenExpiry ¶ added in v1.1.0
func (a *JWTTokenIssuer) ValidateTokenExpiry(token string) (time.Time, error)
ValidateTokenExpiry validates the token and reports its expiry so the session cookie lifetime matches the token instead of duplicating the TTL.
type LogMFACodeDeliverer ¶ added in v1.1.0
type LogMFACodeDeliverer struct {
// contains filtered or unexported fields
}
LogMFACodeDeliverer writes login verification codes to the application log. It is selected only when DEV_MODE is on and SMTP is unconfigured — the one combination where the code cannot be delivered any other way. Production never reaches it: SMTP configured wins, and missing SMTP without DEV_MODE uses the email deliverer, which fails closed.
func NewLogMFACodeDeliverer ¶ added in v1.1.0
func NewLogMFACodeDeliverer(logger kernel.Logger) *LogMFACodeDeliverer
NewLogMFACodeDeliverer creates a log-only code deliverer.
func (*LogMFACodeDeliverer) DeliverMFACode ¶ added in v1.1.0
func (d *LogMFACodeDeliverer) DeliverMFACode(_ context.Context, to, username, code string) error
DeliverMFACode logs the code instead of sending it.
type MFACodeSender ¶ added in v1.1.0
type MFACodeSender interface {
SendMFACodeEmail(ctx context.Context, to, username, code string) error
}
MFACodeSender is the email-channel subset the deliverer needs. The core email service satisfies it structurally.
type ProfilePictureUserRepo ¶
type ProfilePictureUserRepo struct {
// contains filtered or unexported fields
}
ProfilePictureUserRepo adapts repository.UserRepo to the users module's profilepicture.UserRepo seam. It lives in core — the only layer that may import both sides.
func NewProfilePictureUserRepo ¶
func NewProfilePictureUserRepo(repo repository.UserRepo) *ProfilePictureUserRepo
NewProfilePictureUserRepo creates a ProfilePictureUserRepo.
func (*ProfilePictureUserRepo) DeleteProfilePicture ¶
func (r *ProfilePictureUserRepo) DeleteProfilePicture(ctx context.Context, userID int) error
DeleteProfilePicture clears a user's profile picture.
func (*ProfilePictureUserRepo) GetUserByID ¶
GetUserByID returns the profile picture filename for a user.
func (*ProfilePictureUserRepo) UpdateProfilePicture ¶
func (r *ProfilePictureUserRepo) UpdateProfilePicture(ctx context.Context, userID int, profilePicture string) error
UpdateProfilePicture updates a user's profile picture filename.
type SoftDeleteStore ¶
type SoftDeleteStore struct {
// contains filtered or unexported fields
}
SoftDeleteStore adapts repository.SoftDeleteRepo to the users module's SoftDeleteStore seam. Database null types are converted at this boundary so the module never imports database/sql. It lives in core — the only layer that may import both sides.
func NewSoftDeleteStore ¶
func NewSoftDeleteStore(repo repository.SoftDeleteRepo) *SoftDeleteStore
NewSoftDeleteStore creates a SoftDeleteStore.
func (*SoftDeleteStore) GetSoftDeletedContentByID ¶
func (s *SoftDeleteStore) GetSoftDeletedContentByID(ctx context.Context, id int) (*usersapi.SoftDeletedContent, error)
GetSoftDeletedContentByID returns one soft-deleted content record.
func (*SoftDeleteStore) GetSoftDeletedContentByUser ¶
func (s *SoftDeleteStore) GetSoftDeletedContentByUser(ctx context.Context, userID int) ([]*usersapi.SoftDeletedContent, error)
GetSoftDeletedContentByUser returns the soft-deleted content of a user.
func (*SoftDeleteStore) RestoreContent ¶
func (s *SoftDeleteStore) RestoreContent(ctx context.Context, contentType string, contentID int) error
RestoreContent restores soft-deleted content.
type UserCredentialPolicy ¶
type UserCredentialPolicy struct{}
UserCredentialPolicy adapts the platform credential rules to the users module's CredentialPolicy seam: email/password/username syntax from internal/auth plus the registration username rule from the auth module. Password hashing uses the platform argon2id parameters, so hashes remain verifiable across the move. It lives in core — the only layer that may import both sides.
func NewUserCredentialPolicy ¶
func NewUserCredentialPolicy() UserCredentialPolicy
NewUserCredentialPolicy creates a UserCredentialPolicy. The concrete value satisfies both the users and the auth CredentialPolicy seams.
func (UserCredentialPolicy) GeneratePassword ¶
func (UserCredentialPolicy) GeneratePassword(length int) (string, error)
GeneratePassword generates a random password of the given length.
func (UserCredentialPolicy) HashPassword ¶
func (UserCredentialPolicy) HashPassword(password string) (string, error)
HashPassword hashes a password with the platform parameters.
func (UserCredentialPolicy) NeedsRehash ¶
func (UserCredentialPolicy) NeedsRehash(hash string) bool
NeedsRehash reports whether a hash uses outdated parameters.
func (UserCredentialPolicy) ValidateEmail ¶
func (UserCredentialPolicy) ValidateEmail(email string) error
ValidateEmail checks email format per platform rules, translating the platform error to the module sentinel (same message, matchable without importing internal packages).
func (UserCredentialPolicy) ValidatePassword ¶
func (UserCredentialPolicy) ValidatePassword(password string) error
ValidatePassword checks password strength per platform rules, translating the platform error to the module sentinel (same message, matchable without importing internal packages).
func (UserCredentialPolicy) ValidateUsername ¶
func (UserCredentialPolicy) ValidateUsername(username string) error
ValidateUsername checks username format per the registration rule.
func (UserCredentialPolicy) VerifyPassword ¶
func (UserCredentialPolicy) VerifyPassword(hash, password string) error
VerifyPassword verifies a password against its hash.