Use a constant prefix for our internal token

This commit is contained in:
Tobias Gesellchen
2026-04-06 21:15:15 +02:00
parent 153d387aaf
commit 5d933f7ebc
2 changed files with 6 additions and 4 deletions
+2 -2
View File
@@ -139,8 +139,8 @@ func TestSpotifyBridge(t *testing.T) {
t.Fatal("Could not find surrogate token in Marge sources")
}
if len(surrogate) != 32 {
t.Errorf("Expected surrogate to be 32 hex chars, got %s", surrogate)
if !strings.HasPrefix(surrogate, "bs-") || len(surrogate) != 35 {
t.Errorf("Expected surrogate to have 'bs-' prefix and be 35 chars, got %s", surrogate)
}
// Request refresh
+4 -2
View File
@@ -350,13 +350,15 @@ func (s *Service) GetAccountBySecret(secret string) (*Account, bool) {
}
func (s *Service) generateBoseSecret() string {
prefix := "bs-"
b := make([]byte, 16)
if _, err := rand.Read(b); err != nil {
// Fallback to timestamp-based if RNG fails
return fmt.Sprintf("bs-%d", time.Now().UnixNano())
return fmt.Sprintf("%s%d", prefix, time.Now().UnixNano())
}
return hex.EncodeToString(b)
return prefix + hex.EncodeToString(b)
}
// ResolveEntity resolves a Spotify URI to a name and image URL.