Add OAuth 2.0 backend

This commit is contained in:
Simon Ser 2024-02-19 17:19:32 +00:00 committed by Conrad Hoffmann
parent cca1d579db
commit ebb5aede92
5 changed files with 105 additions and 0 deletions

View file

@ -26,6 +26,14 @@ func NewFromURL(authURL string) (AuthProvider, error) {
return NewHtpasswd(path)
case "null":
return NewNull()
case "http", "https":
if u.User == nil {
return nil, fmt.Errorf("missing client ID for OAuth 2.0")
}
clientID := u.User.Username()
clientSecret, _ := u.User.Password()
u.User = nil
return NewOAuth2(u.String(), clientID, clientSecret)
default:
return nil, fmt.Errorf("no auth provider found for %s:// URL", u.Scheme)
}