Skip to content

Commit f8b37f7

Browse files
committed
Merge pull request #104 from mulesoft/bugs/remove-client-secret-for-implicit
Removing ClientSecret field oAuth 2.0 - implicit
2 parents dbf1868 + da303fb commit f8b37f7

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

dist/examples/leagues.raml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ securitySchemes:
3434
settings:
3535
authorizationUri: https://github.com/login/oauth/authorize
3636
accessTokenUri: https://github.com/login/oauth/access_token
37-
authorizationGrants: [ code ]
37+
authorizationGrants: [ code, token ]
3838
scopes:
3939
- "user"
4040
- "user:email"

dist/scripts/api-console.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,10 @@
17001700
return $scope.credentials.grant === 'owner';
17011701
};
17021702

1703+
$scope.isImplicitEnabled = function () {
1704+
return $scope.credentials.grant === 'token';
1705+
};
1706+
17031707
$scope.grants = [
17041708
{
17051709
label: 'Implicit',
@@ -2225,7 +2229,7 @@
22252229
};
22262230

22272231
Oauth2.prototype.authenticate = function(options, done) {
2228-
var githubAuth = new ClientOAuth2({
2232+
var auth = new ClientOAuth2({
22292233
clientId: this.credentials.clientId,
22302234
clientSecret: this.credentials.clientSecret,
22312235
accessTokenUri: this.scheme.settings.accessTokenUri,
@@ -2237,7 +2241,7 @@
22372241

22382242
if (grantType === 'token' || grantType === 'code') {
22392243
window.oauth2Callback = function (uri) {
2240-
githubAuth[grantType].getToken(uri, function (err, user, raw) {
2244+
auth[grantType].getToken(uri, function (err, user, raw) {
22412245
if (err) {
22422246
done(raw);
22432247
}
@@ -2250,11 +2254,11 @@
22502254
});
22512255
};
22522256
//// TODO: Find a way to handle 404
2253-
window.open(githubAuth[grantType].getUri());
2257+
window.open(auth[grantType].getUri());
22542258
}
22552259

22562260
if (grantType === 'owner') {
2257-
githubAuth.owner.getToken(this.credentials.username, this.credentials.password, function (err, user, raw) {
2261+
auth.owner.getToken(this.credentials.username, this.credentials.password, function (err, user, raw) {
22582262
if (err) {
22592263
done(raw);
22602264
}
@@ -2268,7 +2272,7 @@
22682272
}
22692273

22702274
if (grantType === 'credentials') {
2271-
githubAuth.credentials.getToken(function (err, user, raw) {
2275+
auth.credentials.getToken(function (err, user, raw) {
22722276
if (err) {
22732277
done(raw);
22742278
}
@@ -5525,7 +5529,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
55255529
" <span class=\"raml-console-field-validation-error\"></span>\n" +
55265530
" </p>\n" +
55275531
"\n" +
5528-
" <p class=\"raml-console-sidebar-input-container\">\n" +
5532+
" <p class=\"raml-console-sidebar-input-container\" ng-if=\"!isImplicitEnabled()\">\n" +
55295533
" <label for=\"clientSecret\" class=\"raml-console-sidebar-label\">Client Secret <span class=\"raml-console-side-bar-required-field\">*</span></label>\n" +
55305534
" <input required=\"true\" type=\"password\" name=\"clientSecret\" class=\"raml-console-sidebar-input raml-console-sidebar-security-field\" ng-model=\"credentials.clientSecret\" ng-change=\"onChange()\"/>\n" +
55315535
" <span class=\"raml-console-field-validation-error\"></span>\n" +

src/app/security/oauth2.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
return $scope.credentials.grant === 'owner';
1616
};
1717

18+
$scope.isImplicitEnabled = function () {
19+
return $scope.credentials.grant === 'token';
20+
};
21+
1822
$scope.grants = [
1923
{
2024
label: 'Implicit',

src/app/security/oauth2.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<span class="raml-console-field-validation-error"></span>
1313
</p>
1414

15-
<p class="raml-console-sidebar-input-container">
15+
<p class="raml-console-sidebar-input-container" ng-if="!isImplicitEnabled()">
1616
<label for="clientSecret" class="raml-console-sidebar-label">Client Secret <span class="raml-console-side-bar-required-field">*</span></label>
1717
<input required="true" type="password" name="clientSecret" class="raml-console-sidebar-input raml-console-sidebar-security-field" ng-model="credentials.clientSecret" ng-change="onChange()"/>
1818
<span class="raml-console-field-validation-error"></span>

src/common/client/auth_strategies/oauth2.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
};
88

99
Oauth2.prototype.authenticate = function(options, done) {
10-
var githubAuth = new ClientOAuth2({
10+
var auth = new ClientOAuth2({
1111
clientId: this.credentials.clientId,
1212
clientSecret: this.credentials.clientSecret,
1313
accessTokenUri: this.scheme.settings.accessTokenUri,
@@ -19,7 +19,7 @@
1919

2020
if (grantType === 'token' || grantType === 'code') {
2121
window.oauth2Callback = function (uri) {
22-
githubAuth[grantType].getToken(uri, function (err, user, raw) {
22+
auth[grantType].getToken(uri, function (err, user, raw) {
2323
if (err) {
2424
done(raw);
2525
}
@@ -32,11 +32,11 @@
3232
});
3333
};
3434
//// TODO: Find a way to handle 404
35-
window.open(githubAuth[grantType].getUri());
35+
window.open(auth[grantType].getUri());
3636
}
3737

3838
if (grantType === 'owner') {
39-
githubAuth.owner.getToken(this.credentials.username, this.credentials.password, function (err, user, raw) {
39+
auth.owner.getToken(this.credentials.username, this.credentials.password, function (err, user, raw) {
4040
if (err) {
4141
done(raw);
4242
}
@@ -50,7 +50,7 @@
5050
}
5151

5252
if (grantType === 'credentials') {
53-
githubAuth.credentials.getToken(function (err, user, raw) {
53+
auth.credentials.getToken(function (err, user, raw) {
5454
if (err) {
5555
done(raw);
5656
}

0 commit comments

Comments
 (0)