How to use @keystonejs/access-control - 5 common examples

To help you get started, we’ve selected a few @keystonejs/access-control examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keystonejs / keystone / packages / fields / src / types / Virtual / Implementation.js View on Github external
parseFieldAccess(args) {
    const parsedAccess = parseFieldAccess(args);
    const fieldDefaults = { create: false, update: false, delete: false };
    return Object.keys(parsedAccess).reduce((prev, schemaName) => {
      prev[schemaName] = { ...fieldDefaults, read: parsedAccess[schemaName].read };
      return prev;
    }, {});
  }
}
github keystonejs / keystone / packages / fields / src / Implementation.js View on Github external
parseFieldAccess(args) {
    return parseFieldAccess(args);
  }
github keystonejs / keystone / packages / keystone / lib / Keystone / index.js View on Github external
this.lists = {};
    this.listsArray = [];
    this.getListByKey = key => this.lists[key];
    this._extendedTypes = [];
    this._extendedQueries = [];
    this._extendedMutations = [];
    this._graphQLQuery = {};
    this._cookieSecret = cookieSecret;
    this._secureCookies = secureCookies;
    this._cookieMaxAge = cookieMaxAge;
    this._sessionStore = sessionStore;
    this.eventHandlers = { onConnect };
    this.registeredTypes = new Set();
    this._schemaNames = schemaNames;
    this.appVersion = appVersion;
    this.appVersion.access = parseCustomAccess({
      access: this.appVersion.access,
      schemaNames: this._schemaNames,
      defaultAccess: true,
    });

    if (adapters) {
      this.adapters = adapters;
      this.defaultAdapter = defaultAdapter;
    } else if (adapter) {
      this.adapters = { [adapter.constructor.name]: adapter };
      this.defaultAdapter = adapter.constructor.name;
    } else {
      throw new Error('No database adapter provided');
    }

    this.queryLimits = {
github keystonejs / keystone / packages / keystone / lib / Keystone / index.js View on Github external
const _parseAccess = obj => ({
      ...obj,
      access: parseCustomAccess({
        access: obj.access,
        schemaNames: this._schemaNames,
        defaultAccess: this.defaultAccess.custom,
      }),
    });
github keystonejs / keystone / packages / keystone / lib / List / index.js View on Github external
createManyMutationName: `create${_listQueryName}`,
      whereInputName: `${_itemQueryName}WhereInput`,
      whereUniqueInputName: `${_itemQueryName}WhereUniqueInput`,
      updateInputName: `${_itemQueryName}UpdateInput`,
      createInputName: `${_itemQueryName}CreateInput`,
      updateManyInputName: `${_listQueryName}UpdateInput`,
      createManyInputName: `${_listQueryName}CreateInput`,
      relateToManyInputName: `${_itemQueryName}RelateToManyInput`,
      relateToOneInputName: `${_itemQueryName}RelateToOneInput`,
    };

    this.adapterName = adapter.name;
    this.adapter = adapter.newListAdapter(this.key, adapterConfig);
    this._schemaNames = schemaNames;

    this.access = parseListAccess({
      schemaNames: this._schemaNames,
      listKey: key,
      access,
      defaultAccess: this.defaultAccess.list,
    });

    this.queryLimits = {
      maxResults: Infinity,
      ...queryLimits,
    };
    if (this.queryLimits.maxResults < 1) {
      throw new Error(`List ${label}'s queryLimits.maxResults can't be < 1`);
    }

    if (!['object', 'function', 'undefined'].includes(typeof cacheHint)) {
      throw new Error(`List ${label}'s cacheHint must be an object or function`);

@keystonejs/access-control

KeystoneJS Access Control parsing and validating utilities.

MIT
Latest version published 3 years ago

Package Health Score

63 / 100
Full package analysis