
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
@permify/react-role
Advanced tools
Lightweight role based access management solution for React applications
React Role is lightweight role based access management solution which provides components, hooks, and helper methods for controlling access checks and user permissions throughout your entire React application without any backend connection.
Use npm to install:
npm install @permify/react-role
Use yarn to install:
yarn add @permify/react-role
PermifyProviderWrap the part of your application where you want to perform access checks with PermifyProvider. You should pass some props to PermifyProvider in order to utilize from Permify components, hooks and helper methods.
import React from "react";
import { PermifyProvider } from "@permify/react-role";
const App = () => {
return (
<PermifyProvider>
{/* Application layer, Routes, ThemeProviders etc. */}
</PermifyProvider>;
)
};
export default App;
In order to check user roles or permissions, you should set logged in user with setUser function. Our advice is call this method in your login functions promise.
Set the user using the usePermify hook:
import { usePermify } from '@permify/react-role';
...
const { setUser } = usePermify();
const login = async (e) => {
const response = await login(email, password);
setUser({
id: "2",
roles: ["admin", "manager"],
permissions: ["post-create", "user-delete", "content-show"]
})
//
// Continue authentication flow
//
};
Or using PermifyContext:
import React from "react";
import { PermifyContext } from "@permify/react-role";
const AuthComponent = () => {
const login = (setUserId) => {
return async (event) => {
const response = await login(email, password);
setUser({
id: "2",
roles: ["admin", "manager"],
permissions: ["post-create", "user-delete", "content-show"]
})
//
// Continue authentication flow
//
};
};
return (
<PermifyContext.Consumer>
{({ setUser }) => (
<form onSubmit={login(setUser)}>
{/* form layer */}
</form>
)}
</PermifyContext.Consumer>;
)
};
export default AuthComponent;
HasAccessHasAccess is a wrapper component that you can wrap around components or UI Layers that should only be accessible to users have authorization.
You can check roles and permissions of the user with giving them as props.
import React from "react";
import { HasAccess } from "@permify/react-role";
const AnyComponent = () => {
return (
..
..
<HasAccess
roles={["admin", "manager"]}
permissions="user-delete"
renderAuthFailed={<p>You are not authorized to access!</p>}
isLoading={<Spinner/>}
>
<button type="button"> Delete </button>
</HasAccess>
..
..
)
};
export default App;
isAuthorized(roleNames, permissionNames)isAuthorized is a helper function that returns a Promise which resolves with true if the user is authorized for action with the given parameters, if not it resolves with false.
You should call it inside a conditional logic structure; for ex. if check for fetching protected information.
Using isAuthorized through the usePermify hook:
import React, {useState, useEffect} from "react";
import { usePermify } from "@permify/react-role";
const AnyComponent = () => {
const { isAuthorized, isLoading } = usePermify();
useEffect(() => {
const fetchData = async () => {
// Pass roles and permissions accordingly
// You can send empty array or null for first param to check permissions only
if (await isAuthorized(["admin", "manager"], "user-delete")) {
// request protected info from serverß
}
};
fetchData();
},[]);
return (
<>
{isLoading && <span>Loading...</span>}
{dataFetched &&
//render protected component, UI Layers etc.
}
</>;
)
};
export default AnyComponent;
Permify API is an authorization API which you can add complex rbac and abac solutions.
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
FAQs
Lightweight role based access management solution for React applications
The npm package @permify/react-role receives a total of 233 weekly downloads. As such, @permify/react-role popularity was classified as not popular.
We found that @permify/react-role demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.