Add support for OpenID connect!!

This commit is contained in:
garrettmills
2020-08-13 01:56:33 -05:00
parent 455e78bf14
commit d75944644a
21 changed files with 1313 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
const { Model } = require('flitter-orm')
const bcrypt = require('bcrypt')
const uuid = require('uuid/v4')
const uuid = require('uuid').v4
class AppPasswordModel extends Model {
static get schema() {

View File

@@ -1,7 +1,7 @@
const { Model } = require('flitter-orm')
const speakeasy = require('speakeasy')
const MFARecoveryCode = require('./MFARecoveryCode.model')
const uuid = require('uuid/v4')
const uuid = require('uuid').v4
class MFATokenModel extends Model {
static get services() {

View File

@@ -6,7 +6,7 @@ const MFAToken = require('./MFAToken.model')
const PasswordReset = require('./PasswordReset.model')
const AppAuthorization = require('./AppAuthorization.model')
const AppPassword = require('./AppPassword.model')
const uuid = require('uuid/v4')
const uuid = require('uuid').v4
/*
* Auth user model. This inherits fields and methods from the default
@@ -197,6 +197,37 @@ class User extends AuthUser {
get dn() {
return LDAP.parseDN(`uid=${this.uid},${this.ldap_server.auth_dn().format(this.configs.get('ldap:server.format'))}`)
}
// The following are used by OpenID connect
async claims(use, scope) {
return {
sub: this.id,
email: this.email,
email_verified: true, // TODO
family_name: this.last_name,
given_name: this.first_name,
locale: 'en_US', // TODO
name: `${this.first_name} ${this.last_name}`,
preferred_username: this.uid,
username: this.uid,
}
}
static async findByLogin(login) {
return this.findOne({
active: true,
uid: login,
})
}
static async findAccount(ctx, id, token) {
return this.findById(id)
}
get accountId() {
return this.id
}
}
module.exports = exports = User