diff --git a/cfg/dev.yaml b/cfg/dev.yaml index 3efeadc1f..f4320960a 100644 --- a/cfg/dev.yaml +++ b/cfg/dev.yaml @@ -1,4 +1,6 @@ probod: + auth: + invitation-confirmation-token-validity: 3600 api: cors: allowed-origins: ["http://localhost:8080", "http://localhost:5173"] diff --git a/pkg/probod/auth_config.go b/pkg/probod/auth_config.go index fc04f3182..a66ccea67 100644 --- a/pkg/probod/auth_config.go +++ b/pkg/probod/auth_config.go @@ -21,9 +21,10 @@ import ( type ( authConfig struct { - Cookie cookieConfig `json:"cookie"` - Password passwordConfig `json:"password"` - DisableSignup bool `json:"disable-signup"` + Cookie cookieConfig `json:"cookie"` + Password passwordConfig `json:"password"` + DisableSignup bool `json:"disable-signup"` + InvitationConfirmationTokenValidity int `json:"invitation-confirmation-token-validity"` } trustAuthConfig struct { diff --git a/pkg/probod/probod.go b/pkg/probod/probod.go index b74c84c7c..ab792551f 100644 --- a/pkg/probod/probod.go +++ b/pkg/probod/probod.go @@ -99,7 +99,8 @@ func New() *Implm { Duration: 24, Domain: "localhost", }, - DisableSignup: false, + DisableSignup: false, + InvitationConfirmationTokenValidity: 3600, }, TrustAuth: trustAuthConfig{ CookieName: "TCT", @@ -235,6 +236,7 @@ func (impl *Implm) Run( impl.cfg.Auth.Cookie.Secret, impl.cfg.Hostname, impl.cfg.Auth.DisableSignup, + time.Duration(impl.cfg.Auth.InvitationConfirmationTokenValidity)*time.Second, ) if err != nil { return fmt.Errorf("cannot create usrmgr service: %w", err) diff --git a/pkg/usrmgr/usrmgr.go b/pkg/usrmgr/usrmgr.go index 593aa3c7f..07bce1443 100644 --- a/pkg/usrmgr/usrmgr.go +++ b/pkg/usrmgr/usrmgr.go @@ -32,11 +32,12 @@ import ( type ( Service struct { - pg *pg.Client - hp *passwdhash.Profile - hostname string - tokenSecret string - disableSignup bool + pg *pg.Client + hp *passwdhash.Profile + hostname string + tokenSecret string + disableSignup bool + invitationTokenValidity time.Duration } ErrInvalidCredentials struct { @@ -168,13 +169,15 @@ func NewService( tokenSecret string, hostname string, disableSignup bool, + invitationTokenValidity time.Duration, ) (*Service, error) { return &Service{ - pg: pgClient, - hp: hp, - hostname: hostname, - tokenSecret: tokenSecret, - disableSignup: disableSignup, + pg: pgClient, + hp: hp, + hostname: hostname, + tokenSecret: tokenSecret, + disableSignup: disableSignup, + invitationTokenValidity: invitationTokenValidity, }, nil } @@ -710,7 +713,7 @@ func (s Service) InviteUser( confirmationToken, err := statelesstoken.NewToken( s.tokenSecret, TokenTypeOrganizationInvitation, - 12*time.Hour, + s.invitationTokenValidity, InvitationData{OrganizationID: organizationID, Email: emailAddress, FullName: fullName}, ) if err != nil {