Centralize logout method; delete OIDC sessions on logout

This commit is contained in:
2020-08-23 14:42:00 -05:00
parent d9c76e8dde
commit ff5ed6b39a
5 changed files with 34 additions and 8 deletions

View File

@@ -154,6 +154,19 @@ class User extends AuthUser {
return Group.find({ active: true, user_ids: this.id })
}
async oidc_sessions() {
const Session = this.models.get('openid:Session')
return Session.find({ 'payload.account': this.id })
}
async logout(request) {
for ( const session of (await this.oidc_sessions()) ) {
await session.delete()
}
this.get_provider().logout(request)
}
async to_ldap(iam_targets = []) {
const Policy = this.models.get('iam:Policy')

View File

@@ -0,0 +1,17 @@
const { Model } = require('flitter-orm')
class SessionModel extends Model {
static get services() {
return [...super.services, 'models']
}
static get schema() {
return {
payload: {
account: String,
},
}
}
}
module.exports = exports = SessionModel