diff options
author | Willem van Dreumel <willemvd@users.noreply.github.com> | 2017-05-01 15:26:53 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-05-01 21:26:53 +0800 |
commit | 950f2e207413551b868252a1bced6ce9263d16d4 (patch) | |
tree | b01a330af11c7f8b9e2d1461685d9afb2ae9e485 /public | |
parent | 2368bbb6727ea5497743c0fdade723b49693cb4c (diff) | |
download | gitea-950f2e207413551b868252a1bced6ce9263d16d4.tar.gz gitea-950f2e207413551b868252a1bced6ce9263d16d4.zip |
Additional OAuth2 providers (#1010)
* add google+
* sort signin oauth2 providers based on the name so order is always the same
* update auth tip for google+
* add gitlab provider
* add bitbucket provider (and some go fmt)
* add twitter provider
* add facebook provider
* add dropbox provider
* add openid connect provider incl. new format of tips section in "Add New Source"
* lower the amount of disk storage for each session to prevent issues while building cross platform (and disk overflow)
* imports according to goimport and code style
* make it possible to set custom urls to gitlab and github provider (only these could have a different host)
* split up oauth2 into multiple files
* small typo in comment
* fix indention
* fix indentation
* fix new line before external import
* fix layout of signin part
* update "broken" dependency
Diffstat (limited to 'public')
-rw-r--r-- | public/css/index.css | 5 | ||||
-rw-r--r-- | public/img/auth/bitbucket.png | bin | 0 -> 2161 bytes | |||
-rw-r--r-- | public/img/auth/dropbox.png | bin | 0 -> 1427 bytes | |||
-rw-r--r-- | public/img/auth/facebook.png | bin | 0 -> 2327 bytes | |||
-rw-r--r-- | public/img/auth/github.png (renamed from public/img/github.png) | bin | 1151 -> 1151 bytes | |||
-rw-r--r-- | public/img/auth/gitlab.png | bin | 0 -> 3616 bytes | |||
-rw-r--r-- | public/img/auth/google_plus.png | bin | 0 -> 4366 bytes | |||
-rw-r--r-- | public/img/auth/openid_connect.png | bin | 0 -> 12921 bytes | |||
-rw-r--r-- | public/img/auth/twitter.png | bin | 0 -> 3110 bytes | |||
-rw-r--r-- | public/js/index.js | 62 | ||||
-rw-r--r-- | public/less/_form.less | 5 |
11 files changed, 67 insertions, 5 deletions
diff --git a/public/css/index.css b/public/css/index.css index b0fc396cca..3fa2d6d0fd 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -965,7 +965,7 @@ footer .ui.language .menu { float: left; } .signin .oauth2 a { - margin-right: 5px; + margin-right: 3px; } .signin .oauth2 a:last-child { margin-right: 0px; @@ -974,6 +974,9 @@ footer .ui.language .menu { width: 32px; height: 32px; } +.signin .oauth2 img.openidConnect { + width: auto; +} .user.activate form, .user.forgot.password form, .user.reset.password form, diff --git a/public/img/auth/bitbucket.png b/public/img/auth/bitbucket.png Binary files differnew file mode 100644 index 0000000000..b3d022a5a7 --- /dev/null +++ b/public/img/auth/bitbucket.png diff --git a/public/img/auth/dropbox.png b/public/img/auth/dropbox.png Binary files differnew file mode 100644 index 0000000000..da2348872a --- /dev/null +++ b/public/img/auth/dropbox.png diff --git a/public/img/auth/facebook.png b/public/img/auth/facebook.png Binary files differnew file mode 100644 index 0000000000..29273af14f --- /dev/null +++ b/public/img/auth/facebook.png diff --git a/public/img/github.png b/public/img/auth/github.png Binary files differindex 1fa19c55d2..1fa19c55d2 100644 --- a/public/img/github.png +++ b/public/img/auth/github.png diff --git a/public/img/auth/gitlab.png b/public/img/auth/gitlab.png Binary files differnew file mode 100644 index 0000000000..ca30b45901 --- /dev/null +++ b/public/img/auth/gitlab.png diff --git a/public/img/auth/google_plus.png b/public/img/auth/google_plus.png Binary files differnew file mode 100644 index 0000000000..720824230a --- /dev/null +++ b/public/img/auth/google_plus.png diff --git a/public/img/auth/openid_connect.png b/public/img/auth/openid_connect.png Binary files differnew file mode 100644 index 0000000000..af033cd1fe --- /dev/null +++ b/public/img/auth/openid_connect.png diff --git a/public/img/auth/twitter.png b/public/img/auth/twitter.png Binary files differnew file mode 100644 index 0000000000..a4f14de57a --- /dev/null +++ b/public/img/auth/twitter.png diff --git a/public/js/index.js b/public/js/index.js index 9b48c24cd3..31b15a76a7 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1047,6 +1047,56 @@ function initAdmin() { } } + function onOAuth2Change() { + $('.open_id_connect_auto_discovery_url, .oauth2_use_custom_url').hide(); + $('.open_id_connect_auto_discovery_url input[required]').removeAttr('required'); + + var provider = $('#oauth2_provider').val(); + switch (provider) { + case 'github': + case 'gitlab': + $('.oauth2_use_custom_url').show(); + break; + case 'openidConnect': + $('.open_id_connect_auto_discovery_url input').attr('required', 'required'); + $('.open_id_connect_auto_discovery_url').show(); + break; + } + onOAuth2UseCustomURLChange(); + } + + function onOAuth2UseCustomURLChange() { + var provider = $('#oauth2_provider').val(); + $('.oauth2_use_custom_url_field').hide(); + $('.oauth2_use_custom_url_field input[required]').removeAttr('required'); + + if ($('#oauth2_use_custom_url').is(':checked')) { + if (!$('#oauth2_token_url').val()) { + $('#oauth2_token_url').val($('#' + provider + '_token_url').val()); + } + if (!$('#oauth2_auth_url').val()) { + $('#oauth2_auth_url').val($('#' + provider + '_auth_url').val()); + } + if (!$('#oauth2_profile_url').val()) { + $('#oauth2_profile_url').val($('#' + provider + '_profile_url').val()); + } + if (!$('#oauth2_email_url').val()) { + $('#oauth2_email_url').val($('#' + provider + '_email_url').val()); + } + switch (provider) { + case 'github': + $('.oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input, .oauth2_email_url input').attr('required', 'required'); + $('.oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url, .oauth2_email_url').show(); + break; + case 'gitlab': + $('.oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input').attr('required', 'required'); + $('.oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url').show(); + $('#oauth2_email_url').val(''); + break; + } + } + } + // New authentication if ($('.admin.new.authentication').length > 0) { $('#auth_type').change(function () { @@ -1075,22 +1125,28 @@ function initAdmin() { break; case '6': // OAuth2 $('.oauth2').show(); - $('.oauth2 input').attr('required', 'required'); + $('.oauth2 div.required:not(.oauth2_use_custom_url,.oauth2_use_custom_url_field,.open_id_connect_auto_discovery_url) input').attr('required', 'required'); + onOAuth2Change(); break; } - if (authType == '2' || authType == '5') { onSecurityProtocolChange() } }); $('#auth_type').change(); - $('#security_protocol').change(onSecurityProtocolChange) + $('#security_protocol').change(onSecurityProtocolChange); + $('#oauth2_provider').change(onOAuth2Change); + $('#oauth2_use_custom_url').change(onOAuth2UseCustomURLChange); } // Edit authentication if ($('.admin.edit.authentication').length > 0) { var authType = $('#auth_type').val(); if (authType == '2' || authType == '5') { $('#security_protocol').change(onSecurityProtocolChange); + } else if (authType == '6') { + $('#oauth2_provider').change(onOAuth2Change); + $('#oauth2_use_custom_url').change(onOAuth2UseCustomURLChange); + onOAuth2Change(); } } diff --git a/public/less/_form.less b/public/less/_form.less index fc0fdddad1..4542c092db 100644 --- a/public/less/_form.less +++ b/public/less/_form.less @@ -56,7 +56,7 @@ } } a { - margin-right: 5px; + margin-right: 3px; &:last-child { margin-right: 0px; } @@ -64,6 +64,9 @@ img { width: 32px; height: 32px; + &.openidConnect { + width: auto; + } } } } |