Add MFA support

This commit is contained in:
garrettmills
2020-04-22 16:56:39 -05:00
parent d68d5141c8
commit e3ecfb0d37
30 changed files with 802 additions and 75 deletions

View File

@@ -17,6 +17,13 @@ class Forms extends FormController {
}),
})
}
async logout_provider_present_success(req, res, next) {
return this.Vue.auth_message(res, {
message: 'You have been successfully logged out.',
next_destination: '/',
})
}
}
module.exports = exports = Forms

View File

@@ -0,0 +1,44 @@
const { Controller } = require('libflitter')
class MFAController extends Controller {
static get services() {
return [...super.services, 'Vue', 'configs']
}
async setup(req, res, next) {
if ( req.user.mfa_enabled ) {
// Already set up!
return this.Vue.auth_message(res, {
message: 'It looks like your account is already set up for multi-factor authentication. Unable to continue with MFA setup.',
next_destination: '/', // TODO update this
button_text: 'Okay',
})
}
// Display the token setup page
return res.page('auth:mfa:setup', {
...this.Vue.data()
})
}
async challenge(req, res, next) {
if ( !req.user.mfa_enabled ) {
return this.Vue.auth_message(res, {
message: 'Your account is not configured to use multi-factor authentication. Would you like to configure it now?',
next_destination: '/auth/mfa/setup',
button_text: 'Setup MFA',
})
}
if ( !req.session.auth.in_dmz ) {
return res.redirect(req.session.auth.flow)
}
// Display the MFA challenge page
return res.page('auth:mfa:challenge', {
...this.Vue.data()
})
}
}
module.exports = exports = MFAController