Skip to content

Commit

Permalink
Merge pull request #9 from zxan1285/node-uni
Browse files Browse the repository at this point in the history
Node 4/8 version
  • Loading branch information
fyockm authored Apr 17, 2018
2 parents 68175cd + cecf1f1 commit cccfe9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ node_modules
.DS_Store

npm-debug.log

.idea
18 changes: 16 additions & 2 deletions build/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var expressJwt = require('express-jwt');
var rsaValidation = require('auth0-api-jwt-rsa-validation');
var ejs = require('ejs');
var app = new (require('express'))();
var crypto = require('crypto');

function resolveWebtaskAPIHost(host, context) {
if (host.indexOf('us.webtask.io') > 0) {
Expand All @@ -18,6 +19,18 @@ function resolveWebtaskAPIHost(host, context) {
return 'https://sandbox-eu.it.auth0.com';
}

if (host.indexOf('us8.webtask.io') > 0) {
return 'https://sandbox8-us.it.auth0.com';
}

if (host.indexOf('au8.webtask.io') > 0) {
return 'https://sandbox8-au.it.auth0.com';
}

if (host.indexOf('eu8.webtask.io') > 0) {
return 'https://sandbox8-eu.it.auth0.com';
}

var wtUrl = context.secrets.WT_URL;

if (wtUrl && wtUrl.indexOf('api/run') >= 0 ) {
Expand Down Expand Up @@ -45,12 +58,13 @@ app.use(function (req, res, next) {

app.get('/', function (req, res) {
res.redirect([
req.webtaskContext.data.AUTH0_RTA || 'https://auth0.auth0.com', '/i/oauth2/authorize',
req.webtaskContext.data.AUTH0_RTA || 'https://auth0.auth0.com', '/authorize',
'?client_id=', req.baseUrl,
'&response_type=token&expiration=86400000&response_mode=form_post',
'&scope=', encodeURIComponent('openid profile'),
'&redirect_uri=', req.baseUrl,
'&audience=', req.audience
'&audience=', req.audience,
'&nonce=' + encodeURIComponent(crypto.randomBytes(16).toString('hex'))
].join(''));
});

Expand Down

0 comments on commit cccfe9a

Please sign in to comment.