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-29 15:30:24 -04:00
|
|
|
CallbackFunc CallbackFunc
|
2019-09-28 20:04:51 -04:00
|
|
|
}
|
|
|
|
|
2019-09-29 15:30:24 -04:00
|
|
|
func FromEnv(c CallbackFunc) 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-29 15:30:24 -04:00
|
|
|
CallbackFunc: c,
|
2019-09-28 20:04:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PrintConfig() {
|
2019-09-29 15:30:24 -04:00
|
|
|
fmt.Printf("%#v\n", FromEnv(nil))
|
2019-09-28 20:04:51 -04:00
|
|
|
}
|
2019-09-29 15:30:24 -04:00
|
|
|
|
|
|
|
type CallbackFunc func(c Config, u User) error
|