Skip to content

Commit 62ac689

Browse files
committed
Add permission optimization
1 parent 33e8ade commit 62ac689

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

docs/AuthRBAC.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,8 @@ const ProductCreate = () => (
12141214

12151215
`authProvider.getPermissions()` can return a promise, which in theory allows to rely on the authentication server for permissions. The downside is that this slows down the app a great deal, as each page may contain dozens of calls to these methods.
12161216

1217+
To compensate for that, `usePermissions` uses a stale-while-revalidate approach, and after the initial call to `authProvider.getPermissions()`, it will return the permissions from the cache, and refresh them in the background.
1218+
12171219
In practice, your `authProvider` should use short-lived sessions, and refresh the permissions only when the session ends. JSON Web tokens (JWT) work that way.
12181220

12191221
Here is an example of an `authProvider` that stores the permissions in memory, and refreshes them only every 5 minutes:

0 commit comments

Comments
 (0)