Config UI: fix editing existing OAuth devices (#28012)
This commit is contained in:
parent
20de0b9da1
commit
b28be96d0a
8 changed files with 98 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue