简体   繁体   中英

Web App - How to implement an authentication in a web app

I'm currently working with playframework and I would like to implement an authentication functionality on a website. But there are two people who can login with two different access level. Lets say the first group is X and the second group is Y and they inherit both from User(in model). (Everything is implemented in java)

Also there is a database and a table for the group X and one for the group Y. The controller has a java class for X and one for Y. Both groups are identified by their unique email address.

Now, when one of them logs in, how can I check who he is(either X or Y). So first username(email address)/password validation and then I have to find what kind of instance it is(the model looks up in db and returns an object).

But more important is, both groups have different rights. For example, they will have different UI like different sidebars, where they can choose from some features.

I would like to implement the login procedure in the controller. So, I am only speaking about the controller and the implementation should be done there. Also this my first time doing a web app. So the login procedure does not have to be very fancy.

There is already an example on the playframework website and this example is called "zentask". This demonstrates a login procedure as I'd like to have, but as I said for two different groups.

I would appreciate if you could help me with the issue above.

Here is the link for the sample mentioned above.

Don't know if you still need help with this, but I'll try to answer it anyway.

I'm in a similar situation as you are, but I have yet to implement authentication to my application. As far as I can tell, the easiest way to implement authentication would be to use a module.

https://github.com/t2v/play2-auth is a model for 'Authentication and Authorization' and it should, as far as I can tell, suit your needs.

You may also like to take a look at http://securesocial.ws/ and https://developers.google.com/accounts/docs/OAuth2 for implementing OAuth2. This will make it possible for you to log in using your Gmail account.

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