-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add access control #10222
Add access control #10222
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Can't wait to use that one.
I think the Permissions documentation needs some rewrite, though, to introduce this canAccess feature as an alternative to getPermissions. canAccess should be the recommended way. And we should rename the chapter to Access Control.
packages/ra-core/src/core/useConfigureAdminRouterFromChildren.spec.tsx
Outdated
Show resolved
Hide resolved
packages/ra-ui-materialui/src/layout/ResourceMenuItem.stories.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Francois Zaninotto <francois@marmelab.com>
I'd rather do that in a dedicated PR |
Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
@@ -152,7 +152,7 @@ export type UseAuthStateResult<ErrorType = Error> = QueryObserverResult< | |||
boolean, | |||
ErrorType | |||
> & { | |||
authenticated: QueryObserverResult<boolean, ErrorType>['data']; | |||
authenticated?: QueryObserverResult<boolean, ErrorType>['data']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong fix IMO, we must introduce the same types as the other hooks for each state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have?
Access control: pessimistic rendering in CRUD views
Problems
authProvider.getPermissions()
leads developers to put the access control logic in the components. It's hard to keep track of the rules.Solution
authProvider
, and have the components rely on it. Add access control to the main pages, disabled by default.To do
canAccess
method to theauthProvider
useCanAccess
hook<CanAccess>
componentuseCanAccessResources
hookuseCanAccessCallback
hook<Authenticated>
blocking<ListButton>
,<EditButton>
,<CreateButton>
,<ShowButton>
,<DeleteButton>
)rowClick
(Add access control to<Datagrid rowClick>
#10227)ReferenceField
link (Add access control to<Datagrid rowClick>
#10227)<Menu>
(https://github.com/marmelab/react-admin/pull/10222/files#diff-7ea3c7cf3f7576675705b47a17ae782e9b3e752291035cc9b21b569ee1234c91)/
route in the absence of a dashboard (Introduce<NavigateToFirstResource>
#10255)authProvider.getPermissions()
optional (Make authProvider.getPermissions optional #10257)How To Test
ra-core/Admin/Resource
storiesra-ui-materialui/layout/ResourceMenuItem
storiesHistory
This is a big feature, so it was split into multiple PRs that got merged into this branch before merging it to
next
:<DeleteButton>
#10226<Datagrid rowClick>
#10227<NavigateToFirstResource>
#10255