
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
The @gapi/ac library is an access control utility designed for use in GraphQL applications. It helps developers manage permissions for different user roles, such as GUEST, USER, and ADMIN, across various GraphQL actions like queries, mutations, subscripti
The @gapi/ac library is an access control utility designed for use in GraphQL applications. It helps developers manage permissions for different user roles, such as GUEST, USER, and ADMIN, across various GraphQL actions like queries, mutations, subscriptions, and events. It allows developers to define and enforce rules for which roles can access or manipulate specific resources in the system.
Key features include:
Role-based permissions: You can define access control based on user roles (like GUEST, USER, ADMIN) and control what actions they can perform. GraphQL-focused: Specifically built to handle permissioning in GraphQL, making it a natural fit for applications using this API standard. Filtering data: The library allows filtering data based on user roles, so different roles see only the data they are authorized to access. For example, an admin might have access to query a certain data field (status), while a regular user might have partial access, where some attributes of the response are filtered out based on the permission definitions.
import { AccessControl, Union } from '@gapi/ac';
enum GraphqlActions {
query,
mutation,
subscription,
event,
}
enum Roles {
GUEST,
USER,
ADMIN,
}
interface IQuery {
status: {
status: number;
};
}
const Permissions: Union<typeof Roles, IQuery, typeof GraphqlActions> = {
GUEST: {
status: {
query: {
enabled: false,
},
},
},
USER: {
status: {
query: {
enabled: true,
attributes: {
status: false,
},
},
},
},
ADMIN: {
status: {
query: {
enabled: true,
},
},
},
};
const ac = new AccessControl<
typeof Roles,
IQuery & ISubscription & IMutation,
typeof GraphqlActions
>(Permissions);
const canAdminQueryStatus = ac.can('ADMIN', 'query', 'status');
const canAdminQueryStatus = ac.can('USER', 'query', 'status');
if (!canAdminQueryStatus) {
throw new Error('You are not authorized');
}
const data = { status: 200 };
const filteredData = await ac.filter('USER', 'query', 'status')(data);
filteredData; // { status: null }
FAQs
The @gapi/ac library is an access control utility designed for use in GraphQL applications. It helps developers manage permissions for different user roles, such as GUEST, USER, and ADMIN, across various GraphQL actions like queries, mutations, subscripti
The npm package @gapi/ac receives a total of 25 weekly downloads. As such, @gapi/ac popularity was classified as not popular.
We found that @gapi/ac demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.