1d871b000a
Not built by default, but can be added with `go build -tags nullauth`. Enabled by running tokidoki with `-auth.url null://`. Very useful for simpler debugging when you don't want manage test accounts with actual passwords.
27 lines
494 B
Go
27 lines
494 B
Go
package auth
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
)
|
|
|
|
func NewFromURL(authURL string) (AuthProvider, error) {
|
|
u, err := url.Parse(authURL)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error parsing auth URL: %s", err.Error())
|
|
}
|
|
|
|
switch u.Scheme {
|
|
case "imap":
|
|
return NewIMAP(u.Host, false), nil
|
|
case "imaps":
|
|
return NewIMAP(u.Host, true), nil
|
|
case "pam":
|
|
return NewPAM()
|
|
case "null":
|
|
return NewNull()
|
|
default:
|
|
return nil, fmt.Errorf("no auth provider found for %s:// URL", u.Scheme)
|
|
}
|
|
}
|