Merge branch 'master' of https://github.com/CatLabInteractive/swagger-ui into CatLabInteractive-master

Conflicts:
	dist/lib/swagger-oauth.js
	dist/swagger-ui.js
	dist/swagger-ui.min.js
	lib/swagger-oauth.js
This commit is contained in:
Mohsen Azimi
2015-03-02 10:15:48 -08:00
2 changed files with 20 additions and 12 deletions

View File

@@ -103,12 +103,12 @@ function handleLogin() {
for (var key in authSchemes) {
if (authSchemes.hasOwnProperty(key)) {
var flow = authSchemes[key].flow;
if(authSchemes[key].type === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) {
var dets = authSchemes[key];
url = dets.authorizationUrl + '?response_type=' + (flow === 'implicit' ? 'token' : 'code');
window.swaggerUi.tokenName = dets.tokenName || 'access_token';
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null);
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null);
}
else if(authSchemes[key].grantTypes) {
// 1.2 support
@@ -135,11 +135,14 @@ function handleLogin() {
for(k =0; k < o.length; k++) {
var scope = $(o[k]).attr('scope');
if (scopes.indexOf(scope) === -1)
scopes.push(scope);
}
// Implicit auth recommends a state parameter.
var state = Math.random ();
window.enabledScopes=scopes;
redirect_uri = redirectUrl;
@@ -148,6 +151,7 @@ function handleLogin() {
url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopes.join(' '));
url += '&state=' + encodeURIComponent(state);
window.open(url);
});
@@ -210,11 +214,11 @@ function processOAuthCode(data) {
url : window.swaggerUi.tokenUrl,
type: "POST",
data: params,
success:function(data, textStatus, jqXHR)
success:function(data, textStatus, jqXHR)
{
onOAuthComplete(data);
},
error: function(jqXHR, textStatus, errorThrown)
error: function(jqXHR, textStatus, errorThrown)
{
onOAuthComplete("");
}
@@ -268,7 +272,7 @@ function onOAuthComplete(token) {
// all scopes are satisfied
$(o).find('.api-ic').addClass('ic-info');
$(o).find('.api-ic').removeClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error');
$(o).find('.api-ic').removeClass('ic-error');
}
}
});