mirror of
https://github.com/Alvin-Zilverstand/nginx-proxy-manager.git
synced 2026-11-26 16:13:06 +01:00
Oauth2 support
This commit is contained in:
25 files changed
+529
-30
No files matched your search
@@ -2,19 +2,31 @@ package setting
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// GetAuthMethods returns the authentication methods enabled for this site
|
||||
func GetAuthMethods() ([]string, error) {
|
||||
var l []string
|
||||
var m Model
|
||||
if err := m.LoadByName("auth-methods"); err != nil {
|
||||
return l, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(m.Value.String()), &l); err != nil {
|
||||
return l, err
|
||||
var r []string
|
||||
if err := json.Unmarshal([]byte(m.Value.String()), &r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return l, nil
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// AuthMethodEnabled checks that the auth method given is
|
||||
// enabled in the db setting
|
||||
func AuthMethodEnabled(method string) bool {
|
||||
r, err := GetAuthMethods()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return slices.Contains(r, method)
|
||||
}
|
||||
Reference in new issue
Block a user