feat: detect NetBox token version, hint on v1, better 403 message

- TokenVersion() distinguishes nbt_-prefixed v2 tokens from legacy v1
- 403 errors now say "check token permissions" + v1 hint if applicable
- Setup wizard prints a note after saving if a v1 token was entered

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Sebastian UnterschützandClaude Sonnet 4.6 committed 2026-05-23 13:11:01 +02:00
1 parent ff9c61c087
commit 9334003c9e
2 files changed
+22

No files matched your search

+6
View File
@@ -11,6 +11,7 @@ import (
"github.com/charmbracelet/huh"
"git.zb-server.de/Sebi/ssh-netbox-wrapper/internal/config"
"git.zb-server.de/Sebi/ssh-netbox-wrapper/internal/netbox"
)
// RunWizard runs the interactive setup form, pre-filled with any existing cfg values.
@@ -102,6 +103,11 @@ func RunWizard(cfg *config.Config) error {
return err
}
if netbox.TokenVersion(token) == 1 {
fmt.Fprintln(os.Stderr, "\nHinweis: Du verwendest einen Legacy-Token (v1). Erstelle in NetBox einen v2-Token (beginnt mit nbt_) für bessere Kompatibilität.")
fmt.Fprintln(os.Stderr, " NetBox → Admin → API Tokens → Add Token")
}
ttl, _ := strconv.Atoi(cacheTTL)
var subnetList []string