Add auth config struct and restructure social auth provider config to enable iteration and adding other providers

This commit is contained in:
Ken-Håvard Lieng 2020-05-01 04:35:26 +02:00
parent 3d7011e504
commit b81e1e482a
2 changed files with 18 additions and 5 deletions

View File

@ -46,19 +46,19 @@ login = true
# Enable username/password registration
registration = true
[auth.github]
[auth.providers.github]
key = ""
secret = ""
[auth.facebook]
[auth.providers.facebook]
key = ""
secret = ""
[auth.google]
[auth.providers.google]
key = ""
secret = ""
[auth.twitter]
[auth.providers.twitter]
key = ""
secret = ""

View File

@ -3,8 +3,8 @@ package config
import (
"time"
"github.com/khlieng/dispatch/storage"
"github.com/fsnotify/fsnotify"
"github.com/khlieng/dispatch/storage"
"github.com/spf13/viper"
)
@ -18,6 +18,7 @@ type Config struct {
Defaults Defaults
HTTPS HTTPS
LetsEncrypt LetsEncrypt
Auth Auth
}
type Defaults struct {
@ -51,6 +52,18 @@ type LetsEncrypt struct {
Email string
}
type Auth struct {
Anonymous bool
Login bool
Registration bool
Providers map[string]Provider
}
type Provider struct {
Key string
Secret string
}
func LoadConfig() (*Config, chan *Config) {
viper.SetConfigName("config")
viper.AddConfigPath(storage.Path.ConfigRoot())