[#2762] added Yandex OAuth2 provider
Co-authored-by: Valentine <xb2w1z@gmail.com>
This commit is contained in:
@@ -62,6 +62,7 @@ type Settings struct {
|
||||
AppleAuth AuthProviderConfig `form:"appleAuth" json:"appleAuth"`
|
||||
InstagramAuth AuthProviderConfig `form:"instagramAuth" json:"instagramAuth"`
|
||||
VKAuth AuthProviderConfig `form:"vkAuth" json:"vkAuth"`
|
||||
YandexAuth AuthProviderConfig `form:"yandexAuth" json:"yandexAuth"`
|
||||
}
|
||||
|
||||
// New creates and returns a new default Settings instance.
|
||||
@@ -183,6 +184,9 @@ func New() *Settings {
|
||||
VKAuth: AuthProviderConfig{
|
||||
Enabled: false,
|
||||
},
|
||||
YandexAuth: AuthProviderConfig{
|
||||
Enabled: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,6 +229,7 @@ func (s *Settings) Validate() error {
|
||||
validation.Field(&s.AppleAuth),
|
||||
validation.Field(&s.InstagramAuth),
|
||||
validation.Field(&s.VKAuth),
|
||||
validation.Field(&s.YandexAuth),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -290,6 +295,7 @@ func (s *Settings) RedactClone() (*Settings, error) {
|
||||
&clone.AppleAuth.ClientSecret,
|
||||
&clone.InstagramAuth.ClientSecret,
|
||||
&clone.VKAuth.ClientSecret,
|
||||
&clone.YandexAuth.ClientSecret,
|
||||
}
|
||||
|
||||
// mask all sensitive fields
|
||||
@@ -329,6 +335,7 @@ func (s *Settings) NamedAuthProviderConfigs() map[string]AuthProviderConfig {
|
||||
auth.NameApple: s.AppleAuth,
|
||||
auth.NameInstagram: s.InstagramAuth,
|
||||
auth.NameVK: s.VKAuth,
|
||||
auth.NameYandex: s.YandexAuth,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ func TestSettingsValidate(t *testing.T) {
|
||||
s.InstagramAuth.ClientId = ""
|
||||
s.VKAuth.Enabled = true
|
||||
s.VKAuth.ClientId = ""
|
||||
s.YandexAuth.Enabled = true
|
||||
s.YandexAuth.ClientId = ""
|
||||
|
||||
// check if Validate() is triggering the members validate methods.
|
||||
err := s.Validate()
|
||||
@@ -111,6 +113,7 @@ func TestSettingsValidate(t *testing.T) {
|
||||
`"appleAuth":{`,
|
||||
`"instagramAuth":{`,
|
||||
`"vkAuth":{`,
|
||||
`"yandexAuth":{`,
|
||||
}
|
||||
|
||||
errBytes, _ := json.Marshal(err)
|
||||
@@ -182,6 +185,8 @@ func TestSettingsMerge(t *testing.T) {
|
||||
s2.InstagramAuth.ClientId = "instagram_test"
|
||||
s2.VKAuth.Enabled = true
|
||||
s2.VKAuth.ClientId = "vk_test"
|
||||
s2.YandexAuth.Enabled = true
|
||||
s2.YandexAuth.ClientId = "yandex_test"
|
||||
|
||||
if err := s1.Merge(s2); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -271,6 +276,7 @@ func TestSettingsRedactClone(t *testing.T) {
|
||||
s1.AppleAuth.ClientSecret = testSecret
|
||||
s1.InstagramAuth.ClientSecret = testSecret
|
||||
s1.VKAuth.ClientSecret = testSecret
|
||||
s1.YandexAuth.ClientSecret = testSecret
|
||||
|
||||
s1Bytes, err := json.Marshal(s1)
|
||||
if err != nil {
|
||||
@@ -328,6 +334,7 @@ func TestNamedAuthProviderConfigs(t *testing.T) {
|
||||
s.AppleAuth.ClientId = "apple_test"
|
||||
s.InstagramAuth.ClientId = "instagram_test"
|
||||
s.VKAuth.ClientId = "vk_test"
|
||||
s.YandexAuth.ClientId = "yandex_test"
|
||||
|
||||
result := s.NamedAuthProviderConfigs()
|
||||
|
||||
@@ -358,6 +365,7 @@ func TestNamedAuthProviderConfigs(t *testing.T) {
|
||||
`"apple":{"enabled":false,"clientId":"apple_test"`,
|
||||
`"instagram":{"enabled":false,"clientId":"instagram_test"`,
|
||||
`"vk":{"enabled":false,"clientId":"vk_test"`,
|
||||
`"yandex":{"enabled":false,"clientId":"yandex_test"`,
|
||||
}
|
||||
for _, p := range expectedParts {
|
||||
if !strings.Contains(encodedStr, p) {
|
||||
|
||||
Reference in New Issue
Block a user