Repository navigation
Releases: CybeDefend/react-rebac
Release list
v1.0.5
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, andrelationship) toAuthorizedContentto check for user access against multiple entities. - Strict Mode Validation:
AuthorizedContentnow warns and prevents rendering if you attempt to use both the single-entity props (entityId,entityType,relationship) and theentitiesarray simultaneously. - Continued Support for Loading States: The optional
loadingprop 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
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
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
AuthorizedContentnow accepts a single relationship (e.g., "Admin") or an array of relationships (e.g., ["Admin", "Member"]).- When passing multiple relationships,
AuthorizedContentwill 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@latestOr with Yarn:
yarn add react-rebac@latestThank you for using react-rebac, and please share any feedback or issues!
v1.0.2
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.jsonsettings to ensure that.d.tstype declaration files are correctly generated in thedistdirectory. - Main Entry Points: Verified that the main JavaScript (
index.js) and TypeScript definitions (index.d.ts) are correctly referenced inpackage.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@latestOr with Yarn:
yarn add react-rebac@latestThank you for your patience, and please report any further issues!
v1.0.1
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@latestOr with Yarn:
yarn add react-rebac@latestv1.0.0
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
RebacProviderat 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:
AuthorizedContentcomponent 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:
useAuthorizationto verify user access to specific entities.useUserEntitiesfor retrieving user entities with ease.
Installation
Install with npm:
npm install react-rebacOr with Yarn:
yarn add react-rebacUsage
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.