Config UI: fix editing existing OAuth devices (#28012)

This commit is contained in:
lehmanju 2026-04-12 14:04:40 +02:00 • committed by GitHub
parent 20de0b9da1
commit b28be96d0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 98 additions and 9 deletions

View file

@ -2,6 +2,7 @@ package auth
import (
"context"
"errors"
"fmt"
"net/url"
"strings"
@ -32,16 +33,21 @@ func NewDemoFromConfig(_ context.Context, other map[string]any) (oauth2.TokenSou
Server string
Method string
RedirectUri string
Secret string
}
if err := util.DecodeOther(other, &cc); err != nil {
return nil, err
}
return NewDemo(cc.Server, cc.Method, cc.RedirectUri)
return NewDemo(cc.Server, cc.Method, cc.RedirectUri, cc.Secret)
}
func NewDemo(server string, method string, redirectUri string) (oauth2.TokenSource, error) {
func NewDemo(server, method, redirectUri, secret string) (oauth2.TokenSource, error) {
if secret != "topsecret" {
return nil, errors.New("invalid secret")
}
// reuse instance (similar to oauth.go getInstance pattern)
if demoInstance != nil {
// update existing instance with new values