diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2026-01-21 19:05:36 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2026-01-21 19:05:36 -0800 |
| commit | 4368b7cd6ab81e6f98e167dfd86d0574d0eade7b (patch) | |
| tree | ea64ff84c3ba9aa6c6095be7265803ae1e3f88c9 /tools/auth/auth.go | |
| parent | 96253cbcb61569aafb59d592150dfb47e7cb43ff (diff) | |
| download | roseh.moe-4368b7cd6ab81e6f98e167dfd86d0574d0eade7b.tar.zst | |
XML!!!
Diffstat (limited to 'tools/auth/auth.go')
| -rw-r--r-- | tools/auth/auth.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/auth/auth.go b/tools/auth/auth.go index 3c4f063..9b80389 100644 --- a/tools/auth/auth.go +++ b/tools/auth/auth.go @@ -2,13 +2,13 @@ package main import ( "encoding/base32" + "encoding/base64" + "encoding/xml" "flag" "fmt" "os" "github.com/skip2/go-qrcode" - "roseh.moe/pkg/ccl" - "roseh.moe/pkg/roseh.moe/internal/config" ) func run() error { @@ -20,14 +20,20 @@ func run() error { if err != nil { return err } - var config config.SecretsConfig - if err := ccl.Unmarshal(fileBytes, &config); err != nil { + var config struct { + AuthKey string `xml:",attr"` + } + if err := xml.Unmarshal(fileBytes, &config); err != nil { return err } - if len(config.AuthKey) == 0 { + if config.AuthKey == "" { return fmt.Errorf("%s: missing AuthKey", args[0]) } - qrCode, err := qrcode.New(fmt.Sprintf("otpauth://totp/roseh.moe:rose?secret=%s&issuer=roseh.moe", base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(config.AuthKey)), qrcode.Medium) + authKey, err := base64.StdEncoding.DecodeString(config.AuthKey) + if err != nil { + return err + } + qrCode, err := qrcode.New(fmt.Sprintf("otpauth://totp/roseh.moe:rose?secret=%s&issuer=roseh.moe", base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(authKey)), qrcode.Medium) if err != nil { return err } |
