diff --git a/models/login_source.go b/models/login_source.go index 4f577d6ca..f1941c3e7 100644 --- a/models/login_source.go +++ b/models/login_source.go @@ -131,6 +131,7 @@ type OAuth2Config struct { ClientSecret string OpenIDConnectAutoDiscoveryURL string CustomURLMapping *oauth2.CustomURLMapping + IconURL string } // FromDB fills up an OAuth2Config from serialized format. diff --git a/models/oauth2.go b/models/oauth2.go index 27668d5ee..241e11a44 100644 --- a/models/oauth2.go +++ b/models/oauth2.go @@ -111,7 +111,11 @@ func GetActiveOAuth2Providers() ([]string, map[string]OAuth2Provider, error) { var orderedKeys []string providers := make(map[string]OAuth2Provider) for _, source := range loginSources { - providers[source.Name] = OAuth2Providers[source.OAuth2().Provider] + prov := OAuth2Providers[source.OAuth2().Provider] + if source.OAuth2().IconURL != "" { + prov.Image = source.OAuth2().IconURL + } + providers[source.Name] = prov orderedKeys = append(orderedKeys, source.Name) } diff --git a/modules/auth/auth_form.go b/modules/auth/auth_form.go index 1d02c7acf..e348b01e9 100644 --- a/modules/auth/auth_form.go +++ b/modules/auth/auth_form.go @@ -56,6 +56,7 @@ type AuthenticationForm struct { Oauth2AuthURL string Oauth2ProfileURL string Oauth2EmailURL string + Oauth2IconURL string SSPIAutoCreateUsers bool SSPIAutoActivateUsers bool SSPIStripDomainNames bool diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 3aff43c0a..ae72dff3a 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2203,6 +2203,7 @@ auths.enable_tls = Enable TLS Encryption auths.skip_tls_verify = Skip TLS Verify auths.pam_service_name = PAM Service Name auths.oauth2_provider = OAuth2 Provider +auths.oauth2_icon_url = Icon URL auths.oauth2_clientID = Client ID (Key) auths.oauth2_clientSecret = Client Secret auths.openIdConnectAutoDiscoveryURL = OpenID Connect Auto Discovery URL diff --git a/routers/admin/auths.go b/routers/admin/auths.go index ce9dd3836..7a9d28637 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -177,6 +177,7 @@ func parseOAuth2Config(form auth.AuthenticationForm) *models.OAuth2Config { ClientSecret: form.Oauth2Secret, OpenIDConnectAutoDiscoveryURL: form.OpenIDConnectAutoDiscoveryURL, CustomURLMapping: customURLMapping, + IconURL: form.Oauth2IconURL, } } diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index 3347a91bf..6b2485839 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -214,6 +214,10 @@ +
+ + +
diff --git a/templates/admin/auth/source/oauth.tmpl b/templates/admin/auth/source/oauth.tmpl index 7870dbd65..1489ab839 100644 --- a/templates/admin/auth/source/oauth.tmpl +++ b/templates/admin/auth/source/oauth.tmpl @@ -20,6 +20,10 @@
+
+ + +