Skip to content

Commit 02a63e2

Browse files
author
Javier Centurion
committed
Fix: Adding scopes for oAuth 2.0
1 parent e6ddfb4 commit 02a63e2

File tree

8 files changed

+85
-45
lines changed

8 files changed

+85
-45
lines changed

dist/scripts/api-console-vendor.js

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var block = {
2020
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
2121
blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
2222
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
23-
html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
23+
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
2424
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
2525
table: noop,
2626
paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
@@ -868,7 +868,7 @@ Renderer.prototype.link = function(href, title, text) {
868868
} catch (e) {
869869
return '';
870870
}
871-
if (prot.indexOf('javascript:') === 0) {
871+
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
872872
return '';
873873
}
874874
}
@@ -1154,8 +1154,13 @@ function marked(src, opt, callback) {
11541154

11551155
pending = tokens.length;
11561156

1157-
var done = function() {
1158-
var out, err;
1157+
var done = function(err) {
1158+
if (err) {
1159+
opt.highlight = highlight;
1160+
return callback(err);
1161+
}
1162+
1163+
var out;
11591164

11601165
try {
11611166
out = Parser.parse(tokens, opt);
@@ -1184,6 +1189,7 @@ function marked(src, opt, callback) {
11841189
return --pending || done();
11851190
}
11861191
return highlight(token.text, token.lang, function(err, code) {
1192+
if (err) return done(err);
11871193
if (code == null || code === token.text) {
11881194
return --pending || done();
11891195
}
@@ -1253,7 +1259,7 @@ marked.inlineLexer = InlineLexer.output;
12531259

12541260
marked.parse = marked;
12551261

1256-
if (typeof exports === 'object') {
1262+
if (typeof module !== 'undefined' && typeof exports === 'object') {
12571263
module.exports = marked;
12581264
} else if (typeof define === 'function' && define.amd) {
12591265
define(function() { return marked; });
@@ -40225,7 +40231,7 @@ CodeMirror.defineMIME("text/x-yaml", "yaml");
4022540231
})();
4022640232

4022740233
/**
40228-
* @license AngularJS v1.2.28
40234+
* @license AngularJS v1.2.29-build.590+sha.e81b2f7
4022940235
* (c) 2010-2014 Google, Inc. http://angularjs.org
4023040236
* License: MIT
4023140237
*/
@@ -40294,7 +40300,7 @@ function minErr(module) {
4029440300
return match;
4029540301
});
4029640302

40297-
message = message + '\nhttp://errors.angularjs.org/1.2.28/' +
40303+
message = message + '\nhttp://errors.angularjs.org/1.2.29-build.590+sha.e81b2f7/' +
4029840304
(module ? module + '/' : '') + code;
4029940305
for (i = 2; i < arguments.length; i++) {
4030040306
message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' +
@@ -40708,6 +40714,8 @@ noop.$inject = [];
4070840714
return (transformationFn || angular.identity)(value);
4070940715
};
4071040716
```
40717+
* @param {*} value to be returned.
40718+
* @returns {*} the value passed in.
4071140719
*/
4071240720
function identity($) {return $;}
4071340721
identity.$inject = [];
@@ -42213,11 +42221,11 @@ function setupModuleLoader(window) {
4221342221
* - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat".
4221442222
*/
4221542223
var version = {
42216-
full: '1.2.28', // all of these placeholder strings will be replaced by grunt's
42224+
full: '1.2.29-build.590+sha.e81b2f7', // all of these placeholder strings will be replaced by grunt's
4221742225
major: 1, // package task
4221842226
minor: 2,
42219-
dot: 28,
42220-
codeName: 'finnish-disembarkation'
42227+
dot: 29,
42228+
codeName: 'snapshot'
4222142229
};
4222242230

4222342231

@@ -44649,6 +44657,11 @@ function Browser(window, document, $log, $sniffer) {
4464944657
}
4465044658
}
4465144659

44660+
function getHash(url) {
44661+
var index = url.indexOf('#');
44662+
return index === -1 ? '' : url.substr(index + 1);
44663+
}
44664+
4465244665
/**
4465344666
* @private
4465444667
* Note: this method is used only by scenario runner
@@ -44760,8 +44773,10 @@ function Browser(window, document, $log, $sniffer) {
4476044773
}
4476144774
if (replace) {
4476244775
location.replace(url);
44763-
} else {
44776+
} else if (!sameBase) {
4476444777
location.href = url;
44778+
} else {
44779+
location.hash = getHash(url);
4476544780
}
4476644781
}
4476744782
return self;
@@ -49516,6 +49531,10 @@ function stripHash(url) {
4951649531
return index == -1 ? url : url.substr(0, index);
4951749532
}
4951849533

49534+
function trimEmptyHash(url) {
49535+
return url.replace(/(#.+)|#$/, '$1');
49536+
}
49537+
4951949538

4952049539
function stripFile(url) {
4952149540
return url.substr(0, stripHash(url).lastIndexOf('/') + 1);
@@ -50172,10 +50191,11 @@ function $LocationProvider(){
5017250191
// update browser
5017350192
var changeCounter = 0;
5017450193
$rootScope.$watch(function $locationWatch() {
50175-
var oldUrl = $browser.url();
50194+
var oldUrl = trimEmptyHash($browser.url());
50195+
var newUrl = trimEmptyHash($location.absUrl());
5017650196
var currentReplace = $location.$$replace;
5017750197

50178-
if (!changeCounter || oldUrl != $location.absUrl()) {
50198+
if (!changeCounter || oldUrl != newUrl) {
5017950199
changeCounter++;
5018050200
$rootScope.$evalAsync(function() {
5018150201
if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).
@@ -55774,37 +55794,12 @@ function limitToFilter(){
5577455794
limit = int(limit);
5577555795
}
5577655796

55777-
if (isString(input)) {
55778-
//NaN check on limit
55779-
if (limit) {
55780-
return limit >= 0 ? input.slice(0, limit) : input.slice(limit, input.length);
55781-
} else {
55782-
return "";
55783-
}
55784-
}
55785-
55786-
var out = [],
55787-
i, n;
55788-
55789-
// if abs(limit) exceeds maximum length, trim it
55790-
if (limit > input.length)
55791-
limit = input.length;
55792-
else if (limit < -input.length)
55793-
limit = -input.length;
55794-
55795-
if (limit > 0) {
55796-
i = 0;
55797-
n = limit;
55797+
//NaN check on limit
55798+
if (limit) {
55799+
return limit > 0 ? input.slice(0, limit) : input.slice(limit);
5579855800
} else {
55799-
i = input.length + limit;
55800-
n = input.length;
55801+
return isString(input) ? "" : [];
5580155802
}
55802-
55803-
for (; i<n; i++) {
55804-
out.push(input[i]);
55805-
}
55806-
55807-
return out;
5580855803
};
5580955804
}
5581055805

@@ -60077,7 +60072,7 @@ var ngIfDirective = ['$animate', function($animate) {
6007760072
<select ng-model="template" ng-options="t.name for t in templates">
6007860073
<option value="">(blank)</option>
6007960074
</select>
60080-
url of the template: <tt>{{template.url}}</tt>
60075+
url of the template: <code>{{template.url}}</code>
6008160076
<hr/>
6008260077
<div class="slide-animate-container">
6008360078
<div class="slide-animate" ng-include="template.url"></div>

dist/scripts/api-console.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,9 @@
17251725
/* jshint camelcase: false */
17261726
var authorizationGrants = $scope.$parent.securitySchemes.oauth_2_0.settings.authorizationGrants;
17271727

1728+
$scope.scopes = $scope.$parent.securitySchemes.oauth_2_0.settings.scopes;
1729+
$scope.credentials.scopes = {};
1730+
17281731
if (authorizationGrants) {
17291732
$scope.grants = $scope.grants.filter(function (el) {
17301733
return authorizationGrants.indexOf(el.value) > -1;
@@ -2234,7 +2237,7 @@
22342237
accessTokenUri: this.scheme.settings.accessTokenUri,
22352238
authorizationUri: this.scheme.settings.authorizationUri,
22362239
redirectUri: RAML.Settings.oauth2RedirectUri,
2237-
scopes: this.scheme.settings.scopes
2240+
scopes: this.credentials.scopes ? Object.keys(this.credentials.scopes) : []
22382241
});
22392242
var grantType = this.credentials.grant;
22402243

@@ -5543,6 +5546,15 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
55435546
" <input required=\"true\" type=\"password\" name=\"password\" class=\"raml-console-sidebar-input raml-console-sidebar-security-field\" ng-model=\"credentials.password\" ng-change=\"onChange()\"/>\n" +
55445547
" <span class=\"raml-console-field-validation-error\"></span>\n" +
55455548
" </p>\n" +
5549+
"\n" +
5550+
" <p class=\"raml-console-sidebar-input-container\">\n" +
5551+
" <label for=\"password\" class=\"raml-console-sidebar-label\">Scopes</label>\n" +
5552+
" <ol class=\"raml-console-sidebar-oauth-scopes\">\n" +
5553+
" <li ng-repeat=\"scope in scopes\">\n" +
5554+
" <input type=\"checkbox\" ng-model=\"credentials.scopes[scope]\"> {{scope}}\n" +
5555+
" </li>\n" +
5556+
" </ol>\n" +
5557+
" </p>\n" +
55465558
"</div>\n"
55475559
);
55485560

dist/styles/api-console-dark-theme.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,6 +3605,13 @@ a.raml-console-resource-path-active {
36053605
color: red;
36063606
}
36073607

3608+
.raml-console-sidebar-oauth-scopes {
3609+
list-style-type: none;
3610+
padding-left: 0;
3611+
font-size: 14px;
3612+
margin-top: -10px !important;
3613+
}
3614+
36083615
/* ==========================================================================
36093616
Helper classes
36103617
========================================================================== */

dist/styles/api-console-light-theme.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,6 +3605,13 @@ a.raml-console-resource-path-active {
36053605
color: red;
36063606
}
36073607

3608+
.raml-console-sidebar-oauth-scopes {
3609+
list-style-type: none;
3610+
padding-left: 0;
3611+
font-size: 14px;
3612+
margin-top: -10px !important;
3613+
}
3614+
36083615
/* ==========================================================================
36093616
Helper classes
36103617
========================================================================== */

src/app/security/oauth2.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
/* jshint camelcase: false */
4242
var authorizationGrants = $scope.$parent.securitySchemes.oauth_2_0.settings.authorizationGrants;
4343

44+
$scope.scopes = $scope.$parent.securitySchemes.oauth_2_0.settings.scopes;
45+
$scope.credentials.scopes = {};
46+
4447
if (authorizationGrants) {
4548
$scope.grants = $scope.grants.filter(function (el) {
4649
return authorizationGrants.indexOf(el.value) > -1;

src/app/security/oauth2.tpl.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,13 @@
2929
<input required="true" type="password" name="password" class="raml-console-sidebar-input raml-console-sidebar-security-field" ng-model="credentials.password" ng-change="onChange()"/>
3030
<span class="raml-console-field-validation-error"></span>
3131
</p>
32+
33+
<p class="raml-console-sidebar-input-container">
34+
<label for="password" class="raml-console-sidebar-label">Scopes</label>
35+
<ol class="raml-console-sidebar-oauth-scopes">
36+
<li ng-repeat="scope in scopes">
37+
<input type="checkbox" ng-model="credentials.scopes[scope]"> {{scope}}
38+
</li>
39+
</ol>
40+
</p>
3241
</div>

src/common/client/auth_strategies/oauth2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
accessTokenUri: this.scheme.settings.accessTokenUri,
1414
authorizationUri: this.scheme.settings.authorizationUri,
1515
redirectUri: RAML.Settings.oauth2RedirectUri,
16-
scopes: this.scheme.settings.scopes
16+
scopes: this.credentials.scopes ? Object.keys(this.credentials.scopes) : []
1717
});
1818
var grantType = this.credentials.grant;
1919

src/scss/_sidebar.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,3 +1144,10 @@
11441144
font-size: 13px;
11451145
color: red;
11461146
}
1147+
1148+
.sidebar-oauth-scopes {
1149+
list-style-type: none;
1150+
padding-left: 0;
1151+
font-size: 14px;
1152+
margin-top: -10px !important;
1153+
}

0 commit comments

Comments
 (0)