I don't have a specific technical issue but a general problem understanding the architecture for using Auth0 for Authentication and then using the returned profile to access a rails API.
I am using Auth0.Lock in React Native and can successfully sign-up and login to my React Native App and store the returned profile and token.
On the Rails side I have create an API and setup Knock (https://github.com/nsarno/knock) as per the instructions to implement JWT Authentication.
What I don't understand is the link between my User model in Rails and my Database in Auth0. Neither the Auth0 documentation or the Knock documentation are clear on how this association happens.
Thanks Craig
I've created two example projects, a rails API and a front-end app that illustrate auth0 integration in rails. I'm presuming scope claims are present in the tokens to demonstrate at a very basic level how authorization would work in such scenario.
The frontend uses AngularJS, but this is mostly irrelevant as the logic is very basic and can easily be rewritten in any framework.
As joão-angelo hinted, using tokens mostly defeats the need to have a user model at all, you can of course define a user class as convenience wrapper in runtime, but you don't have to store it in the DB. In fact, having user models living in your app and in auth0 may be counter productive, as you'll have to keep them in sync.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With