![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@mknet/react-acl-router
Advanced tools
Readme
Router with Access Control for React Applications.
yarn add react-acl-router react react-router-dom lodash
Property | Description | Type | Default |
---|---|---|---|
authorities | permissions of current user | OneOfType([string, array, func]) | '' |
authorizedRoutes | array of routes needs permissions | arrayOf(AuthorizedRoute) | [] |
authorizedLayout | container of all authorized routes | function | <div>{props.children}</div> |
normalRoutes | array of routes don't need permissions | arrayOf(NormalRoute) | [] |
normalLayout | container of all routes don't need permissions | function | <div>{props.children}</div> |
notFound | element to show when route doesn't match | function | <div>404</div> |
with all react-router <Route />
supported props except render
because react-acl-router
will overwrite the render
prop.
Property | Description | Type | Default |
---|---|---|---|
path | route's full path | string | - |
permissions | array of roles which have permission like ['god', 'admin' ] | arrayOf(string) | - |
component | route's component | function | - |
unauthorized | unauthorized view component if authorities don't have permission | string | - |
redirect | redirect path if authorities don't have permission | string | - |
with all react-router <Route />
supported props except render
because react-acl-router
will overwrite the render
prop.
Property | Description | Type | Default |
---|---|---|---|
path | route's full path | string | - |
redirect | redirect route path to other route | string | - |
component | route's component | function | - |
import AclRouter from 'react-acl-router';
import BasicLayout from 'layouts/BasicLayout';
import NormalLayout from 'layouts/NormalLayout';
import Login from 'views/login';
import WorkInProgress from 'views/workInProgress';
import Unauthorized from 'views/unauthorized';
const authorizedRoutes = [{
path: '/dashboard/analysis/realtime',
exact: true,
permissions: ['admin', 'user'],
redirect: '/login',
component: WorkInProgress,
}, {
path: '/dashboard/analysis/offline',
exact: true,
permissions: ['admin', 'user'],
redirect: '/login',
component: WorkInProgress,
}, {
path: '/dashboard/workplace',
exact: true,
permissions: ['admin', 'user'],
redirect: '/login',
component: WorkInProgress,
}, {
path: '/exception/403',
exact: true,
permissions: ['god'],
component: WorkInProgress,
unauthorized: Unauthorized,
}];
const normalRoutes = [{
path: '/',
exact: true,
redirect: '/dashboard/analysis/realtime',
}, {
path: '/login',
exact: true,
component: Login,
}];
const Router = (props) => (
<AclRouter
// sync user authorities with the user data in your application
authorities={props.user.authorities}
authorizedRoutes={authorizedRoutes}
authorizedLayout={BasicLayout}
normalRoutes={unAuthorizedRoutes}
normalLayout={NormalLayout}
notFound={() => <div>Page Not Found</div>}
/>
);
export default Router;
redirect
or unauthorized
and component
are exclusive since normally you won't redirect user to another path while you have a valid component to render.FAQs
Router with Access Control for React Applications.
The npm package @mknet/react-acl-router receives a total of 0 weekly downloads. As such, @mknet/react-acl-router popularity was classified as not popular.
We found that @mknet/react-acl-router 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.