Merge pull request #1648 from estiller/master

Support additional query parameters during OAuth2 authorization process
This commit is contained in:
Tony Tam
2015-12-09 14:36:38 -08:00
4 changed files with 14 additions and 2 deletions

3
dist/index.html vendored
View File

@@ -51,7 +51,8 @@
clientSecret: "your-client-secret-if-required", clientSecret: "your-client-secret-if-required",
realm: "your-realms", realm: "your-realms",
appName: "your-app-name", appName: "your-app-name",
scopeSeparator: "," scopeSeparator: ",",
additionalQueryStringParams: {}
}); });
} }

View File

@@ -7,6 +7,7 @@ var oauth2KeyName;
var redirect_uri; var redirect_uri;
var clientSecret; var clientSecret;
var scopeSeparator; var scopeSeparator;
var additionalQueryStringParams;
function handleLogin() { function handleLogin() {
var scopes = []; var scopes = [];
@@ -156,6 +157,9 @@ function handleLogin() {
url += '&client_id=' + encodeURIComponent(clientId); url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator)); url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator));
url += '&state=' + encodeURIComponent(state); url += '&state=' + encodeURIComponent(state);
for (var key in additionalQueryStringParams) {
url += '&' + key + '=' + encodeURIComponent(additionalQueryStringParams[key]);
}
window.open(url); window.open(url);
}); });
@@ -190,6 +194,7 @@ function initOAuth(opts) {
clientSecret = (o.clientSecret||null); clientSecret = (o.clientSecret||null);
realm = (o.realm||errors.push('missing realm')); realm = (o.realm||errors.push('missing realm'));
scopeSeparator = (o.scopeSeparator||' '); scopeSeparator = (o.scopeSeparator||' ');
additionalQueryStringParams = (o.additionalQueryStringParams||{});
if(errors.length > 0){ if(errors.length > 0){
log('auth unable initialize oauth: ' + errors); log('auth unable initialize oauth: ' + errors);

View File

@@ -7,6 +7,7 @@ var oauth2KeyName;
var redirect_uri; var redirect_uri;
var clientSecret; var clientSecret;
var scopeSeparator; var scopeSeparator;
var additionalQueryStringParams;
function handleLogin() { function handleLogin() {
var scopes = []; var scopes = [];
@@ -156,6 +157,9 @@ function handleLogin() {
url += '&client_id=' + encodeURIComponent(clientId); url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator)); url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator));
url += '&state=' + encodeURIComponent(state); url += '&state=' + encodeURIComponent(state);
for (var key in additionalQueryStringParams) {
url += '&' + key + '=' + encodeURIComponent(additionalQueryStringParams[key]);
}
window.open(url); window.open(url);
}); });
@@ -190,6 +194,7 @@ function initOAuth(opts) {
clientSecret = (o.clientSecret||null); clientSecret = (o.clientSecret||null);
realm = (o.realm||errors.push('missing realm')); realm = (o.realm||errors.push('missing realm'));
scopeSeparator = (o.scopeSeparator||' '); scopeSeparator = (o.scopeSeparator||' ');
additionalQueryStringParams = (o.additionalQueryStringParams||{});
if(errors.length > 0){ if(errors.length > 0){
log('auth unable initialize oauth: ' + errors); log('auth unable initialize oauth: ' + errors);

View File

@@ -51,7 +51,8 @@
clientSecret: "your-client-secret-if-required", clientSecret: "your-client-secret-if-required",
realm: "your-realms", realm: "your-realms",
appName: "your-app-name", appName: "your-app-name",
scopeSeparator: "," scopeSeparator: ",",
additionalQueryStringParams: {}
}); });
} }