开发者

How to handle user authentications in a Service-Oriented Architecture using 'memcached'?

I am using Ruby on Rails 3 and I would like to handle user authentications in a Service-Oriented Architecture (SOA).

At this time I have 3 applications located (for now) on the same server:

  • pjtname.com
  • users.pjtname.com
  • others.pjtname.com

I would like to use memcached (it is a very awesome way to avoid to query the database), but I've heard of problems that can happen when the system goes out of memory, such as the problem for users not being able to log.

However, I am thinking to store in the pjtname.com cache at least the user_id values so that is more hard to go out of memory. The following are steps at what I am thinking to do, but I don't know if it is the best way to accomplish what I aim.

  1. send user credentials from pjtname.com to users.pjtname.com over SSL;
  2. on the users.pjtname.com side use a middleware to intercept and sign in the user;
  3. on sign in success, send back the user session authentication information (example: the user_id string) from users.pjtname.com to pjtname.com over SSL;
  4. on the pjtname.com side look for user_id in cache and if that is expired start again at the step 1.

So, do you advice to use memcached for that purpose?

  • If so, where I can start?
  • If no, what approach is recommended?

UPDATE for @Mörre comment

Why do you want to send authentication info between the sites, can't they just get the session data from the (same) database?

It is because I am trying to scale RoR applications on different servers each of them with its own database.

To give architecture advice one would have to see the WHOLE picture, what your task is from the customers point of view, and know their intentions and c开发者_如何学编程onstraints.

The "picture" is that I have 3 RoR applications (pjtname.com, users.pjtname.com and others.pjtname.com) for which I need to handle data in order to improve the whole system performance. In this case I need to handle user session on a central place (pjtname.com) in order to access to the other application datas (users.pjtname.com and others.pjtname.com) only if the current user is authenticated, that is, signed in.


Given what you've explained so far, my answer would be no, I would not recommend this. Use a before_filter to authenticate, store the auth in the session.

Now if you had asked if you can use memcached as a session store, I'd say that it is possible. But the overly-complex message-passing scenario you've described would not be helped by using memcached.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜