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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user