System permissions for app access (#4004)

* Pass relations through schema, instead of individual reads

* Fetch field transforms upfront

* Fix length check

* List if user has app access or not in accountability

* Load permissions up front, merge app access minimal permissions

* Show app access required permissions in permissions overview

* Show system minimal permissions in permissions detail

* Fix app access check in authenticate for jwt use

* Fix minimal permissions for presets

* Remove /permissions/me in favor of root use w/ permissions

* Fix logical nested OR in an AND

* Use root permissions endpoint with filter instead of /me

* Allow filter query on /permissions

* Add system minimal app access permissions into result of /permissions

* Remove stray console log

* Remove stray console.dir

* Set current role as role for minimal permissions

* Fix no-permissions state for user detail

* Add filter items function that allows altering existing result set
This commit is contained in:
Rijk van Zanten
2021-02-11 12:50:56 -05:00
committed by GitHub
parent 8c1402fb88
commit b7d87e581a
55 changed files with 897 additions and 524 deletions

View File

@@ -2,6 +2,7 @@ import env from '../../../env';
import logger from '../../../logger';
import installDatabase from '../../../database/seeds/run';
import runMigrations from '../../../database/migrations/run';
import { getSchema } from '../../../utils/get-schema';
import { nanoid } from 'nanoid';
export default async function bootstrap() {
@@ -22,7 +23,7 @@ export default async function bootstrap() {
await installDatabase(database);
const schema = await schemaInspector.overview();
const schema = await getSchema();
logger.info('Setting up first admin role...');
const rolesService = new RolesService({ schema });

View File

@@ -1,5 +1,7 @@
import { getSchema } from '../../../utils/get-schema';
export default async function rolesCreate({ name, admin }: any) {
const { default: database, schemaInspector } = require('../../../database/index');
const { default: database } = require('../../../database/index');
const { RolesService } = require('../../../services/roles');
if (!name) {
@@ -8,7 +10,7 @@ export default async function rolesCreate({ name, admin }: any) {
}
try {
const schema = await schemaInspector.overview();
const schema = await getSchema();
const service = new RolesService({ schema: schema, knex: database });
const id = await service.create({ name, admin_access: admin });

View File

@@ -1,3 +1,5 @@
import { getSchema } from '../../../utils/get-schema';
export default async function usersCreate({ email, password, role }: any) {
const { default: database, schemaInspector } = require('../../../database/index');
const { UsersService } = require('../../../services/users');
@@ -8,7 +10,7 @@ export default async function usersCreate({ email, password, role }: any) {
}
try {
const schema = await schemaInspector.overview();
const schema = await getSchema();
const service = new UsersService({ schema, knex: database });
const id = await service.create({ email, password, role, status: 'active' });