diff --git a/app.go b/app.go index 874bedf..640803b 100644 --- a/app.go +++ b/app.go @@ -48,7 +48,7 @@ import ( const ( AuthPrefix = "Bearer " - Postgres = "postgresql" + Postgres = "postgres" Sqlite = "sqlite3" updateInterval = 5000 HTTPReadTimeout = 30 * time.Second diff --git a/cmd/headscale/cli/preauthkeys.go b/cmd/headscale/cli/preauthkeys.go index 9d5c838..5342085 100644 --- a/cmd/headscale/cli/preauthkeys.go +++ b/cmd/headscale/cli/preauthkeys.go @@ -13,7 +13,7 @@ import ( ) const ( - DefaultPreAuthKeyExpiry = 24 * time.Hour + DefaultPreAuthKeyExpiry = 1 * time.Hour ) func init() { @@ -145,14 +145,12 @@ var createPreAuthKeyCmd = &cobra.Command{ Ephemeral: ephemeral, } - if cmd.Flags().Changed("expiration") { - duration, _ := cmd.Flags().GetDuration("expiration") - expiration := time.Now().UTC().Add(duration) + duration, _ := cmd.Flags().GetDuration("expiration") + expiration := time.Now().UTC().Add(duration) - log.Trace().Dur("expiration", duration).Msg("expiration has been set") + log.Trace().Dur("expiration", duration).Msg("expiration has been set") - request.Expiration = timestamppb.New(expiration) - } + request.Expiration = timestamppb.New(expiration) ctx, client, conn, cancel := getHeadscaleCLIClient() defer cancel() diff --git a/integration_cli_test.go b/integration_cli_test.go index 81a1933..0278da0 100644 --- a/integration_cli_test.go +++ b/integration_cli_test.go @@ -426,7 +426,12 @@ func (s *IntegrationCLITestSuite) TestPreAuthKeyCommandWithoutExpiry() { assert.Nil(s.T(), err) assert.Len(s.T(), listedPreAuthKeys, 1) - assert.True(s.T(), time.Time{}.Equal(listedPreAuthKeys[0].Expiration.AsTime())) + + assert.True(s.T(), listedPreAuthKeys[0].Expiration.AsTime().After(time.Now())) + assert.True( + s.T(), + listedPreAuthKeys[0].Expiration.AsTime().Before(time.Now().Add(time.Minute*70)), + ) } func (s *IntegrationCLITestSuite) TestPreAuthKeyCommandReusableEphemeral() {