Unverified Commit 6106b48f authored by Josh Black's avatar Josh Black Committed by GitHub
Browse files

fix version check (#14395)

parent dafe86ce
Showing with 16 additions and 10 deletions
+16 -10
...@@ -996,16 +996,22 @@ func (ts *TokenStore) create(ctx context.Context, entry *logical.TokenEntry) err ...@@ -996,16 +996,22 @@ func (ts *TokenStore) create(ctx context.Context, entry *logical.TokenEntry) err
if err != nil { if err != nil {
return err return err
} }
newestVersion, err := version.NewVersion(ver)
if err != nil { var newestVersion *version.Version
return err var oneTen *version.Version
}
oneTen, err := version.NewVersion("1.10.0") if ver != "" {
if err != nil { newestVersion, err = version.NewVersion(ver)
return err if err != nil {
return err
}
oneTen, err = version.NewVersion("1.10.0")
if err != nil {
return err
}
} }
if ts.core.DisableSSCTokens() || newestVersion.LessThan(oneTen) { if ts.core.DisableSSCTokens() || (newestVersion != nil && newestVersion.LessThan(oneTen)) {
entry.ID = consts.LegacyBatchTokenPrefix + bEntry entry.ID = consts.LegacyBatchTokenPrefix + bEntry
} else { } else {
entry.ID = consts.BatchTokenPrefix + bEntry entry.ID = consts.BatchTokenPrefix + bEntry
......
...@@ -70,7 +70,7 @@ func (c *Core) storeVersionTimestamp(ctx context.Context, version string, timest ...@@ -70,7 +70,7 @@ func (c *Core) storeVersionTimestamp(ctx context.Context, version string, timest
// FindOldestVersionTimestamp searches for the vault version with the oldest // FindOldestVersionTimestamp searches for the vault version with the oldest
// upgrade timestamp from storage. The earliest version this can be is 1.9.0. // upgrade timestamp from storage. The earliest version this can be is 1.9.0.
func (c *Core) FindOldestVersionTimestamp() (string, time.Time, error) { func (c *Core) FindOldestVersionTimestamp() (string, time.Time, error) {
if len(c.versionTimestamps) == 0 { if c.versionTimestamps == nil {
return "", time.Time{}, fmt.Errorf("version timestamps are not initialized") return "", time.Time{}, fmt.Errorf("version timestamps are not initialized")
} }
...@@ -87,7 +87,7 @@ func (c *Core) FindOldestVersionTimestamp() (string, time.Time, error) { ...@@ -87,7 +87,7 @@ func (c *Core) FindOldestVersionTimestamp() (string, time.Time, error) {
} }
func (c *Core) FindNewestVersionTimestamp() (string, time.Time, error) { func (c *Core) FindNewestVersionTimestamp() (string, time.Time, error) {
if len(c.versionTimestamps) == 0 { if c.versionTimestamps == nil {
return "", time.Time{}, fmt.Errorf("version timestamps are not initialized") return "", time.Time{}, fmt.Errorf("version timestamps are not initialized")
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment