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