diff --git a/app/controllers/admin/core-node.js b/app/controllers/admin/core-node.js index d4eb2af..e10b0d1 100644 --- a/app/controllers/admin/core-node.js +++ b/app/controllers/admin/core-node.js @@ -46,6 +46,10 @@ class CoreNodeController extends SiteController { return next(error); } + const CORE_SCHEME = process.env.DTP_CORE_AUTH_SCHEME || 'https'; + res.locals.siteConfig = Object.assign({ }, this.dtp.config.site); + res.locals.siteConfig.coreAuth.redirectUri = `${CORE_SCHEME}://${this.dtp.config.site.domain}/auth/core/${res.locals.core._id}/welcome`; + try { res.locals.txConnect = await coreNodeService.sendRequest(res.locals.core, { method: 'POST', @@ -53,7 +57,7 @@ class CoreNodeController extends SiteController { tokenized: true, body: { version: this.dtp.pkg.version, - site: this.dtp.config.site, + site: res.locals.siteConfig, }, }); diff --git a/app/services/core-node.js b/app/services/core-node.js index fa579fa..22699ff 100644 --- a/app/services/core-node.js +++ b/app/services/core-node.js @@ -99,7 +99,8 @@ class CoreNodeService extends SiteService { const authorizationHost = `${core.address.host}:${core.address.port}`; const authorizationURL = `${AUTH_SCHEME}://${authorizationHost}/oauth2/authorize`; const tokenURL = `${AUTH_SCHEME}://${authorizationHost}/oauth2/token`; - const callbackURL = `${AUTH_SCHEME}://${process.env.DTP_SITE_DOMAIN}/auth/core/callback`; + const callbackURL = `${AUTH_SCHEME}://${process.env.DTP_SITE_DOMAIN}/auth/core/${core._id}/welcome`; + const coreAuthStrategy = new OAuth2Strategy( { authorizationURL, @@ -126,6 +127,7 @@ class CoreNodeService extends SiteService { host: core.address.host, port: core.address.port, clientID: core.oauth.clientId.toString(), + callbackURL, }); passport.use(coreAuthStrategyName, coreAuthStrategy); } diff --git a/app/services/oauth2.js b/app/services/oauth2.js index c17306d..1118052 100644 --- a/app/services/oauth2.js +++ b/app/services/oauth2.js @@ -86,6 +86,7 @@ class OAuth2Service extends SiteService { } async renderAuthorizeDialog (req, res) { + res.locals.oauth2 = req.oauth2; res.locals.transactionID = req.oauth2.transactionID; res.locals.client = req.oauth2.client; res.render('oauth2/authorize-dialog'); diff --git a/app/views/admin/core-node/connect.pug b/app/views/admin/core-node/connect.pug index 0ef34f7..3f438a1 100644 --- a/app/views/admin/core-node/connect.pug +++ b/app/views/admin/core-node/connect.pug @@ -9,16 +9,6 @@ block content .uk-card-body .uk-margin p You are registering #{site.name} with a DTP Core node. If accepted, this will enable members of that community to make use of the services provided by #{site.name} as an authenticated member of this site. - p Please make sure the information displayed is as you want it to be displayed in your Core Directory entry. - - .uk-margin - - var { version, name } = pkg; - label.uk-form-label Package Information - textarea(style="font-family: Courier New, fixed; font-size: 12px;", rows= 4, disabled).uk-textarea= JSON.stringify({ name, version }, null, 2) - - .uk-margin - label.uk-form-label Site Information - textarea(style="font-family: Courier New, fixed; font-size: 12px;", rows= 10, disabled).uk-textarea= JSON.stringify(site, null, 2) .uk-margin label(for="host").uk-form-label Core Host diff --git a/app/views/oauth2/authorize-dialog.pug b/app/views/oauth2/authorize-dialog.pug new file mode 100644 index 0000000..9785bd4 --- /dev/null +++ b/app/views/oauth2/authorize-dialog.pug @@ -0,0 +1,5 @@ +extends ../layouts/main +block content + + h1 OAuth2 Authorization + pre= JSON.stringify(oauth2, null, 2) \ No newline at end of file diff --git a/config/site.js b/config/site.js index f372528..884f979 100644 --- a/config/site.js +++ b/config/site.js @@ -12,6 +12,6 @@ module.exports = { company: process.env.DTP_SITE_COMPANY || 'Digital Telepresence, LLC', coreAuth: { scopes: ['account-read', 'event-write'], - redirectUri: '/auth/core/callback', + redirectUri: `/auth/core/callback`, }, }; \ No newline at end of file