[#335] added Discord OAuth2 provider

This commit is contained in:
Gani Georgiev
2022-08-21 19:38:42 +03:00
parent 0b8c7f6883
commit 49b084cf50
18 changed files with 246 additions and 149 deletions

View File

@@ -35,6 +35,7 @@ type Settings struct {
FacebookAuth AuthProviderConfig `form:"facebookAuth" json:"facebookAuth"`
GithubAuth AuthProviderConfig `form:"githubAuth" json:"githubAuth"`
GitlabAuth AuthProviderConfig `form:"gitlabAuth" json:"gitlabAuth"`
DiscordAuth AuthProviderConfig `form:"discordAuth" json:"discordAuth"`
}
// NewSettings creates and returns a new default Settings instance.
@@ -106,6 +107,10 @@ func NewSettings() *Settings {
Enabled: false,
AllowRegistrations: true,
},
DiscordAuth: AuthProviderConfig{
Enabled: false,
AllowRegistrations: true,
},
}
}
@@ -130,6 +135,7 @@ func (s *Settings) Validate() error {
validation.Field(&s.FacebookAuth),
validation.Field(&s.GithubAuth),
validation.Field(&s.GitlabAuth),
validation.Field(&s.DiscordAuth),
)
}
@@ -178,6 +184,7 @@ func (s *Settings) RedactClone() (*Settings, error) {
&clone.FacebookAuth.ClientSecret,
&clone.GithubAuth.ClientSecret,
&clone.GitlabAuth.ClientSecret,
&clone.DiscordAuth.ClientSecret,
}
// mask all sensitive fields
@@ -201,6 +208,7 @@ func (s *Settings) NamedAuthProviderConfigs() map[string]AuthProviderConfig {
auth.NameFacebook: s.FacebookAuth,
auth.NameGithub: s.GithubAuth,
auth.NameGitlab: s.GitlabAuth,
auth.NameDiscord: s.DiscordAuth,
}
}