Browse Source

wip push to Core

pull/1/head
Rob Colbert 3 years ago
parent
commit
7bee921a1a
  1. 6
      app/controllers/admin/core-node.js
  2. 4
      app/services/core-node.js
  3. 1
      app/services/oauth2.js
  4. 10
      app/views/admin/core-node/connect.pug
  5. 5
      app/views/oauth2/authorize-dialog.pug
  6. 2
      config/site.js

6
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,
},
});

4
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);
}

1
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');

10
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

5
app/views/oauth2/authorize-dialog.pug

@ -0,0 +1,5 @@
extends ../layouts/main
block content
h1 OAuth2 Authorization
pre= JSON.stringify(oauth2, null, 2)

2
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`,
},
};
Loading…
Cancel
Save