1
0
Fork 0

Custom icons for OAuth sources (#14161)

* Add Icon URL to Backend

* Template for Icon URL

* Localization & Edit Icon URL

* Improve Custom Icon URL

* Removed not working else

Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
Timo Ley 2020-12-28 03:35:55 +01:00 committed by GitHub
parent f6ca44c706
commit 2b2a4a53bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 1 deletions

View file

@ -131,6 +131,7 @@ type OAuth2Config struct {
ClientSecret string ClientSecret string
OpenIDConnectAutoDiscoveryURL string OpenIDConnectAutoDiscoveryURL string
CustomURLMapping *oauth2.CustomURLMapping CustomURLMapping *oauth2.CustomURLMapping
IconURL string
} }
// FromDB fills up an OAuth2Config from serialized format. // FromDB fills up an OAuth2Config from serialized format.

View file

@ -111,7 +111,11 @@ func GetActiveOAuth2Providers() ([]string, map[string]OAuth2Provider, error) {
var orderedKeys []string var orderedKeys []string
providers := make(map[string]OAuth2Provider) providers := make(map[string]OAuth2Provider)
for _, source := range loginSources { 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) orderedKeys = append(orderedKeys, source.Name)
} }

View file

@ -56,6 +56,7 @@ type AuthenticationForm struct {
Oauth2AuthURL string Oauth2AuthURL string
Oauth2ProfileURL string Oauth2ProfileURL string
Oauth2EmailURL string Oauth2EmailURL string
Oauth2IconURL string
SSPIAutoCreateUsers bool SSPIAutoCreateUsers bool
SSPIAutoActivateUsers bool SSPIAutoActivateUsers bool
SSPIStripDomainNames bool SSPIStripDomainNames bool

View file

@ -2203,6 +2203,7 @@ auths.enable_tls = Enable TLS Encryption
auths.skip_tls_verify = Skip TLS Verify auths.skip_tls_verify = Skip TLS Verify
auths.pam_service_name = PAM Service Name auths.pam_service_name = PAM Service Name
auths.oauth2_provider = OAuth2 Provider auths.oauth2_provider = OAuth2 Provider
auths.oauth2_icon_url = Icon URL
auths.oauth2_clientID = Client ID (Key) auths.oauth2_clientID = Client ID (Key)
auths.oauth2_clientSecret = Client Secret auths.oauth2_clientSecret = Client Secret
auths.openIdConnectAutoDiscoveryURL = OpenID Connect Auto Discovery URL auths.openIdConnectAutoDiscoveryURL = OpenID Connect Auto Discovery URL

View file

@ -177,6 +177,7 @@ func parseOAuth2Config(form auth.AuthenticationForm) *models.OAuth2Config {
ClientSecret: form.Oauth2Secret, ClientSecret: form.Oauth2Secret,
OpenIDConnectAutoDiscoveryURL: form.OpenIDConnectAutoDiscoveryURL, OpenIDConnectAutoDiscoveryURL: form.OpenIDConnectAutoDiscoveryURL,
CustomURLMapping: customURLMapping, CustomURLMapping: customURLMapping,
IconURL: form.Oauth2IconURL,
} }
} }

View file

@ -214,6 +214,10 @@
<label for="oauth2_secret">{{.i18n.Tr "admin.auths.oauth2_clientSecret"}}</label> <label for="oauth2_secret">{{.i18n.Tr "admin.auths.oauth2_clientSecret"}}</label>
<input id="oauth2_secret" name="oauth2_secret" value="{{$cfg.ClientSecret}}" required> <input id="oauth2_secret" name="oauth2_secret" value="{{$cfg.ClientSecret}}" required>
</div> </div>
<div class="optional field">
<label for="oauth2_icon_url">{{.i18n.Tr "admin.auths.oauth2_icon_url"}}</label>
<input id="oauth2_icon_url" name="oauth2_icon_url" value="{{$cfg.IconURL}}">
</div>
<div class="open_id_connect_auto_discovery_url required field"> <div class="open_id_connect_auto_discovery_url required field">
<label for="open_id_connect_auto_discovery_url">{{.i18n.Tr "admin.auths.openIdConnectAutoDiscoveryURL"}}</label> <label for="open_id_connect_auto_discovery_url">{{.i18n.Tr "admin.auths.openIdConnectAutoDiscoveryURL"}}</label>
<input id="open_id_connect_auto_discovery_url" name="open_id_connect_auto_discovery_url" value="{{$cfg.OpenIDConnectAutoDiscoveryURL}}"> <input id="open_id_connect_auto_discovery_url" name="open_id_connect_auto_discovery_url" value="{{$cfg.OpenIDConnectAutoDiscoveryURL}}">

View file

@ -20,6 +20,10 @@
<label for="oauth2_secret">{{.i18n.Tr "admin.auths.oauth2_clientSecret"}}</label> <label for="oauth2_secret">{{.i18n.Tr "admin.auths.oauth2_clientSecret"}}</label>
<input id="oauth2_secret" name="oauth2_secret" value="{{.oauth2_secret}}"> <input id="oauth2_secret" name="oauth2_secret" value="{{.oauth2_secret}}">
</div> </div>
<div class="optional field">
<label for="oauth2_icon_url">{{.i18n.Tr "admin.auths.oauth2_icon_url"}}</label>
<input id="oauth2_icon_url" name="oauth2_icon_url" value="{{.oauth2_icon_url}}">
</div>
<div class="open_id_connect_auto_discovery_url required field"> <div class="open_id_connect_auto_discovery_url required field">
<label for="open_id_connect_auto_discovery_url">{{.i18n.Tr "admin.auths.openIdConnectAutoDiscoveryURL"}}</label> <label for="open_id_connect_auto_discovery_url">{{.i18n.Tr "admin.auths.openIdConnectAutoDiscoveryURL"}}</label>
<input id="open_id_connect_auto_discovery_url" name="open_id_connect_auto_discovery_url" value="{{.open_id_connect_auto_discovery_url}}"> <input id="open_id_connect_auto_discovery_url" name="open_id_connect_auto_discovery_url" value="{{.open_id_connect_auto_discovery_url}}">