Create without user table but Redis instead

I've been looking around for a while but can't seem to find a solution that suits my needs or an example that might help me along my way ...

TL; DR

How can I use Devise + Redis without requiring a user and object table, but instead store the user / session related data (obtained from an API call like email, access_token, refresh_token, admin_boolean) in Redis for the duration of the session?

Problem

I have an API (rails + doorkeeper + grape ) that is used by a rails client. Following the concept of eating their dog food, this client makes API calls to get all the information, data, etc. And it shows or (handles if needed, but mostly done in the API) it's in the client.

Since my client is almost entirely API dependent, I have no client side tables except for one user table that I want to get rid of.

This user table exists because I am currently using Devise to allow (new) users to register and log into my client application. With some changes to session_controller, I was able to send the registration data to the API where the data is saved. Then when the User logs into the API / Doorkeeper call using the Oauth2 gem to get an access_token + refresh_token (+ email + admin_boolean) which can be used to send all further requests.

Currently, this data is stored as attributes as part of the User object that is used throughout the application, that is, every time the user logs in, I call User.new (data_params).

However, I get rid of this approach very much and instead store all data in Redis, allowing me to drop the User table and client db ...

My problem is not that I don't know how to store the values ​​in Redis, but that I cannot figure out how to use Devise without the User table since Devise / Warden requires a resource object.

So my question is, does anyone know how I can solve this problem? And what are the limitations of this approach? (I don't need the functionality of a relational db)

Please let me know if anything is unclear (it has been a long day ;-) thanks for any help with suggestions in advance!

+3


source to share





All Articles