merged from auth_2.0 branch
This commit is contained in:
79
dist/css/screen.css
vendored
79
dist/css/screen.css
vendored
@@ -1100,85 +1100,6 @@
|
||||
.swagger-section .api-popup-actions {
|
||||
padding-top: 10px;
|
||||
}
|
||||
.auth {
|
||||
text-align: right;
|
||||
height: 15px;
|
||||
float: right;
|
||||
clear: both;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
.auth_icon {
|
||||
float: right;
|
||||
}
|
||||
.auth_container_2 {
|
||||
visibility: visible;
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
margin-top: 26px;
|
||||
float: left;
|
||||
display: none;
|
||||
border: solid 2px;
|
||||
background: white;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-khtml-border-radius: 4px;
|
||||
z-index: 2;
|
||||
}
|
||||
.auth_label {
|
||||
text-align: left;
|
||||
clear: left;
|
||||
float: left;
|
||||
padding-left: 10px;
|
||||
width: 90px;
|
||||
}
|
||||
.auth_submit {
|
||||
border-left: 1px;
|
||||
border-right: 1px;
|
||||
margin-top: 25px;
|
||||
margin-bottom: 25px;
|
||||
text-align: center;
|
||||
}
|
||||
.auth_button {
|
||||
display: block;
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
.auth_submit_button {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
padding: 6px 8px;
|
||||
font-size: 0.9em;
|
||||
color: white;
|
||||
float: right;
|
||||
text-align: center;
|
||||
background: #547f00;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-khtml-border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.auth_input {
|
||||
float: left;
|
||||
}
|
||||
.authentication_container {
|
||||
float: left;
|
||||
display: block;
|
||||
background: yellow;
|
||||
}
|
||||
.auth_button .auth_icon {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .access {
|
||||
float: right;
|
||||
}
|
||||
|
||||
3
dist/lib/swagger-client.js
vendored
3
dist/lib/swagger-client.js
vendored
@@ -389,6 +389,9 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
|
||||
this.produces = response.produces;
|
||||
this.securityDefinitions = response.securityDefinitions;
|
||||
|
||||
// legacy support
|
||||
this.authSchemes = response.securityDefinitions;
|
||||
|
||||
var location = this.parseUri(this.url);
|
||||
if(typeof this.schemes === 'undefined' || this.schemes.length === 0) {
|
||||
this.scheme = location.scheme;
|
||||
|
||||
60
dist/lib/swagger-oauth.js
vendored
60
dist/lib/swagger-oauth.js
vendored
@@ -7,10 +7,29 @@ var realm;
|
||||
function handleLogin() {
|
||||
var scopes = [];
|
||||
|
||||
if(window.swaggerUi.api.authSchemes
|
||||
&& window.swaggerUi.api.authSchemes.oauth2
|
||||
&& window.swaggerUi.api.authSchemes.oauth2.scopes) {
|
||||
scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
|
||||
var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
|
||||
if(auths) {
|
||||
var key;
|
||||
var defs = auths;
|
||||
for(key in defs) {
|
||||
var auth = defs[key];
|
||||
if(auth.type === 'oauth2' && auth.scopes) {
|
||||
var scope;
|
||||
if(Array.isArray(auth.scopes)) {
|
||||
// 1.2 support
|
||||
var i;
|
||||
for(i = 0; i < auth.scopes.length; i++) {
|
||||
scopes.push(auth.scopes[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 2.0 support
|
||||
for(scope in auth.scopes) {
|
||||
scopes.push({scope: scope, description: auth.scopes[scope]});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(window.swaggerUi.api
|
||||
@@ -18,9 +37,6 @@ function handleLogin() {
|
||||
appName = window.swaggerUi.api.info.title;
|
||||
}
|
||||
|
||||
if(popupDialog.length > 0)
|
||||
popupDialog = popupDialog.last();
|
||||
else {
|
||||
popupDialog = $(
|
||||
[
|
||||
'<div class="api-popup-dialog">',
|
||||
@@ -48,7 +64,6 @@ function handleLogin() {
|
||||
str += '</label></li>';
|
||||
popup.append(str);
|
||||
}
|
||||
}
|
||||
|
||||
var $win = $(window),
|
||||
dw = $win.width(),
|
||||
@@ -67,7 +82,10 @@ function handleLogin() {
|
||||
popupDialog.find('button.api-popup-cancel').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
popupDialog.empty();
|
||||
popupDialog = [];
|
||||
});
|
||||
|
||||
popupDialog.find('button.api-popup-authbtn').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
@@ -75,26 +93,35 @@ function handleLogin() {
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
|
||||
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
|
||||
var url = null;
|
||||
|
||||
for (var key in authSchemes) {
|
||||
if (authSchemes.hasOwnProperty(key)) {
|
||||
if(authSchemes[key].type === 'oauth2' && authSchemes[key].flow === 'implicit') {
|
||||
var dets = authSchemes[key];
|
||||
url = dets.authorizationUrl + '?response_type=token';
|
||||
window.swaggerUi.tokenName = dets.tokenUrl || 'access_token';
|
||||
}
|
||||
else if(authSchemes[key].grantTypes) {
|
||||
// 1.2 support
|
||||
var o = authSchemes[key].grantTypes;
|
||||
for(var t in o) {
|
||||
if(o.hasOwnProperty(t) && t === 'implicit') {
|
||||
var dets = o[t];
|
||||
url = dets.loginEndpoint.url + "?response_type=token";
|
||||
var ep = dets.loginEndpoint.url;
|
||||
url = dets.loginEndpoint.url + '?response_type=token';
|
||||
window.swaggerUi.tokenName = dets.tokenName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var scopes = []
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
|
||||
for(k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr("scope"));
|
||||
scopes.push($(o[k]).attr('scope'));
|
||||
}
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
@@ -130,14 +157,14 @@ function initOAuth(opts) {
|
||||
var o = (opts||{});
|
||||
var errors = [];
|
||||
|
||||
appName = (o.appName||errors.push("missing appName"));
|
||||
appName = (o.appName||errors.push('missing appName'));
|
||||
popupMask = (o.popupMask||$('#api-common-mask'));
|
||||
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
|
||||
clientId = (o.clientId||errors.push("missing client id"));
|
||||
realm = (o.realm||errors.push("missing realm"));
|
||||
clientId = (o.clientId||errors.push('missing client id'));
|
||||
realm = (o.realm||errors.push('missing realm'));
|
||||
|
||||
if(errors.length > 0){
|
||||
log("auth unable initialize oauth: " + errors);
|
||||
log('auth unable initialize oauth: ' + errors);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,8 +230,7 @@ function onOAuthComplete(token) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
|
||||
window.authorizations.add('oauth2', new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
dist/lib/swagger.js
vendored
24
dist/lib/swagger.js
vendored
@@ -1,5 +1,5 @@
|
||||
// swagger.js
|
||||
// version 2.0.41
|
||||
// version 2.0.42
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -974,16 +974,22 @@
|
||||
var queryParams = "";
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var param = params[i];
|
||||
if (param.paramType === 'query') {
|
||||
if (args[param.name] !== undefined) {
|
||||
if (queryParams !== '')
|
||||
queryParams += "&";
|
||||
queryParams += '&';
|
||||
if (Array.isArray(param)) {
|
||||
var j;
|
||||
var output = '';
|
||||
for(j = 0; j < param.length; j++) {
|
||||
if(j > 0)
|
||||
output += ',';
|
||||
output += encodeURIComponent(param[j]);
|
||||
}
|
||||
queryParams += encodeURIComponent(param.name) + '=' + output;
|
||||
}
|
||||
else {
|
||||
queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((queryParams != null) && queryParams.length > 0)
|
||||
url += '?' + queryParams;
|
||||
return url;
|
||||
};
|
||||
|
||||
@@ -1477,8 +1483,8 @@
|
||||
data: response.content.data
|
||||
};
|
||||
|
||||
var contentType = (response._headers["content-type"] || response._headers["Content-Type"] || null)
|
||||
|
||||
var headers = response._headers.normalized || response._headers;
|
||||
var contentType = (headers["content-type"] || headers["Content-Type"] || null)
|
||||
if (contentType != null) {
|
||||
if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
|
||||
if (response.content.data && response.content.data !== "")
|
||||
|
||||
1
dist/swagger-ui.js
vendored
1
dist/swagger-ui.js
vendored
@@ -1782,7 +1782,6 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
this.model.description = this.model.description.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
||||
}
|
||||
this.model.oauth = null;
|
||||
log(this.model.authorizations);
|
||||
if (this.model.authorizations) {
|
||||
if (Array.isArray(this.model.authorizations)) {
|
||||
_ref5 = this.model.authorizations;
|
||||
|
||||
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
@@ -389,6 +389,9 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
|
||||
this.produces = response.produces;
|
||||
this.securityDefinitions = response.securityDefinitions;
|
||||
|
||||
// legacy support
|
||||
this.authSchemes = response.securityDefinitions;
|
||||
|
||||
var location = this.parseUri(this.url);
|
||||
if(typeof this.schemes === 'undefined' || this.schemes.length === 0) {
|
||||
this.scheme = location.scheme;
|
||||
|
||||
@@ -7,10 +7,29 @@ var realm;
|
||||
function handleLogin() {
|
||||
var scopes = [];
|
||||
|
||||
if(window.swaggerUi.api.authSchemes
|
||||
&& window.swaggerUi.api.authSchemes.oauth2
|
||||
&& window.swaggerUi.api.authSchemes.oauth2.scopes) {
|
||||
scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
|
||||
var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
|
||||
if(auths) {
|
||||
var key;
|
||||
var defs = auths;
|
||||
for(key in defs) {
|
||||
var auth = defs[key];
|
||||
if(auth.type === 'oauth2' && auth.scopes) {
|
||||
var scope;
|
||||
if(Array.isArray(auth.scopes)) {
|
||||
// 1.2 support
|
||||
var i;
|
||||
for(i = 0; i < auth.scopes.length; i++) {
|
||||
scopes.push(auth.scopes[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 2.0 support
|
||||
for(scope in auth.scopes) {
|
||||
scopes.push({scope: scope, description: auth.scopes[scope]});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(window.swaggerUi.api
|
||||
@@ -18,9 +37,6 @@ function handleLogin() {
|
||||
appName = window.swaggerUi.api.info.title;
|
||||
}
|
||||
|
||||
if(popupDialog.length > 0)
|
||||
popupDialog = popupDialog.last();
|
||||
else {
|
||||
popupDialog = $(
|
||||
[
|
||||
'<div class="api-popup-dialog">',
|
||||
@@ -48,7 +64,6 @@ function handleLogin() {
|
||||
str += '</label></li>';
|
||||
popup.append(str);
|
||||
}
|
||||
}
|
||||
|
||||
var $win = $(window),
|
||||
dw = $win.width(),
|
||||
@@ -67,7 +82,10 @@ function handleLogin() {
|
||||
popupDialog.find('button.api-popup-cancel').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
popupDialog.empty();
|
||||
popupDialog = [];
|
||||
});
|
||||
|
||||
popupDialog.find('button.api-popup-authbtn').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
@@ -75,26 +93,35 @@ function handleLogin() {
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
|
||||
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
|
||||
var url = null;
|
||||
|
||||
for (var key in authSchemes) {
|
||||
if (authSchemes.hasOwnProperty(key)) {
|
||||
if(authSchemes[key].type === 'oauth2' && authSchemes[key].flow === 'implicit') {
|
||||
var dets = authSchemes[key];
|
||||
url = dets.authorizationUrl + '?response_type=token';
|
||||
window.swaggerUi.tokenName = dets.tokenUrl || 'access_token';
|
||||
}
|
||||
else if(authSchemes[key].grantTypes) {
|
||||
// 1.2 support
|
||||
var o = authSchemes[key].grantTypes;
|
||||
for(var t in o) {
|
||||
if(o.hasOwnProperty(t) && t === 'implicit') {
|
||||
var dets = o[t];
|
||||
url = dets.loginEndpoint.url + "?response_type=token";
|
||||
var ep = dets.loginEndpoint.url;
|
||||
url = dets.loginEndpoint.url + '?response_type=token';
|
||||
window.swaggerUi.tokenName = dets.tokenName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var scopes = []
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
|
||||
for(k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr("scope"));
|
||||
scopes.push($(o[k]).attr('scope'));
|
||||
}
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
@@ -130,14 +157,14 @@ function initOAuth(opts) {
|
||||
var o = (opts||{});
|
||||
var errors = [];
|
||||
|
||||
appName = (o.appName||errors.push("missing appName"));
|
||||
appName = (o.appName||errors.push('missing appName'));
|
||||
popupMask = (o.popupMask||$('#api-common-mask'));
|
||||
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
|
||||
clientId = (o.clientId||errors.push("missing client id"));
|
||||
realm = (o.realm||errors.push("missing realm"));
|
||||
clientId = (o.clientId||errors.push('missing client id'));
|
||||
realm = (o.realm||errors.push('missing realm'));
|
||||
|
||||
if(errors.length > 0){
|
||||
log("auth unable initialize oauth: " + errors);
|
||||
log('auth unable initialize oauth: ' + errors);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,8 +230,7 @@ function onOAuthComplete(token) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
|
||||
window.authorizations.add('oauth2', new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ class OperationView extends Backbone.View
|
||||
if @model.description
|
||||
@model.description = @model.description.replace(/(?:\r\n|\r|\n)/g, '<br />')
|
||||
@model.oauth = null
|
||||
log @model.authorizations
|
||||
if @model.authorizations
|
||||
if Array.isArray @model.authorizations
|
||||
for auths in @model.authorizations
|
||||
|
||||
@@ -1100,85 +1100,6 @@
|
||||
.swagger-section .api-popup-actions {
|
||||
padding-top: 10px;
|
||||
}
|
||||
.auth {
|
||||
text-align: right;
|
||||
height: 15px;
|
||||
float: right;
|
||||
clear: both;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
.auth_icon {
|
||||
float: right;
|
||||
}
|
||||
.auth_container_2 {
|
||||
visibility: visible;
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
margin-top: 26px;
|
||||
float: left;
|
||||
display: none;
|
||||
border: solid 2px;
|
||||
background: white;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-khtml-border-radius: 4px;
|
||||
z-index: 2;
|
||||
}
|
||||
.auth_label {
|
||||
text-align: left;
|
||||
clear: left;
|
||||
float: left;
|
||||
padding-left: 10px;
|
||||
width: 90px;
|
||||
}
|
||||
.auth_submit {
|
||||
border-left: 1px;
|
||||
border-right: 1px;
|
||||
margin-top: 25px;
|
||||
margin-bottom: 25px;
|
||||
text-align: center;
|
||||
}
|
||||
.auth_button {
|
||||
display: block;
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
.auth_submit_button {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
padding: 6px 8px;
|
||||
font-size: 0.9em;
|
||||
color: white;
|
||||
float: right;
|
||||
text-align: center;
|
||||
background: #547f00;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-khtml-border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.auth_input {
|
||||
float: left;
|
||||
}
|
||||
.authentication_container {
|
||||
float: left;
|
||||
display: block;
|
||||
background: yellow;
|
||||
}
|
||||
.auth_button .auth_icon {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .access {
|
||||
float: right;
|
||||
}
|
||||
|
||||
@@ -81,94 +81,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.auth {
|
||||
text-align: right;
|
||||
height: 15px;
|
||||
float: right;
|
||||
clear: both;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.auth_icon {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.auth_container_2 {
|
||||
visibility: visible;
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
float:left;
|
||||
margin-top: 26px;
|
||||
float: left;
|
||||
display: none;
|
||||
border: solid 2px;
|
||||
background: white;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-khtml-border-radius: 4px;
|
||||
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.auth_label {
|
||||
text-align: left;
|
||||
clear: left;
|
||||
float: left;
|
||||
padding-left: 10px;
|
||||
width: 90px;
|
||||
}
|
||||
|
||||
.auth_submit {
|
||||
border-left: 1px;
|
||||
border-right: 1px;
|
||||
margin-top: 25px;
|
||||
margin-bottom: 25px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.auth_button {
|
||||
display: block;
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.auth_submit_button {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
padding: 6px 8px;
|
||||
font-size: 0.9em;
|
||||
color: white;
|
||||
float: right;
|
||||
text-align: center;
|
||||
background: #547f00;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-khtml-border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.auth_input {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.authentication_container {
|
||||
float: left;
|
||||
display: block;
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.auth_button .auth_icon {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
cursor: pointer;
|
||||
}
|
||||
Reference in New Issue
Block a user