checks for window
This commit is contained in:
11
dist/lib/swagger-oauth.js
vendored
11
dist/lib/swagger-oauth.js
vendored
@@ -11,7 +11,7 @@ var additionalQueryStringParams;
|
|||||||
function handleLogin() {
|
function handleLogin() {
|
||||||
var scopes = [];
|
var scopes = [];
|
||||||
|
|
||||||
var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
|
var auths = window.swaggerUiAuth.authSchemes || window.swaggerUiAuth.securityDefinitions;
|
||||||
if(auths) {
|
if(auths) {
|
||||||
var key;
|
var key;
|
||||||
var defs = auths;
|
var defs = auths;
|
||||||
@@ -36,8 +36,7 @@ function handleLogin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(window.swaggerUi.api
|
if(window.swaggerUi.api && window.swaggerUi.api.info) {
|
||||||
&& window.swaggerUi.api.info) {
|
|
||||||
appName = window.swaggerUi.api.info.title;
|
appName = window.swaggerUi.api.info.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +294,7 @@ window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
|
|||||||
alert(token.error);
|
alert(token.error);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var b = token[window.swaggerUi.tokenName];
|
var b = token[window.swaggerUiAuth.tokenName];
|
||||||
if (!OAuthSchemeKey){
|
if (!OAuthSchemeKey){
|
||||||
OAuthSchemeKey = token.state;
|
OAuthSchemeKey = token.state;
|
||||||
}
|
}
|
||||||
@@ -339,9 +338,11 @@ window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.swaggerUi.api.clientAuthorizations.add(window.OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
if(typeof window.swaggerUi !== 'undefined') {
|
||||||
|
window.swaggerUi.api.clientAuthorizations.add(window.swaggerUiAuth.OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
||||||
window.swaggerUi.load();
|
window.swaggerUi.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
2
dist/o2c.html
vendored
2
dist/o2c.html
vendored
@@ -11,7 +11,7 @@ qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
|
|||||||
return key===""?value:decodeURIComponent(value) }
|
return key===""?value:decodeURIComponent(value) }
|
||||||
):{}
|
):{}
|
||||||
|
|
||||||
if (window.opener.swaggerUi.tokenUrl)
|
if (window.opener.swaggerUiAuth.tokenUrl)
|
||||||
window.opener.processOAuthCode(qp);
|
window.opener.processOAuthCode(qp);
|
||||||
else
|
else
|
||||||
window.opener.onOAuthComplete(qp);
|
window.opener.onOAuthComplete(qp);
|
||||||
|
|||||||
23
dist/swagger-ui.js
vendored
23
dist/swagger-ui.js
vendored
@@ -22216,7 +22216,11 @@ SwaggerUi.Collections.AuthsCollection = Backbone.Collection.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
parse: function (data) {
|
parse: function (data) {
|
||||||
var authz = Object.assign({}, window.swaggerUi.api.clientAuthorizations.authz);
|
var authz = {};
|
||||||
|
|
||||||
|
if(typeof window.swaggerUi !== 'undefined') {
|
||||||
|
authz = Object.assign({}, window.swaggerUi.api.clientAuthorizations.authz);
|
||||||
|
}
|
||||||
|
|
||||||
return _.map(data, function (auth, name) {
|
return _.map(data, function (auth, name) {
|
||||||
var isBasic = authz[name] && auth.type === 'basic' && authz[name].username && authz[name].password;
|
var isBasic = authz[name] && auth.type === 'basic' && authz[name].username && authz[name].password;
|
||||||
@@ -22395,8 +22399,9 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
|||||||
var scopes = _.map(auth.get('scopes'), function (scope) {
|
var scopes = _.map(auth.get('scopes'), function (scope) {
|
||||||
return scope.scope;
|
return scope.scope;
|
||||||
});
|
});
|
||||||
|
var container = window.swaggerUiAuth || (window.swaggerUiAuth = {});
|
||||||
var state, dets, ep;
|
var state, dets, ep;
|
||||||
window.OAuthSchemeKey = auth.get('title');
|
container.OAuthSchemeKey = auth.get('title');
|
||||||
|
|
||||||
window.enabledScopes = scopes;
|
window.enabledScopes = scopes;
|
||||||
var flow = auth.get('flow');
|
var flow = auth.get('flow');
|
||||||
@@ -22404,14 +22409,14 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
|||||||
if(auth.get('type') === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) {
|
if(auth.get('type') === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) {
|
||||||
dets = auth.attributes;
|
dets = auth.attributes;
|
||||||
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';
|
container.tokenName = dets.tokenName || 'access_token';
|
||||||
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null);
|
container.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null);
|
||||||
state = window.OAuthSchemeKey;
|
state = container.OAuthSchemeKey;
|
||||||
}
|
}
|
||||||
else if(auth.get('type') === 'oauth2' && flow && (flow === 'application')) {
|
else if(auth.get('type') === 'oauth2' && flow && (flow === 'application')) {
|
||||||
dets = auth.attributes;
|
dets = auth.attributes;
|
||||||
window.swaggerUi.tokenName = dets.tokenName || 'access_token';
|
container.tokenName = dets.tokenName || 'access_token';
|
||||||
this.clientCredentialsFlow(scopes, dets.tokenUrl, window.OAuthSchemeKey);
|
this.clientCredentialsFlow(scopes, dets.tokenUrl, container.OAuthSchemeKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(auth.get('grantTypes')) {
|
else if(auth.get('grantTypes')) {
|
||||||
@@ -22422,13 +22427,13 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
|||||||
dets = o[t];
|
dets = o[t];
|
||||||
ep = dets.loginEndpoint.url;
|
ep = dets.loginEndpoint.url;
|
||||||
url = dets.loginEndpoint.url + '?response_type=token';
|
url = dets.loginEndpoint.url + '?response_type=token';
|
||||||
window.swaggerUi.tokenName = dets.tokenName;
|
container.tokenName = dets.tokenName;
|
||||||
}
|
}
|
||||||
else if (o.hasOwnProperty(t) && t === 'accessCode') {
|
else if (o.hasOwnProperty(t) && t === 'accessCode') {
|
||||||
dets = o[t];
|
dets = o[t];
|
||||||
ep = dets.tokenRequestEndpoint.url;
|
ep = dets.tokenRequestEndpoint.url;
|
||||||
url = dets.tokenRequestEndpoint.url + '?response_type=code';
|
url = dets.tokenRequestEndpoint.url + '?response_type=code';
|
||||||
window.swaggerUi.tokenName = dets.tokenName;
|
container.tokenName = dets.tokenName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -11,7 +11,7 @@ var additionalQueryStringParams;
|
|||||||
function handleLogin() {
|
function handleLogin() {
|
||||||
var scopes = [];
|
var scopes = [];
|
||||||
|
|
||||||
var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
|
var auths = window.swaggerUiAuth.authSchemes || window.swaggerUiAuth.securityDefinitions;
|
||||||
if(auths) {
|
if(auths) {
|
||||||
var key;
|
var key;
|
||||||
var defs = auths;
|
var defs = auths;
|
||||||
@@ -36,8 +36,7 @@ function handleLogin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(window.swaggerUi.api
|
if(window.swaggerUi.api && window.swaggerUi.api.info) {
|
||||||
&& window.swaggerUi.api.info) {
|
|
||||||
appName = window.swaggerUi.api.info.title;
|
appName = window.swaggerUi.api.info.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +294,7 @@ window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
|
|||||||
alert(token.error);
|
alert(token.error);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var b = token[window.swaggerUi.tokenName];
|
var b = token[window.swaggerUiAuth.tokenName];
|
||||||
if (!OAuthSchemeKey){
|
if (!OAuthSchemeKey){
|
||||||
OAuthSchemeKey = token.state;
|
OAuthSchemeKey = token.state;
|
||||||
}
|
}
|
||||||
@@ -339,9 +338,11 @@ window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.swaggerUi.api.clientAuthorizations.add(window.OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
if(typeof window.swaggerUi !== 'undefined') {
|
||||||
|
window.swaggerUi.api.clientAuthorizations.add(window.swaggerUiAuth.OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
||||||
window.swaggerUi.load();
|
window.swaggerUi.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
|
|||||||
return key===""?value:decodeURIComponent(value) }
|
return key===""?value:decodeURIComponent(value) }
|
||||||
):{}
|
):{}
|
||||||
|
|
||||||
if (window.opener.swaggerUi.tokenUrl)
|
if (window.opener.swaggerUiAuth.tokenUrl)
|
||||||
window.opener.processOAuthCode(qp);
|
window.opener.processOAuthCode(qp);
|
||||||
else
|
else
|
||||||
window.opener.onOAuthComplete(qp);
|
window.opener.onOAuthComplete(qp);
|
||||||
|
|||||||
@@ -100,8 +100,9 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
|||||||
var scopes = _.map(auth.get('scopes'), function (scope) {
|
var scopes = _.map(auth.get('scopes'), function (scope) {
|
||||||
return scope.scope;
|
return scope.scope;
|
||||||
});
|
});
|
||||||
|
var container = window.swaggerUiAuth || (window.swaggerUiAuth = {});
|
||||||
var state, dets, ep;
|
var state, dets, ep;
|
||||||
window.OAuthSchemeKey = auth.get('title');
|
container.OAuthSchemeKey = auth.get('title');
|
||||||
|
|
||||||
window.enabledScopes = scopes;
|
window.enabledScopes = scopes;
|
||||||
var flow = auth.get('flow');
|
var flow = auth.get('flow');
|
||||||
@@ -109,14 +110,14 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
|||||||
if(auth.get('type') === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) {
|
if(auth.get('type') === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) {
|
||||||
dets = auth.attributes;
|
dets = auth.attributes;
|
||||||
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';
|
container.tokenName = dets.tokenName || 'access_token';
|
||||||
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null);
|
container.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null);
|
||||||
state = window.OAuthSchemeKey;
|
state = container.OAuthSchemeKey;
|
||||||
}
|
}
|
||||||
else if(auth.get('type') === 'oauth2' && flow && (flow === 'application')) {
|
else if(auth.get('type') === 'oauth2' && flow && (flow === 'application')) {
|
||||||
dets = auth.attributes;
|
dets = auth.attributes;
|
||||||
window.swaggerUi.tokenName = dets.tokenName || 'access_token';
|
container.tokenName = dets.tokenName || 'access_token';
|
||||||
this.clientCredentialsFlow(scopes, dets.tokenUrl, window.OAuthSchemeKey);
|
this.clientCredentialsFlow(scopes, dets.tokenUrl, container.OAuthSchemeKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(auth.get('grantTypes')) {
|
else if(auth.get('grantTypes')) {
|
||||||
@@ -127,13 +128,13 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
|||||||
dets = o[t];
|
dets = o[t];
|
||||||
ep = dets.loginEndpoint.url;
|
ep = dets.loginEndpoint.url;
|
||||||
url = dets.loginEndpoint.url + '?response_type=token';
|
url = dets.loginEndpoint.url + '?response_type=token';
|
||||||
window.swaggerUi.tokenName = dets.tokenName;
|
container.tokenName = dets.tokenName;
|
||||||
}
|
}
|
||||||
else if (o.hasOwnProperty(t) && t === 'accessCode') {
|
else if (o.hasOwnProperty(t) && t === 'accessCode') {
|
||||||
dets = o[t];
|
dets = o[t];
|
||||||
ep = dets.tokenRequestEndpoint.url;
|
ep = dets.tokenRequestEndpoint.url;
|
||||||
url = dets.tokenRequestEndpoint.url + '?response_type=code';
|
url = dets.tokenRequestEndpoint.url + '?response_type=code';
|
||||||
window.swaggerUi.tokenName = dets.tokenName;
|
container.tokenName = dets.tokenName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,11 @@ SwaggerUi.Collections.AuthsCollection = Backbone.Collection.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
parse: function (data) {
|
parse: function (data) {
|
||||||
var authz = Object.assign({}, window.swaggerUi.api.clientAuthorizations.authz);
|
var authz = {};
|
||||||
|
|
||||||
|
if(typeof window.swaggerUi !== 'undefined') {
|
||||||
|
authz = Object.assign({}, window.swaggerUi.api.clientAuthorizations.authz);
|
||||||
|
}
|
||||||
|
|
||||||
return _.map(data, function (auth, name) {
|
return _.map(data, function (auth, name) {
|
||||||
var isBasic = authz[name] && auth.type === 'basic' && authz[name].username && authz[name].password;
|
var isBasic = authz[name] && auth.type === 'basic' && authz[name].username && authz[name].password;
|
||||||
|
|||||||
Reference in New Issue
Block a user