2019-09-28 20:04:51 -04:00
|
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Domain string
|
|
|
|
ClientID string
|
|
|
|
ClientSecret string
|
|
|
|
CallbackURL string
|
2019-09-30 14:46:13 -04:00
|
|
|
RedirectURL string
|
2019-09-28 20:04:51 -04:00
|
|
|
}
|
|
|
|
|
2019-09-30 14:46:13 -04:00
|
|
|
func FromEnv() Config {
|
2019-09-28 20:04:51 -04:00
|
|
|
return Config{
|
|
|
|
Domain: os.Getenv("AUTH_DOMAIN"),
|
|
|
|
ClientID: os.Getenv("AUTH_CLIENT_ID"),
|
|
|
|
ClientSecret: os.Getenv("AUTH_CLIENT_SECRET"),
|
|
|
|
CallbackURL: os.Getenv("AUTH_CALLBACK_URL"),
|
2019-09-30 14:46:13 -04:00
|
|
|
RedirectURL: "/user",
|
2019-09-28 20:04:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PrintConfig() {
|
2019-09-30 14:46:13 -04:00
|
|
|
fmt.Printf("%#v\n", FromEnv())
|
2019-09-28 20:04:51 -04:00
|
|
|
}
|
2019-09-29 15:30:24 -04:00
|
|
|
|
|
|
|
type CallbackFunc func(c Config, u User) error
|