Skip to content

Releases: CybeDefend/react-rebac

v1.0.5

Choose a tag to compare

@FlorentinLedy FlorentinLedy released this 06 Dec 09:47

v1.0.5 - Multi-Entity Support and Strict Mode Validation 🏆

Summary

This release introduces the ability to check authorization against multiple entities at once, providing greater flexibility and control in defining user access. AuthorizedContent can now operate in a "multi-entity" mode, allowing you to pass an array of entities—each with its own entityId, entityType, and relationship—to be checked. The component will render its children if the user has the required relationship with at least one of the specified entities.

In addition, the component enforces that you cannot use both "single-entity" and "multi-entity" modes at the same time. If both sets of props are provided, a warning will be logged and no content will be rendered, ensuring a more predictable and maintainable setup.

Key Features

  • Multi-Entity Mode: Pass an array of entities (each defined by entityId, entityType, and relationship) to AuthorizedContent to check for user access against multiple entities.
  • Strict Mode Validation: AuthorizedContent now warns and prevents rendering if you attempt to use both the single-entity props (entityId, entityType, relationship) and the entities array simultaneously.
  • Continued Support for Loading States: The optional loading prop is still available to handle asynchronous loading of user entities gracefully.

This update simplifies complex authorization scenarios and enforces best practices, ensuring a clearer and more robust approach to rendering authorized content in your application.

v1.0.4

Choose a tag to compare

@FlorentinLedy FlorentinLedy released this 22 Oct 13:07
d1ff7a7

v1.0.4 - Support for Multiple Roles in Authorization Checks 📈

Summary

This release enhances the useAuthorization hook and AuthorizedContent component to support multiple roles for access control. You can now pass an array of roles to check if the user has any of the specified roles for an entity. Additionally, a loading state is introduced to handle situations where user entities are not yet fully loaded.

Key Features

  • useAuthorization now accepts a single role or an array of roles for more flexible permission checks.
  • AuthorizedContent supports multiple role checks and provides an optional loading prop to display content while user entities are being fetched.
  • Improved handling of asynchronous loading states to ensure proper access control flow.

This update improves the flexibility and robustness of the access control system, making it easier to handle complex authorization scenarios.

v1.0.3

Choose a tag to compare

@FlorentinLedy FlorentinLedy released this 12 Oct 14:38

v1.0.3 - Multiple Relationship Support for AuthorizedContent 🚀

Summary

This update enhances the AuthorizedContent component to support multiple relationships, allowing content to be conditionally rendered based on one or more specified user relationships. This feature provides greater flexibility in managing access permissions for complex roles and scenarios.

New Features

Multiple Relationship Support

  • AuthorizedContent now accepts a single relationship (e.g., "Admin") or an array of relationships (e.g., ["Admin", "Member"]).
  • When passing multiple relationships, AuthorizedContent will render content if the user has at least one of the specified relationships.

Enhanced Flexibility

  • Simplifies the management of roles with different permissions across entities, enabling broader use cases.

Code Example

<AuthorizedContent entityId="team1" entityType="Team" relationship={["Member", "Admin"]}>
  <p>Accessible to Team1 Members or Admins</p>
</AuthorizedContent>

Installation

Update to the latest version:

npm install react-rebac@latest

Or with Yarn:

yarn add react-rebac@latest

Thank you for using react-rebac, and please share any feedback or issues!

v1.0.2

Choose a tag to compare

@FlorentinLedy FlorentinLedy released this 12 Oct 14:11

v1.0.2 - Build Fix for TypeScript Compatibility 🛠️

Summary

This release addresses a critical build issue where the library did not properly compile TypeScript definitions, resulting in import errors. The issue is now resolved, ensuring full compatibility with TypeScript projects.

Fixes

  • Build Configuration: Adjusted the tsconfig.json settings to ensure that .d.ts type declaration files are correctly generated in the dist directory.
  • Main Entry Points: Verified that the main JavaScript (index.js) and TypeScript definitions (index.d.ts) are correctly referenced in package.json.
  • Exports: Confirmed all public components and hooks are accessible for import from react-rebac.

Installation

To update to the latest version with the build fix:

npm install react-rebac@latest

Or with Yarn:

yarn add react-rebac@latest

Thank you for your patience, and please report any further issues!

v1.0.1

Choose a tag to compare

@FlorentinLedy FlorentinLedy released this 12 Oct 13:55

v1.0.1 - README Update 📝

Summary

This patch release includes updates to the README for improved clarity and ease of use. The revised README provides more concise installation and usage instructions, without internal project configuration details, making it more accessible for end-users.

Changes

README:

  • Updated installation instructions for npm and Yarn.
  • Refined usage examples with streamlined setup and API documentation.
  • Removed internal compilation details to focus on public usage.

Installation

Install or update to the latest version with:

npm install react-rebac@latest

Or with Yarn:

yarn add react-rebac@latest

v1.0.0

Choose a tag to compare

@FlorentinLedy FlorentinLedy released this 12 Oct 13:22

React ReBAC Release v1.0.0 🎉

Summary

We are excited to announce the initial release of React ReBAC! This lightweight library brings Relationship-Based Access Control (ReBAC) capabilities to React applications, allowing you to manage access control with ease and flexibility.

Features

  • ReBAC Context Provider: Easily integrate the RebacProvider at the root of your React app to set up access control.
  • Dynamic Access Management: Set user relationships with different entities and roles, and use hooks to manage access control dynamically.
  • Conditional Rendering Component: AuthorizedContent component enables content to be displayed conditionally based on user relationships and roles.
  • TypeScript Support: Full TypeScript support, ensuring better type safety and developer experience.
  • Flexible Hooks:
    • useAuthorization to verify user access to specific entities.
    • useUserEntities for retrieving user entities with ease.

Installation

Install with npm:

npm install react-rebac

Or with Yarn:

yarn add react-rebac

Usage

Import and wrap your application with RebacProvider, and use the AuthorizedContent component to conditionally render content.

import { RebacProvider, AuthorizedContent, useRebac } from 'react-rebac';

const App: React.FC = () => (
  <RebacProvider>
    <MainContent />
  </RebacProvider>
);

const MainContent: React.FC = () => (
  <AuthorizedContent entityId="orgA" entityType="Organization" relationship="Admin">
    <h3>Admin Content</h3>
  </AuthorizedContent>
);

export default App;

Feedback

We would love to hear your feedback! Please open an issue if you encounter any problems or have feature requests.

This release note is ready for a GitHub release and can be adjusted as new features or changes are added to the library.