SAML; Dashboard

This commit is contained in:
garrettmills
2020-05-03 20:16:54 -05:00
parent e3ecfb0d37
commit c389e151b5
1778 changed files with 148410 additions and 82 deletions

View File

@@ -0,0 +1,35 @@
const { Controller } = require('libflitter')
class GroupsController extends Controller {
static get services() {
return [...super.services, 'cobalt', 'models']
}
async get_listing(req, res, next) {
const Group = this.models.get('ldap:Group')
const groups = await Group.find()
const formatted = groups.map(x => {
return {
name: x.name,
count: x.user_ids.length,
}
})
return this.cobalt.listing(req, res, {
title: 'LDAP Groups', // TODO generalize this for SAML/OAuth2
columns: [
{
name: 'Group Name',
field: 'name',
},
{
name: '# Users',
field: 'count',
},
],
data: formatted,
})
}
}
module.exports = exports = GroupsController

View File

@@ -0,0 +1,16 @@
const { Controller } = require('libflitter')
class ProfileController extends Controller {
static get services() {
return [...super.services, 'Vue']
}
async get_page(req, res, next) {
return res.page('dash:profile:main', {
...this.Vue.data(),
...this.Vue.session(req)
})
}
}
module.exports = exports = ProfileController

View File

@@ -0,0 +1,46 @@
const { Controller } = require('libflitter')
class SAMLController extends Controller {
static get services() {
return [...super.services, 'cobalt', 'models']
}
async get_sp_listing(req, res, next) {
const ServiceProvider = this.models.get('saml:ServiceProvider')
const service_providers = await ServiceProvider.find()
const formatted = service_providers.map(x => {
return {
name: x.name,
entity_id: x.entity_id,
acs_url: x.acs_url,
has_slo: !!x.slo_url,
}
})
return this.cobalt.listing(req, res, {
title: 'SAML Service Providers',
columns: [
{
name: 'Provider Name',
field: 'name',
},
{
name: 'Entity ID',
field: 'entity_id',
},
{
name: 'Has SLO?',
field: 'has_slo',
renderer: 'boolean',
},
{
name: 'ACS URL',
field: 'acs_url',
},
],
data: formatted,
})
}
}
module.exports = exports = SAMLController

View File

@@ -0,0 +1,47 @@
const { Controller } = require('libflitter')
class UsersController extends Controller {
static get services() {
return [...super.services, 'models', 'cobalt']
}
async get_listing(req, res, next) {
// Columns: Username, First, Last, E-Mail
const User = this.models.get('auth:User')
const users = await User.find()
const formatted = users.map(x => {
return {
username: x.uid,
first: x.first_name,
last: x.last_name,
email: x.email,
}
})
return this.cobalt.listing(req, res, {
title: 'Users',
columns: [
{
name: 'Username',
field: 'username',
},
{
name: 'First Name',
field: 'first',
},
{
name: 'Last Name',
field: 'last',
},
{
name: 'E-Mail Address',
field: 'email',
},
],
data: formatted,
})
}
}
module.exports = exports = UsersController