简体   繁体   English

Spring Security 3 Web +稳定登录

[英]Spring Security 3 Web + Restful Login

I have a spring-mvc and spring-security + spring-security-social webapplication which I would like to provide restful login to allow a rest client to interact via this application. 我有一个spring-mvc和spring-security + spring-security-social网络应用程序,我想提供宁静的登录名,以允许其他客户端通过此应用程序进行交互。 Let me explain a little bit more: 让我解释一下:

  • For the web application, everything is working fine. 对于Web应用程序,一切正常。 Login, roles, Facebook login, without any xml using Spring-Core version 4 and Spring-Security version 3. 使用Spring-Core版本4和Spring-Security版本3,无需任何xml即可进行登录,角色,Facebook登录。

Requirement 需求

  • Provide a restful service in which will allow the user to sign in on the application and provide its user all the access like the web login. 提供一个宁静的服务,其中将允许用户登录应用程序,并向其用户提供所有访问权限,例如Web登录。

I've been searching over the web, but I can only find old examples using older spring versions and with xml code. 我一直在网上搜索,但是只能使用较早的Spring版本和xml代码找到旧示例。

REST is stateless. REST是无状态的。 With that in mind, are you looking to still have authentication/authorization for the services in a RESTful fashion? 考虑到这一点,您是否仍希望以RESTful方式对服务进行身份验证/授权? To do this, you will have to authenticate the user on EVERY call. 为此,您将必须在每次通话时对用户进行身份验证。 You can use Basic authentication to stick to strict REST principles or you can violate REST slightly by using OAuth yourself. 您可以使用基本身份验证来遵守严格的REST原则,也可以通过自己使用OAuth来稍微违反REST。

RESTful services are typically developed for other developers to incorporate in their code. RESTful服务通常是为其他开发人员开发的,以整合到他们的代码中。 They're not meant to be exposed directly to a user of a service. 它们并不意味着直接向服务用户公开。

If you need to provide client like functionality (login, allow user to access features/services, etc), then there is no need to develop a RESTful service. 如果您需要提供类似客户端的功能(登录,允许用户访问功能/服务等),则无需开发RESTful服务。 You can use Spring MVC in combination with Spring Security for that. 您可以将Spring MVC与Spring Security结合使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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