Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Roles and Permissions based Authorization for Frontend App​

Roles and Permissions based Authorization for Frontend App​

Roles and Permissions based Authorization for Frontend App​

With @ImpelsysInc/React-RBAC​

Abhisek Pattnaik

December 02, 2022
Tweet

More Decks by Abhisek Pattnaik

Other Decks in Programming

Transcript

  1. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. 1. Pre-requisites 2. Authorization 3. Existing Authorization in Frontend Apps 4. Introduction to React RBAC 5. Permissions 6. Usage 7. Available API 8. Custom Component 9. Demo 10. Relevant Resources 11. The End Agenda
  2. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. I'm an expert. Please don't try to teach me. Don't say to me "You Don't Know JS" and Kend C. Dodds can help you. Basic understanding about • Javascript (optionally Typescript) and • ReactJS Prerequisites
  3. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. • Authorization is the method of specifying access rights/privileges to resources. • Resource is defined as the entity viz. a component, a page, menu, etc. that is output in the application. • Action is defined as the type of operation (e.g. VIEW, GET, UPDATE, DELETE) that the user want to perform on the given resource. Authorization
  4. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. • Hard-coded roles checking. • Cluttered if statements for each role. Existing Authorization in Frontend Apps
  5. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. • Hard-coded permissions checking. • Lacks granular control. • Lacks standardization. • Difficult to extend. • Lacks flexibility. Existing Authorization in Frontend Apps
  6. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. React-RBAC React RBAC is an open-source library with which you get more granular control of resources and actions and has easy to use API for defining the permissions and controlling the visibility of the application components. React RBAC
  7. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. React-RBAC • Make permissions JSON for any role. • Statically define in Frontend or Dynamically fetch from Backend. The Permissions
  8. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. • Import and use the useRBAC hook to get the rbac context value. • Pass the rbac context value to the imported RBACProvider. Where do we fetch or define the permissions for the React RBAC library? The App Component
  9. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. The Layout Component • You may fetch or define your permissions in a wrapper layout component.
  10. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. React-RBAC Custom Permission Component
  11. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. React RBAC • Repository: https://github.com/ImpelsysInc/react-rbac • NPM: https://npm.im/@impelsysinc/react-rbac • Blog Article: https://to.absk.im/react-rbac-article Relevant Resources