Merge pull request #435 from JoergAdler/master

The list of scopes now RFC6749 Sec.3.3 compliant
This commit is contained in:
Tony Tam
2014-06-01 16:35:58 -07:00

View File

@@ -48,65 +48,72 @@ function handleLogin() {
str += '</label></li>'; str += '</label></li>';
popup.append(str); popup.append(str);
} }
}
var $win = $(window),
dw = $win.width(),
dh = $win.height(),
st = $win.scrollTop(),
dlgWd = popupDialog.outerWidth(),
dlgHt = popupDialog.outerHeight(),
top = (dh -dlgHt)/2 + st,
left = (dw - dlgWd)/2;
popupDialog.css({ var $win = $(window),
top: (top < 0? 0 : top) + 'px', dw = $win.width(),
left: (left < 0? 0 : left) + 'px' dh = $win.height(),
}); st = $win.scrollTop(),
dlgWd = popupDialog.outerWidth(),
dlgHt = popupDialog.outerHeight(),
top = (dh -dlgHt)/2 + st,
left = (dw - dlgWd)/2;
popupDialog.find('button.api-popup-cancel').click(function() { popupDialog.css({
popupMask.hide(); top: (top < 0? 0 : top) + 'px',
popupDialog.hide(); left: (left < 0? 0 : left) + 'px'
}); });
popupDialog.find('button.api-popup-authbtn').click(function() {
popupMask.hide();
popupDialog.hide();
var authSchemes = window.swaggerUi.api.authSchemes; popupDialog.find('button.api-popup-cancel').click(function() {
var host = window.location; popupMask.hide();
var redirectUrl = host.protocol + '//' + host.host + "/o2c.html"; popupDialog.hide();
var url = null; });
popupDialog.find('button.api-popup-authbtn').click(function() {
popupMask.hide();
popupDialog.hide();
var p = window.swaggerUi.api.authSchemes; var authSchemes = window.swaggerUi.api.authSchemes;
for (var key in p) { var location = window.location;
if (p.hasOwnProperty(key)) { var locationUrl = location.protocol + '//' + location.host + location.pathname;
var o = p[key].grantTypes; var redirectUrl = locationUrl.replace("index.html","").concat("/o2c.html").replace("//o2c.html","/o2c.html");
for(var t in o) { var url = null;
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t]; var p = window.swaggerUi.api.authSchemes;
url = dets.loginEndpoint.url + "?response_type=token"; for (var key in p) {
window.swaggerUi.tokenName = dets.tokenName; if (p.hasOwnProperty(key)) {
var o = p[key].grantTypes;
for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
url = dets.loginEndpoint.url + "?response_type=token";
window.swaggerUi.tokenName = dets.tokenName;
}
} }
} }
} }
} var scopes = [];
var scopes = [] var scopeForUrl='';
var o = $('.api-popup-scopes').find('input:checked'); var o = $('.api-popup-scopes').find('input:checked');
for(k =0; k < o.length; k++) { for(var k =0; k < o.length; k++) {
scopes.push($(o[k]).attr("scope")); scopes.push($(o[k]).attr("scope"));
} if(k > 0){
scopeForUrl+=' ';
}
scopeForUrl+=$(o[k]).attr("scope");
}
window.enabledScopes=scopes; window.enabledScopes=scopes;
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopes);
window.open(url); url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
}); url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopeForUrl);
window.open(url);
});
}
popupMask.show(); popupMask.show();
popupDialog.show(); popupDialog.show();
return; return;