summaryrefslogtreecommitdiffstats
path: root/public/js
diff options
context:
space:
mode:
authorWillem van Dreumel <willemvd@users.noreply.github.com>2017-05-01 15:26:53 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-05-01 21:26:53 +0800
commit950f2e207413551b868252a1bced6ce9263d16d4 (patch)
treeb01a330af11c7f8b9e2d1461685d9afb2ae9e485 /public/js
parent2368bbb6727ea5497743c0fdade723b49693cb4c (diff)
downloadgitea-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/js')
-rw-r--r--public/js/index.js62
1 files changed, 59 insertions, 3 deletions
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();
}
}