Auth0 with Rails API

I don't have a specific technical problem, but the general problem is understanding the architecture for using Auth0 for authentication, and then using the return profile to access the rails APIs.

I use Auth0.Lock in React Native and can successfully register and log in to my React Native app and save the returned profile and token.

On the Rails side, I created an API and installed Knock ( https://github.com/nsarno/knock ) according to the instructions for implementing JWT authentication.

What I don't understand is the relationship between my user model in Rails and my database in Auth0. The Auth0 documentation or Knock documentation is unclear about how this relationship occurs.

Thanks Craig

+4
source share
2 answers

I created two sample projects, the rails API and the front-end app , which illustrate the integration of auth0 in rails. I assume that the scope requirements are present in the tokens to demonstrate at the most basic level how authorization will work in such a scenario.

The interface uses AngularJS, but it basically does not matter, as the logic is very simple and can be easily rewritten in any structure.

joão-angelo, , , , , , . , , auth0, , .

, !

+1

.

scope, Auth0 - - , .

, Knock , JWT .


, Knock (), , . , from_token_payload, .

class User < ActiveRecord::Base
  def self.from_token_payload payload
    # Returns a valid user, `nil` or raise
  end
end

(: Knock)


, Rails API Auth0. , Auth0 Rails API, , , .

Auth0. , Management API ( , ), Auth0 .

0

Source: https://habr.com/ru/post/1661699/


All Articles