SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(user): add config for user invite token expiry (#10618)
Vikrant Gupta5bafdeb373be
diff --git a/conf/example.yaml b/conf/example.yamlindex b670810b74..60ce89b6cd 100644--- a/conf/example.yaml+++ b/conf/example.yaml@@ -308,6 +308,9 @@ user:allow_self: true# The duration within which a user can reset their password.max_token_lifetime: 6h+ invite:+ # The duration within which a user can accept their invite.+ max_token_lifetime: 48hroot:# Whether to enable the root user. When enabled, a root user is provisioned# on startup using the email and password below. The root user cannot bediff --git a/pkg/modules/user/config.go b/pkg/modules/user/config.goindex 487ae5e687..87a3336999 100644--- a/pkg/modules/user/config.go+++ b/pkg/modules/user/config.go@@ -27,7 +27,12 @@ type OrgConfig struct {}type PasswordConfig struct {- Reset ResetConfig `mapstructure:"reset"`+ Invite InviteConfig `mapstructure:"invite"`+ Reset ResetConfig `mapstructure:"reset"`+}++type InviteConfig struct {+ MaxTokenLifetime time.Duration `mapstructure:"max_token_lifetime"`}type ResetConfig struct {@@ -46,6 +51,9 @@ func newConfig() factory.Config {AllowSelf: false,MaxTokenLifetime: 6 * time.Hour,},+ Invite: InviteConfig{+ MaxTokenLifetime: 48 * time.Hour,+ },},Root: RootConfig{Enabled: false,@@ -61,6 +69,10 @@ func (c Config) Validate() error {return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "user::password::reset::max_token_lifetime must be positive")}+ if c.Password.Invite.MaxTokenLifetime <= 0 {+ return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "user::password::invite::max_token_lifetime must be positive")+ }+if c.Root.Enabled {if c.Root.Email.IsZero() {return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "user::root::email is required when root user is enabled")diff --git a/pkg/modules/user/impluser/module.go b/pkg/modules/user/impluser/module.goindex 1ce5e23bd2..41ec1fe8c2 100644--- a/pkg/modules/user/impluser/module.go+++ b/pkg/modules/user/impluser/module.go@@ -203,7 +203,7 @@ func (m *Module) CreateBulkInvite(ctx context.Context, orgID valuer.UUID, userIDresetLink := userWithToken.ResetPasswordToken.FactorPasswordResetLink(frontendBaseUrl)- tokenLifetime := m.config.Password.Reset.MaxTokenLifetime+ tokenLifetime := m.config.Password.Invite.MaxTokenLifetimehumanizedTokenLifetime := strings.TrimSpace(humanize.RelTime(time.Now(), time.Now().Add(tokenLifetime), "", ""))if err := m.emailing.SendHTML(ctx, userWithToken.User.Email.String(), "You're Invited to Join SigNoz", emailtypes.TemplateNameInvitationEmail, map[string]any{@@ -460,7 +460,11 @@ func (module *Module) GetOrCreateResetPasswordToken(ctx context.Context, userID}// create a new token- resetPasswordToken, err := types.NewResetPasswordToken(password.ID, time.Now().Add(module.config.Password.Reset.MaxTokenLifetime))+ tokenLifetime := module.config.Password.Reset.MaxTokenLifetime+ if user.Status == types.UserStatusPendingInvite {+ tokenLifetime = module.config.Password.Invite.MaxTokenLifetime+ }+ resetPasswordToken, err := types.NewResetPasswordToken(password.ID, time.Now().Add(tokenLifetime))if err != nil {return nil, err}@@ -500,6 +504,9 @@ func (module *Module) ForgotPassword(ctx context.Context, orgID valuer.UUID, emaresetLink := token.FactorPasswordResetLink(frontendBaseURL)tokenLifetime := module.config.Password.Reset.MaxTokenLifetime+ if user.Status == types.UserStatusPendingInvite {+ tokenLifetime = module.config.Password.Invite.MaxTokenLifetime+ }humanizedTokenLifetime := strings.TrimSpace(humanize.RelTime(time.Now(), time.Now().Add(tokenLifetime), "", ""))if err := module.emailing.SendHTML(