Hello, I've recently started working
Hello, I've recently started working with Refine. It's a really great platform!
I've tried getting some help from kapa.ai, but no luck there so trying here...
Does anyone have experience integrating Authelia as an AuthProvider? I'm trying to use react-oidc-context, but I'm having some trouble making things work with the built-in components/hooks like <Authenticated>. I'm also not entirely sure how to correctly handle the callback route.
The useAuth from react-oidc-context is working properly. However, I'm not sure where I should use it and how to pass it correctly to the authProvider methods. I can't use it directly inside these methods as it throws error about using hooks outside of FC. I'm currently defining the authProvider (that goes into the Refine component) within the App function, and I call useAuth there. (similar to the Keycloak example).
Any thoughts?
2 Replies
stormy-gold•2mo ago
Hello @Stormlight thanks for the kind words!
Built-in
<Authenticated />
component calls auth provider's check
method, return redirects the user based on the response. So in your auth provider, if you handle check method correctly, authenticated component should work.
For callback route, you can create a new route/page out of refine and handle the given token from the query params and follow Authelia's suggestions (persist cooki and/or local storage).
useAuth hook probably for general purpose usage, but basically you can use their sole client package and implement login, logout, check methods into your auth provider. Then you can use Refine's authpage or useLogin hooks.other-emerald•2mo ago
Thanks for the response!
I've managed to get it working for the most part, though I still have some issues with it.
I'm currently using a callback component that shows loading screen and performs some background process. The react-oidc-context (with oidc-client-ts) is supposed to handle the rest. The main issue I currently have is that for some reason the session-storage seems to reset when I refresh the page, and so it always redirects back to homepage (it actually goes to /login and then immediately to /). Hopefully I'll be able to solve this soon.
It would be really amazing if refine will support react-oidc-context as AuthProvider for generic oidc. It should allow working with any provider. For example, the keycloak packages used by refine are deprecated for years now and recommend using react-oidc-context.
I wish I had the knowledge and time to implement it myself 😔