Add Identity Provider to support Authentication via Authentik,OpenID ,etc..
This commit is contained in:
parent
0647725c68
commit
430f46ffee
10 changed files with 269 additions and 30 deletions
|
@ -18,6 +18,7 @@ type Config struct {
|
|||
SchedulerJobs SchedulerConfig `mapstructure:"scheduler_jobs" yaml:"scheduler_jobs"`
|
||||
EmailConfig EmailConfig `mapstructure:"email" yaml:"email"`
|
||||
StripeConfig StripeConfig `mapstructure:"stripe" yaml:"stripe"`
|
||||
OAuth2Config OAuth2Config `mapstructure:"oauth2" yaml:"oauth2"`
|
||||
IsDoneTickDotCom bool `mapstructure:"is_done_tick_dot_com" yaml:"is_done_tick_dot_com"`
|
||||
IsUserCreationDisabled bool `mapstructure:"is_user_creation_disabled" yaml:"is_user_creation_disabled"`
|
||||
}
|
||||
|
@ -84,6 +85,16 @@ type EmailConfig struct {
|
|||
AppHost string `mapstructure:"appHost"`
|
||||
}
|
||||
|
||||
type OAuth2Config struct {
|
||||
ClientID string `mapstructure:"client_id" yaml:"client_id"`
|
||||
ClientSecret string `mapstructure:"client_secret" yaml:"client_secret"`
|
||||
RedirectURL string `mapstructure:"redirect_url" yaml:"redirect_url"`
|
||||
Scopes []string
|
||||
AuthURL string `mapstructure:"auth_url" yaml:"auth_url"`
|
||||
TokenURL string `mapstructure:"token_url" yaml:"token_url"`
|
||||
UserInfoURL string `mapstructure:"user_info_url" yaml:"user_info_url"`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
return &Config{
|
||||
Telegram: TelegramConfig{
|
||||
|
@ -126,9 +137,12 @@ func LoadConfig() *Config {
|
|||
}
|
||||
// get logger and log the current environment:
|
||||
fmt.Printf("--ConfigLoad config for environment: %s ", os.Getenv("DT_ENV"))
|
||||
viper.SetEnvPrefix("DT")
|
||||
viper.AutomaticEnv()
|
||||
|
||||
viper.AddConfigPath("./config")
|
||||
viper.SetConfigType("yaml")
|
||||
|
||||
err := viper.ReadInConfig()
|
||||
// print a useful error:
|
||||
if err != nil {
|
||||
|
@ -141,9 +155,11 @@ func LoadConfig() *Config {
|
|||
panic(err)
|
||||
}
|
||||
fmt.Printf("--ConfigLoad name : %s ", config.Name)
|
||||
viper.SetEnvPrefix("DT")
|
||||
viper.AutomaticEnv()
|
||||
|
||||
// bind all the environment variables to the config:
|
||||
|
||||
configEnvironmentOverrides(&config)
|
||||
panic(config.OAuth2Config.ClientID)
|
||||
return &config
|
||||
|
||||
// return LocalConfig()
|
||||
|
|
|
@ -22,4 +22,10 @@ DT_EMAIL_HOST=
|
|||
DT_EMAIL_PORT=
|
||||
DT_EMAIL_KEY=
|
||||
DT_EMAIL_EMAIL=
|
||||
DT_EMAIL_APP_HOST=
|
||||
DT_EMAIL_APP_HOST=
|
||||
DT_OAUTH2_CLIENT_ID=
|
||||
DT_OAUTH2_CLIENT_SECRET=
|
||||
DT_OAUTH2_AUTH_URL=
|
||||
DT_OAUTH2_TOKEN_URL=
|
||||
DT_OAUTH2_USER_INFO_URL=
|
||||
DT_OAUTH2_REDIRECT_URL=
|
|
@ -35,3 +35,10 @@ email:
|
|||
key:
|
||||
email:
|
||||
appHost:
|
||||
oauth2:
|
||||
client_id:
|
||||
client_secret:
|
||||
auth_url:
|
||||
token_url:
|
||||
user_info_url:
|
||||
redirect_url:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue