[#2533] added VK OAuth2 provider
Co-authored-by: Valentine <xb2w1z@gmail.com>
This commit is contained in:
@@ -61,6 +61,7 @@ type Settings struct {
|
||||
OIDC3Auth AuthProviderConfig `form:"oidc3Auth" json:"oidc3Auth"`
|
||||
AppleAuth AuthProviderConfig `form:"appleAuth" json:"appleAuth"`
|
||||
InstagramAuth AuthProviderConfig `form:"instagramAuth" json:"instagramAuth"`
|
||||
VKAuth AuthProviderConfig `form:"vkAuth" json:"vkAuth"`
|
||||
}
|
||||
|
||||
// New creates and returns a new default Settings instance.
|
||||
@@ -179,6 +180,9 @@ func New() *Settings {
|
||||
InstagramAuth: AuthProviderConfig{
|
||||
Enabled: false,
|
||||
},
|
||||
VKAuth: AuthProviderConfig{
|
||||
Enabled: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,6 +224,7 @@ func (s *Settings) Validate() error {
|
||||
validation.Field(&s.OIDC3Auth),
|
||||
validation.Field(&s.AppleAuth),
|
||||
validation.Field(&s.InstagramAuth),
|
||||
validation.Field(&s.VKAuth),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -284,6 +289,7 @@ func (s *Settings) RedactClone() (*Settings, error) {
|
||||
&clone.OIDC3Auth.ClientSecret,
|
||||
&clone.AppleAuth.ClientSecret,
|
||||
&clone.InstagramAuth.ClientSecret,
|
||||
&clone.VKAuth.ClientSecret,
|
||||
}
|
||||
|
||||
// mask all sensitive fields
|
||||
@@ -322,6 +328,7 @@ func (s *Settings) NamedAuthProviderConfigs() map[string]AuthProviderConfig {
|
||||
auth.NameOIDC + "3": s.OIDC3Auth,
|
||||
auth.NameApple: s.AppleAuth,
|
||||
auth.NameInstagram: s.InstagramAuth,
|
||||
auth.NameVK: s.VKAuth,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,8 @@ func TestSettingsValidate(t *testing.T) {
|
||||
s.AppleAuth.ClientId = ""
|
||||
s.InstagramAuth.Enabled = true
|
||||
s.InstagramAuth.ClientId = ""
|
||||
s.VKAuth.Enabled = true
|
||||
s.VKAuth.ClientId = ""
|
||||
|
||||
// check if Validate() is triggering the members validate methods.
|
||||
err := s.Validate()
|
||||
@@ -108,6 +110,7 @@ func TestSettingsValidate(t *testing.T) {
|
||||
`"oidc3Auth":{`,
|
||||
`"appleAuth":{`,
|
||||
`"instagramAuth":{`,
|
||||
`"vkAuth":{`,
|
||||
}
|
||||
|
||||
errBytes, _ := json.Marshal(err)
|
||||
@@ -177,6 +180,8 @@ func TestSettingsMerge(t *testing.T) {
|
||||
s2.AppleAuth.ClientId = "apple_test"
|
||||
s2.InstagramAuth.Enabled = true
|
||||
s2.InstagramAuth.ClientId = "instagram_test"
|
||||
s2.VKAuth.Enabled = true
|
||||
s2.VKAuth.ClientId = "vk_test"
|
||||
|
||||
if err := s1.Merge(s2); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -265,6 +270,7 @@ func TestSettingsRedactClone(t *testing.T) {
|
||||
s1.OIDC3Auth.ClientSecret = testSecret
|
||||
s1.AppleAuth.ClientSecret = testSecret
|
||||
s1.InstagramAuth.ClientSecret = testSecret
|
||||
s1.VKAuth.ClientSecret = testSecret
|
||||
|
||||
s1Bytes, err := json.Marshal(s1)
|
||||
if err != nil {
|
||||
@@ -321,6 +327,7 @@ func TestNamedAuthProviderConfigs(t *testing.T) {
|
||||
s.OIDC3Auth.ClientId = "oidc3_test"
|
||||
s.AppleAuth.ClientId = "apple_test"
|
||||
s.InstagramAuth.ClientId = "instagram_test"
|
||||
s.VKAuth.ClientId = "vk_test"
|
||||
|
||||
result := s.NamedAuthProviderConfigs()
|
||||
|
||||
@@ -350,6 +357,7 @@ func TestNamedAuthProviderConfigs(t *testing.T) {
|
||||
`"oidc3":{"enabled":false,"clientId":"oidc3_test"`,
|
||||
`"apple":{"enabled":false,"clientId":"apple_test"`,
|
||||
`"instagram":{"enabled":false,"clientId":"instagram_test"`,
|
||||
`"vk":{"enabled":false,"clientId":"vk_test"`,
|
||||
}
|
||||
for _, p := range expectedParts {
|
||||
if !strings.Contains(encodedStr, p) {
|
||||
|
||||
Reference in New Issue
Block a user