From b81e1e482a218885ca6441ec0e026dac9910ee45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Fri, 1 May 2020 04:35:26 +0200 Subject: [PATCH] Add auth config struct and restructure social auth provider config to enable iteration and adding other providers --- config.default.toml | 8 ++++---- config/config.go | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/config.default.toml b/config.default.toml index 6eaf3409..be9501e8 100644 --- a/config.default.toml +++ b/config.default.toml @@ -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 = "" diff --git a/config/config.go b/config/config.go index 13448dd1..5e869c44 100644 --- a/config/config.go +++ b/config/config.go @@ -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())