[英]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. 我目前正在使用playframework,我想在网站上实现身份验证功能。 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). 假设第一个组是X,第二个组是Y,它们都从User(在模型中)继承。 (Everything is implemented in java) (一切都在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. 还有一个数据库和一个表,用于组X,一个用于组Y。该控制器具有一个用于X的Java类,一个用于Y的Java类。这两个组均由其唯一的电子邮件地址标识。
Now, when one of them logs in, how can I check who he is(either X or Y). 现在,当其中一个登录时,如何检查他是谁(X或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). 因此,首先要进行用户名(电子邮件地址)/密码验证,然后我必须找到它的实例类型(该模型在db中查找并返回一个对象)。
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. 例如,他们将具有不同的UI,例如不同的侧边栏,从中可以从某些功能中进行选择。
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". 播放框架网站上已经有一个示例,该示例称为“ 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. https://github.com/t2v/play2-auth是“身份验证和授权”的模型,据我所知,它应该适合您的需求。
You may also like to take a look at http://securesocial.ws/ and https://developers.google.com/accounts/docs/OAuth2 for implementing OAuth2. 您可能还想看看用于实现OAuth2的http://securesocial.ws/和https://developers.google.com/accounts/docs/OAuth2 。 This will make it possible for you to log in using your Gmail account. 这样您就可以使用Gmail帐户登录了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.