Commit d5964d8b authored by Luca Leonardo Scorcia's avatar Luca Leonardo Scorcia

Adds an optional custom icon to the oAuth login label

parent 0e35db54
......@@ -17,7 +17,7 @@ module AuthHelper
end
def provider_has_icon?(name)
PROVIDERS_WITH_ICONS.include?(name.to_s)
PROVIDERS_WITH_ICONS.include?(name.to_s) || icon_for_provider(name.to_s)
end
def qa_class_for_provider(provider)
......@@ -35,6 +35,10 @@ module AuthHelper
Gitlab::Auth::OAuth::Provider.label_for(name)
end
def icon_for_provider(name)
Gitlab::OAuth::Provider.icon_for(name)
end
def form_based_provider_priority
['crowd', /^ldap/, 'kerberos']
end
......@@ -109,7 +113,9 @@ module AuthHelper
def provider_image_tag(provider, size = 64)
label = label_for_provider(provider)
if provider_has_icon?(provider)
if icon_for_provider(provider)
image_tag(icon_for_provider(provider), alt: label, title: "Sign in with #{label}")
elsif provider_has_icon?(provider)
file_name = "#{provider.to_s.split('_').first}_#{size}.png"
image_tag("auth_buttons/#{file_name}", alt: label, title: "Sign in with #{label}")
......
......@@ -34,6 +34,7 @@ The OpenID Connect will provide you with a client details and secret for you to
gitlab_rails['omniauth_providers'] = [
{ 'name' => 'openid_connect',
'label' => '<your_oidc_label>',
'icon' => '<url_to_custom_provider_icon>',
'args' => {
'name' => 'openid_connect',
'scope' => ['openid','profile'],
......@@ -58,6 +59,7 @@ The OpenID Connect will provide you with a client details and secret for you to
```yaml
- { name: 'openid_connect',
label: '<your_oidc_label>',
icon: '<url_to_custom_provider_icon>',
args: {
name: 'openid_connect',
scope: ['openid','profile'],
......@@ -82,6 +84,8 @@ The OpenID Connect will provide you with a client details and secret for you to
1. For the configuration above, change the values for the provider to match your OpenID Connect client setup. Use the following as a guide:
- `<your_oidc_label>` is the label that will be displayed on the login page.
- `<url_to_custom_provider_icon>` (optional) is the icon that will be displayed on the login page. Icons for the major social login platforms are built-in into Gitlab,
but can be overridden by specifying this parameter.
- `<your_oidc_url>` (optional) is the URL that points to the OpenID Connect provider. For example, `https://example.com/auth/realms/your-realm`.
If this value is not provided, the URL is constructed from the `client_options` in the following format: `<client_options.scheme>://<client_options.host>:<client_options.port>`.
- If `discovery` is set to `true`, the OpenID Connect provider will try to auto discover the client options using `<your_oidc_url>/.well-known/openid-configuration`. Defaults to `false`.
......
......@@ -75,6 +75,12 @@ module Gitlab
config = config_for(name)
(config && config['label']) || LABELS[name] || name.titleize
end
def self.icon_for(name)
name = name.to_s
config = config_for(name)
config && config['icon']
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment