mirror of https://github.com/Ombi-app/Ombi
parent
7266f20927
commit
9b4ae2c486
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
|
||||
* http://benalman.com/projects/jquery-bbq-plugin/
|
||||
*
|
||||
* Copyright (c) 2010 "Cowboy" Ben Alman
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://benalman.com/about/license/
|
||||
*/
|
||||
(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this);
|
||||
/*
|
||||
* jQuery hashchange event - v1.2 - 2/11/2010
|
||||
* http://benalman.com/projects/jquery-hashchange-plugin/
|
||||
*
|
||||
* Copyright (c) 2010 "Cowboy" Ben Alman
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://benalman.com/about/license/
|
||||
*/
|
||||
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
|
@ -0,0 +1 @@
|
||||
(function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery);
|
@ -0,0 +1,8 @@
|
||||
/*
|
||||
jQuery Wiggle
|
||||
Author: WonderGroup, Jordan Thomas
|
||||
URL: http://labs.wondergroup.com/demos/mini-ui/index.html
|
||||
License: MIT (http://en.wikipedia.org/wiki/MIT_License)
|
||||
*/
|
||||
jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
|
||||
if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,125 @@
|
||||
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
|
||||
html,
|
||||
body,
|
||||
div,
|
||||
span,
|
||||
applet,
|
||||
object,
|
||||
iframe,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
p,
|
||||
blockquote,
|
||||
pre,
|
||||
a,
|
||||
abbr,
|
||||
acronym,
|
||||
address,
|
||||
big,
|
||||
cite,
|
||||
code,
|
||||
del,
|
||||
dfn,
|
||||
em,
|
||||
img,
|
||||
ins,
|
||||
kbd,
|
||||
q,
|
||||
s,
|
||||
samp,
|
||||
small,
|
||||
strike,
|
||||
strong,
|
||||
sub,
|
||||
sup,
|
||||
tt,
|
||||
var,
|
||||
b,
|
||||
u,
|
||||
i,
|
||||
center,
|
||||
dl,
|
||||
dt,
|
||||
dd,
|
||||
ol,
|
||||
ul,
|
||||
li,
|
||||
fieldset,
|
||||
form,
|
||||
label,
|
||||
legend,
|
||||
table,
|
||||
caption,
|
||||
tbody,
|
||||
tfoot,
|
||||
thead,
|
||||
tr,
|
||||
th,
|
||||
td,
|
||||
article,
|
||||
aside,
|
||||
canvas,
|
||||
details,
|
||||
embed,
|
||||
figure,
|
||||
figcaption,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
menu,
|
||||
nav,
|
||||
output,
|
||||
ruby,
|
||||
section,
|
||||
summary,
|
||||
time,
|
||||
mark,
|
||||
audio,
|
||||
video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
menu,
|
||||
nav,
|
||||
section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol,
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote,
|
||||
q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before,
|
||||
blockquote:after,
|
||||
q:before,
|
||||
q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,250 @@
|
||||
.swagger-section #header a#logo {
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
background: transparent url(../images/logo.png) no-repeat left center;
|
||||
padding: 20px 0 20px 40px;
|
||||
}
|
||||
#text-head {
|
||||
font-size: 80px;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
color: #ffffff;
|
||||
float: right;
|
||||
margin-right: 20%;
|
||||
}
|
||||
.navbar-fixed-top .navbar-nav {
|
||||
height: auto;
|
||||
}
|
||||
.navbar-fixed-top .navbar-brand {
|
||||
height: auto;
|
||||
}
|
||||
.navbar-header {
|
||||
height: auto;
|
||||
}
|
||||
.navbar-inverse {
|
||||
background-color: #000;
|
||||
border-color: #000;
|
||||
}
|
||||
#navbar-brand {
|
||||
margin-left: 20%;
|
||||
}
|
||||
.navtext {
|
||||
font-size: 10px;
|
||||
}
|
||||
.h1,
|
||||
h1 {
|
||||
font-size: 60px;
|
||||
}
|
||||
.navbar-default .navbar-header .navbar-brand {
|
||||
color: #a2dfee;
|
||||
}
|
||||
/* tag titles */
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a {
|
||||
color: #393939;
|
||||
font-family: 'Arvo', serif;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
|
||||
color: black;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
|
||||
color: #525252;
|
||||
padding-left: 0px;
|
||||
display: block;
|
||||
clear: none;
|
||||
float: left;
|
||||
font-family: 'Arvo', serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
.navbar-default .navbar-collapse,
|
||||
.navbar-default .navbar-form {
|
||||
border-color: #0A0A0A;
|
||||
}
|
||||
.container1 {
|
||||
width: 1500px;
|
||||
margin: auto;
|
||||
margin-top: 0;
|
||||
background-image: url('../images/shield.png');
|
||||
background-repeat: no-repeat;
|
||||
background-position: -40px -20px;
|
||||
margin-bottom: 210px;
|
||||
}
|
||||
.container-inner {
|
||||
width: 1200px;
|
||||
margin: auto;
|
||||
background-color: rgba(223, 227, 228, 0.75);
|
||||
padding-bottom: 40px;
|
||||
padding-top: 40px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
.header-content {
|
||||
padding: 0;
|
||||
width: 1000px;
|
||||
}
|
||||
.title1 {
|
||||
font-size: 80px;
|
||||
font-family: 'Vollkorn', serif;
|
||||
color: #404040;
|
||||
text-align: center;
|
||||
padding-top: 40px;
|
||||
padding-bottom: 100px;
|
||||
}
|
||||
#icon {
|
||||
margin-top: -18px;
|
||||
}
|
||||
.subtext {
|
||||
font-size: 25px;
|
||||
font-style: italic;
|
||||
color: #08b;
|
||||
text-align: right;
|
||||
padding-right: 250px;
|
||||
}
|
||||
.bg-primary {
|
||||
background-color: #00468b;
|
||||
}
|
||||
.navbar-default .nav > li > a,
|
||||
.navbar-default .nav > li > a:focus {
|
||||
color: #08b;
|
||||
}
|
||||
.navbar-default .nav > li > a,
|
||||
.navbar-default .nav > li > a:hover {
|
||||
color: #08b;
|
||||
}
|
||||
.navbar-default .nav > li > a,
|
||||
.navbar-default .nav > li > a:focus:hover {
|
||||
color: #08b;
|
||||
}
|
||||
.text-faded {
|
||||
font-size: 25px;
|
||||
font-family: 'Vollkorn', serif;
|
||||
}
|
||||
.section-heading {
|
||||
font-family: 'Vollkorn', serif;
|
||||
font-size: 45px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
hr {
|
||||
border-color: #00468b;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.description {
|
||||
margin-top: 20px;
|
||||
padding-bottom: 200px;
|
||||
}
|
||||
.description li {
|
||||
font-family: 'Vollkorn', serif;
|
||||
font-size: 25px;
|
||||
color: #525252;
|
||||
margin-left: 28%;
|
||||
padding-top: 5px;
|
||||
}
|
||||
.gap {
|
||||
margin-top: 200px;
|
||||
}
|
||||
.troubleshootingtext {
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
padding-left: 30%;
|
||||
}
|
||||
.troubleshootingtext li {
|
||||
list-style-type: circle;
|
||||
font-size: 25px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
.overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1000;
|
||||
}
|
||||
.block.response_body.json:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
.backdrop {
|
||||
color: blue;
|
||||
}
|
||||
#myModal {
|
||||
height: 100%;
|
||||
}
|
||||
.modal-backdrop {
|
||||
bottom: 0;
|
||||
position: fixed;
|
||||
}
|
||||
.curl {
|
||||
padding: 10px;
|
||||
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
|
||||
font-size: 0.9em;
|
||||
max-height: 400px;
|
||||
margin-top: 5px;
|
||||
overflow-y: auto;
|
||||
background-color: #fcf6db;
|
||||
border: 1px solid #e5e0c6;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.curl_title {
|
||||
font-size: 1.1em;
|
||||
margin: 0;
|
||||
padding: 15px 0 5px;
|
||||
font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
|
||||
font-weight: 500;
|
||||
line-height: 1.1;
|
||||
}
|
||||
.footer {
|
||||
display: none;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap h2 {
|
||||
padding: 0;
|
||||
}
|
||||
h2 {
|
||||
margin: 0;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.markdown p {
|
||||
font-size: 15px;
|
||||
font-family: 'Arvo', serif;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap .code {
|
||||
font-size: 15px;
|
||||
font-family: 'Arvo', serif;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap b {
|
||||
font-family: 'Arvo', serif;
|
||||
}
|
||||
#signin:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
.dropdown-menu {
|
||||
padding: 15px;
|
||||
}
|
||||
.navbar-right .dropdown-menu {
|
||||
left: 0;
|
||||
right: auto;
|
||||
}
|
||||
#signinbutton {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
font-size: 13px;
|
||||
font-weight: bold;
|
||||
color: #08b;
|
||||
}
|
||||
.navbar-default .nav > li .details {
|
||||
color: #000000;
|
||||
text-transform: none;
|
||||
font-size: 15px;
|
||||
font-weight: normal;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-style: italic;
|
||||
line-height: 20px;
|
||||
top: -2px;
|
||||
}
|
||||
.navbar-default .nav > li .details:hover {
|
||||
color: black;
|
||||
}
|
||||
#signout {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
font-size: 13px;
|
||||
font-weight: bold;
|
||||
color: #08b;
|
||||
}
|
@ -0,0 +1,338 @@
|
||||
var appName;
|
||||
var popupMask;
|
||||
var popupDialog;
|
||||
var clientId;
|
||||
var realm;
|
||||
var redirect_uri;
|
||||
var clientSecret;
|
||||
var scopeSeparator;
|
||||
var additionalQueryStringParams;
|
||||
|
||||
function handleLogin() {
|
||||
var 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], OAuthSchemeKey: key});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(window.swaggerUi.api
|
||||
&& window.swaggerUi.api.info) {
|
||||
appName = window.swaggerUi.api.info.title;
|
||||
}
|
||||
|
||||
$('.api-popup-dialog').remove();
|
||||
popupDialog = $(
|
||||
[
|
||||
'<div class="api-popup-dialog">',
|
||||
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
|
||||
'<div class="api-popup-content">',
|
||||
'<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.',
|
||||
'<a href="#">Learn how to use</a>',
|
||||
'</p>',
|
||||
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
|
||||
'<ul class="api-popup-scopes">',
|
||||
'</ul>',
|
||||
'<p class="error-msg"></p>',
|
||||
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
|
||||
'</div>',
|
||||
'</div>'].join(''));
|
||||
$(document.body).append(popupDialog);
|
||||
|
||||
//TODO: only display applicable scopes (will need to pass them into handleLogin)
|
||||
popup = popupDialog.find('ul.api-popup-scopes').empty();
|
||||
for (i = 0; i < scopes.length; i ++) {
|
||||
scope = scopes[i];
|
||||
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"' +'" oauthtype="' + scope.OAuthSchemeKey +'"/>' + '<label for="scope_' + i + '">' + scope.scope ;
|
||||
if (scope.description) {
|
||||
if ($.map(auths, function(n, i) { return i; }).length > 1) //if we have more than one scheme, display schemes
|
||||
str += '<br/><span class="api-scope-desc">' + scope.description + ' ('+ scope.OAuthSchemeKey+')' +'</span>';
|
||||
else
|
||||
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
|
||||
}
|
||||
str += '</label></li>';
|
||||
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({
|
||||
top: (top < 0? 0 : top) + 'px',
|
||||
left: (left < 0? 0 : left) + 'px'
|
||||
});
|
||||
|
||||
popupDialog.find('button.api-popup-cancel').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
popupDialog.empty();
|
||||
popupDialog = [];
|
||||
});
|
||||
|
||||
$('button.api-popup-authbtn').unbind();
|
||||
popupDialog.find('button.api-popup-authbtn').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
|
||||
var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl;
|
||||
var url = null;
|
||||
var scopes = []
|
||||
var o = popup.find('input:checked');
|
||||
var OAuthSchemeKeys = [];
|
||||
var state;
|
||||
for(k =0; k < o.length; k++) {
|
||||
var scope = $(o[k]).attr('scope');
|
||||
if (scopes.indexOf(scope) === -1)
|
||||
scopes.push(scope);
|
||||
var OAuthSchemeKey = $(o[k]).attr('oauthtype');
|
||||
if (OAuthSchemeKeys.indexOf(OAuthSchemeKey) === -1)
|
||||
OAuthSchemeKeys.push(OAuthSchemeKey);
|
||||
}
|
||||
|
||||
//TODO: merge not replace if scheme is different from any existing
|
||||
//(needs to be aware of schemes to do so correctly)
|
||||
window.enabledScopes=scopes;
|
||||
|
||||
for (var key in authSchemes) {
|
||||
if (authSchemes.hasOwnProperty(key) && OAuthSchemeKeys.indexOf(key) != -1) { //only look at keys that match this scope.
|
||||
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);
|
||||
state = key;
|
||||
}
|
||||
else if(authSchemes[key].type === 'oauth2' && flow && (flow === 'application')) {
|
||||
var dets = authSchemes[key];
|
||||
window.swaggerUi.tokenName = dets.tokenName || 'access_token';
|
||||
clientCredentialsFlow(scopes, dets.tokenUrl, key);
|
||||
return;
|
||||
}
|
||||
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];
|
||||
var ep = dets.loginEndpoint.url;
|
||||
url = dets.loginEndpoint.url + '?response_type=token';
|
||||
window.swaggerUi.tokenName = dets.tokenName;
|
||||
}
|
||||
else if (o.hasOwnProperty(t) && t === 'accessCode') {
|
||||
var dets = o[t];
|
||||
var ep = dets.tokenRequestEndpoint.url;
|
||||
url = dets.tokenRequestEndpoint.url + '?response_type=code';
|
||||
window.swaggerUi.tokenName = dets.tokenName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
redirect_uri = redirectUrl;
|
||||
|
||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||
url += '&realm=' + encodeURIComponent(realm);
|
||||
url += '&client_id=' + encodeURIComponent(clientId);
|
||||
url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator));
|
||||
url += '&state=' + encodeURIComponent(state);
|
||||
for (var key in additionalQueryStringParams) {
|
||||
url += '&' + key + '=' + encodeURIComponent(additionalQueryStringParams[key]);
|
||||
}
|
||||
|
||||
window.open(url);
|
||||
});
|
||||
|
||||
popupMask.show();
|
||||
popupDialog.show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function handleLogout() {
|
||||
for(key in window.swaggerUi.api.clientAuthorizations.authz){
|
||||
window.swaggerUi.api.clientAuthorizations.remove(key)
|
||||
}
|
||||
window.enabledScopes = null;
|
||||
$('.api-ic.ic-on').addClass('ic-off');
|
||||
$('.api-ic.ic-on').removeClass('ic-on');
|
||||
|
||||
// set the info box
|
||||
$('.api-ic.ic-warning').addClass('ic-error');
|
||||
$('.api-ic.ic-warning').removeClass('ic-warning');
|
||||
}
|
||||
|
||||
function initOAuth(opts) {
|
||||
var o = (opts||{});
|
||||
var errors = [];
|
||||
|
||||
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'));
|
||||
clientSecret = (o.clientSecret||null);
|
||||
realm = (o.realm||errors.push('missing realm'));
|
||||
scopeSeparator = (o.scopeSeparator||' ');
|
||||
additionalQueryStringParams = (o.additionalQueryStringParams||{});
|
||||
|
||||
if(errors.length > 0){
|
||||
log('auth unable initialize oauth: ' + errors);
|
||||
return;
|
||||
}
|
||||
|
||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
||||
$('.api-ic').unbind();
|
||||
$('.api-ic').click(function(s) {
|
||||
if($(s.target).hasClass('ic-off'))
|
||||
handleLogin();
|
||||
else {
|
||||
handleLogout();
|
||||
}
|
||||
false;
|
||||
});
|
||||
}
|
||||
|
||||
function clientCredentialsFlow(scopes, tokenUrl, OAuthSchemeKey) {
|
||||
var params = {
|
||||
'client_id': clientId,
|
||||
'client_secret': clientSecret,
|
||||
'scope': scopes.join(' '),
|
||||
'grant_type': 'client_credentials'
|
||||
}
|
||||
$.ajax(
|
||||
{
|
||||
url : tokenUrl,
|
||||
type: "POST",
|
||||
data: params,
|
||||
success:function(data, textStatus, jqXHR)
|
||||
{
|
||||
onOAuthComplete(data,OAuthSchemeKey);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
onOAuthComplete("");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
window.processOAuthCode = function processOAuthCode(data) {
|
||||
var OAuthSchemeKey = data.state;
|
||||
var params = {
|
||||
'client_id': clientId,
|
||||
'code': data.code,
|
||||
'grant_type': 'authorization_code',
|
||||
'redirect_uri': redirect_uri
|
||||
};
|
||||
|
||||
if (clientSecret) {
|
||||
params.client_secret = clientSecret;
|
||||
}
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
url : window.swaggerUi.tokenUrl,
|
||||
type: "POST",
|
||||
data: params,
|
||||
success:function(data, textStatus, jqXHR)
|
||||
{
|
||||
onOAuthComplete(data, OAuthSchemeKey);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
onOAuthComplete("");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
|
||||
if(token) {
|
||||
if(token.error) {
|
||||
var checkbox = $('input[type=checkbox],.secured')
|
||||
checkbox.each(function(pos){
|
||||
checkbox[pos].checked = false;
|
||||
});
|
||||
alert(token.error);
|
||||
}
|
||||
else {
|
||||
var b = token[window.swaggerUi.tokenName];
|
||||
if (!OAuthSchemeKey){
|
||||
OAuthSchemeKey = token.state;
|
||||
}
|
||||
if(b){
|
||||
// if all roles are satisfied
|
||||
var o = null;
|
||||
$.each($('.auth .api-ic .api_information_panel'), function(k, v) {
|
||||
var children = v;
|
||||
if(children && children.childNodes) {
|
||||
var requiredScopes = [];
|
||||
$.each((children.childNodes), function (k1, v1){
|
||||
var inner = v1.innerHTML;
|
||||
if(inner)
|
||||
requiredScopes.push(inner);
|
||||
});
|
||||
var diff = [];
|
||||
for(var i=0; i < requiredScopes.length; i++) {
|
||||
var s = requiredScopes[i];
|
||||
if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
|
||||
diff.push(s);
|
||||
}
|
||||
}
|
||||
if(diff.length > 0){
|
||||
o = v.parentNode.parentNode;
|
||||
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
|
||||
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
|
||||
|
||||
// sorry, not all scopes are satisfied
|
||||
$(o).find('.api-ic').addClass('ic-warning');
|
||||
$(o).find('.api-ic').removeClass('ic-error');
|
||||
}
|
||||
else {
|
||||
o = v.parentNode.parentNode;
|
||||
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
|
||||
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
|
||||
|
||||
// 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');
|
||||
}
|
||||
}
|
||||
});
|
||||
window.swaggerUi.api.clientAuthorizations.add(OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,14 @@
|
||||
/* Google Font's Droid Sans */
|
||||
@font-face {
|
||||
font-family: 'Droid Sans';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Droid Sans'), local('DroidSans'), url('../fonts/DroidSans.ttf') format('truetype');
|
||||
}
|
||||
/* Google Font's Droid Sans Bold */
|
||||
@font-face {
|
||||
font-family: 'Droid Sans';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Droid Sans Bold'), local('DroidSans-Bold'), url('../fonts/DroidSans-Bold.ttf') format('truetype');
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,20 @@
|
||||
<script>
|
||||
var qp = null;
|
||||
if(window.location.hash) {
|
||||
qp = location.hash.substring(1);
|
||||
}
|
||||
else {
|
||||
qp = location.search.substring(1);
|
||||
}
|
||||
qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
|
||||
function(key, value) {
|
||||
return key===""?value:decodeURIComponent(value) }
|
||||
):{}
|
||||
|
||||
if (window.opener.swaggerUi.tokenUrl)
|
||||
window.opener.processOAuthCode(qp);
|
||||
else
|
||||
window.opener.onOAuthComplete(qp);
|
||||
|
||||
window.close();
|
||||
</script>
|
Loading…
Reference in new issue