|
|
@ -15,7 +15,6 @@ const striptags = require('striptags');
|
|
|
|
|
|
|
|
|
|
|
|
const oauth2orize = require('oauth2orize');
|
|
|
|
const oauth2orize = require('oauth2orize');
|
|
|
|
const passport = require('passport');
|
|
|
|
const passport = require('passport');
|
|
|
|
const ensureLoggedIn = require('connect-ensure-login');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const generatePassword = require('password-generator');
|
|
|
|
const generatePassword = require('password-generator');
|
|
|
|
|
|
|
|
|
|
|
@ -62,16 +61,21 @@ class OAuth2Service extends SiteService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
attachRoutes (app) {
|
|
|
|
attachRoutes (app) {
|
|
|
|
|
|
|
|
const { session: sessionService } = this.dtp.services;
|
|
|
|
|
|
|
|
const requireLogin = sessionService.authCheckMiddleware({
|
|
|
|
|
|
|
|
requireAuth: true,
|
|
|
|
|
|
|
|
loginUri: '/welcome/login'
|
|
|
|
|
|
|
|
});
|
|
|
|
app.get(
|
|
|
|
app.get(
|
|
|
|
'/oauth2/authorize',
|
|
|
|
'/oauth2/authorize',
|
|
|
|
ensureLoggedIn.ensureLoggedIn('/welcome/login'),
|
|
|
|
requireLogin,
|
|
|
|
this.server.authorize(this.processAuthorize.bind(this)),
|
|
|
|
this.server.authorize(this.processAuthorize.bind(this)),
|
|
|
|
this.renderAuthorizeDialog.bind(this),
|
|
|
|
this.renderAuthorizeDialog.bind(this),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
app.post(
|
|
|
|
app.post(
|
|
|
|
'/oauth2/authorize/decision',
|
|
|
|
'/oauth2/authorize/decision',
|
|
|
|
ensureLoggedIn.ensureLoggedIn('/welcome/login'),
|
|
|
|
requireLogin,
|
|
|
|
this.server.decision(),
|
|
|
|
this.server.decision(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|