简体   繁体   中英

Rails: authenticate with JWT Token using knock

Iam trying to build an authentication solution for my app. Iam using React as frontend and Rails in API mode as my backend. I have an external authentication solution, which I need to use. I stumbled over Knock for JWT token management but I dont understand the documentation, especially this part "It must have an authenticate method, similar to the one added by has_secure_password.", since, due to my external authentication service, i dont have a User Model. So in my head, a login request would go to my LoginController, which would manage the external authentication, and, after successful authentication, would somehow create an JWT token and return this to the frontend. Any idea how i achieve this?

Check this post

Although it's very strange that you cannot understand the documentation

If you're using an external authentication solution, then you don't have a login controller, and you shouldn't need to have. If you have an external service do authentication, then that's very likely to be OpenID or OAuth2.

Here is a good explanation of the authentication flow .

What you probably want and need in your application is a before_action which verifies that the Bearer token is valid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM