Tag: spring security

Spring EL变量列表?

Spring EL支持一些预定义的变量 {#systemProperties. … } {#systemEnvironment. … } {#request. …} {#session. …} 前两篇文章记录在Spring Reference:第6章Spring表达语言(SpEL)中 。 在Spring Reference中没有提到另外两个(或者我没有找到它们。)(我在这张幻灯片中找到了它们,以及它在spring社交和这个问题中的用法)。 所以我的问题是:是否有一个或多或少完整的预定义spring-el变量列表? 我猜这些预定义变量中的一些并不是由spring core本身定义的,而是通过“激活”某些模块(如spring-mvc)来定义的。 所以我对一个或多或少常见的spring + jpa + mvc +安全应用程序中可用的变量感兴趣。

春季限制最多会话; 限制最大用户

我是否可以使用spring security来限制能够同时登录网站的最大用户数? 肯定的是,不是并发会话控制参数。 我想要的是,例如,我想限制最大只允许1000个用户同时登录。 如果超过该转发通知页面,则说明超出了最大用户数

Spring Security:测试和理解REST身份validation

我正在使用Spring-MVC,我在其中使用Spring-Security进行登录/注销和会话管理。 在普通浏览器中使用时效果很好。 我正在尝试为应用程序集成REST身份validation,我在其中参考了答案 。 我做了一些修改,以便我也可以在浏览器中使用它,也可以在REST上使用它。 现在,代码运行得很好,但我不知道为什么,而且如果我想通过RESTvalidation用户,我如何使用此代码实现? 不幸的是,没有错误要求解决方案。 任何人都可以告诉我这段代码,我应该通过REST发送哪些数据进行身份validation并访问后续的@Secured服务。 你能帮忙的话,我会很高兴。 非常感谢。 Security-application-context.xml: <!—-> AuthenticationFilter: public class AuthenticationFilter extends UsernamePasswordAuthenticationFilter{ @Override protected boolean requiresAuthentication(HttpServletRequest request,HttpServletResponse response){ return (StringUtils.hasText(obtainUsername(request)) && StringUtils.hasText(obtainPassword(request))); } @Override protected void successfulAuthentication(HttpServletRequest request,HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException{ System.out.println(“Successfule authenticaiton”); super.successfulAuthentication(request,response,chain,authResult); chain.doFilter(request,response); } } AuthenticationSuccessHandler: public class AuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler{ @PostConstruct […]

在反向代理后面需要使用Spring Security的https

我有一个使用Spring Security保护的Spring MVC应用程序。 大多数应用程序使用简单的http来节省资源,但是一小部分处理更多机密信息并需要https频道。 从security-config.xml提取: … 一切正常,直到我们决定将其迁移到主服务器,其中应用程序服务器在反向代理后面运行。 现在,HTTPS由反向代理处理,应用程序服务器只能看到HTTP请求,并且不允许访问/sec/**层次结构。 经过一些研究,我发现代理添加了一个X-Forwarded-Proto: https头(*) ,但在Spring Security中, HttpServletRequest.isSecure()用于确定所提供的通道安全性 (从SecureChannelProcessor javadoc中提取) 如何告诉Spring Security X-Forwarded-Proto: https标头足以满足安全请求? 我知道我可以在代理配置上报告该部分,但代理管理员确实不喜欢该解决方案,因为代理背后有许多应用程序,并且配置可能会增长到不可管理的状态。 我目前正在使用带有XML配置的Spring Security 3.2,但我已准备好接受基于Java配置和/或更新版本的答案。 (*)当然,代理如果它在传入请求中存在则删除标题,因此应用程序可以对它充满信心。

使用Spring Security,我如何使用HTTP方法(例如GET,PUT,POST)来确定特定URL模式的安全性?

Spring Security参考说明: 您可以使用多个元素为不同的URL集定义不同的访问要求,但它们将按列出的顺序进行评估,并将使用第一个匹配项。 所以你必须把最具体的比赛放在最上面。 您还可以添加方法属性以限制与特定HTTP方法(GET,POST,PUT等)的匹配。 如果请求与多个模式匹配,则无论排序如何,特定于方法的匹配都将优先。 如何配置Spring Security,以便根据用于访问URL模式的HTTP方法,以不同方式保护对特定URL模式的访问?

Spring Security + MVC:相同的@RequestMapping,不同的@Secured

假设我们有一个使用Spring MVC和Spring Security配置的API端点。 我们希望能够处理成对的@RequestMapping和@Secured注释,其中唯一的@Secured注释值因配对而异。 这样,我们就可以根据同一请求的安全规则返回不同的响应主体。 这可以通过避免直接检查方法体中的安全规则来允许我们的代码更易于维护。 有一个不成功的例子,我们想做的是: @Controller @RequestMapping(“/api”) public class Controller { @Secured ({“ROLE_A”}) @RequestMapping(value=”{uid}”, method=RequestMethod.GET) @ResponseBody public Response getSomething(@PathVariable(“uid”) String uid) { // Returns something for users having ROLE_A } @Secured ({“ROLE_B”}) @RequestMapping(value=”{uid}”, method=RequestMethod.GET) @ResponseBody public Response getSomethingDifferent(@PathVariable(“uid”) String uid) { // Returns something different for users having ROLE_B } } 我们怎样才能做到这一点? 如果可以这样做:如何为同时具有ROLE_A和ROLE_B的用户管理优先级?

如何使用基于Java的配置启用安全注释?

我想对我的控制器操作使用@Secured注释。 由于我有基于java的配置,我需要知道如何设置 没有xml文件的选项。 Upate 1: 我将@EnableGlobalMethodSecurity(securedEnabled = true)到我的安全配置类中: @Configuration @EnableWebMvcSecurity @EnableGlobalMethodSecurity(securedEnabled = true) public class LIRSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http .authenticationProvider(preAuthenticatedAuthenticationProvider()) .addFilter(cookiePreAuthenticationFilter()) .authorizeRequests() .antMatchers(“/**”) .hasAnyAuthority(“ROLE_USER”) ; } … } 在启动时,这会导致此exception Jul 21, 2014 3:32:54 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of […]

没有使用javaconfig定义名为’springSecurityFilterChain’的bean错误

我在增加弹簧安全性方面遇到了一些问题。 它显示一个错误:没有定义名为’springSecurityFilterChain’的bean public class WebInitializer implements WebApplicationInitializer { public void onStartup(ServletContext servletContext) throws ServletException { // Create the ‘root’ Spring application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(App.class); servletContext.addListener(new ContextLoaderListener(rootContext)); // security filter servletContext.addFilter( “springSecurityFilterChain”, new DelegatingFilterProxy(“springSecurityFilterChain”)) .addMappingForUrlPatterns(null, false, “/*”); // Manage the lifecycle of the root application context AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext(); webContext.register(WebConfig.class); […]

Jersey JAX-RS + Spring安全应用程序示例

有没有人有关于这个答案描述内容的示例应用程序? Jersey REST服务上的用户身份validation

无法解析类型javax.servlet.ServletContext和javax.servlet.ServletException

我正在尝试将Spring Security包含到我的Web项目中,我正在按照本教程http://docs.spring.io/spring-security/site/docs/current/guides/html5//helloworld.html 我已经用给定的maven项目完成了教程中的所有内容并且工作正常。 但是当我试图将它包含在我的项目中时,会出现编译错误。 特别是当我从AbstractSecurityWebApplicationInitializer扩展时出现给定的错误 此行有多个标记 无法解析javax.servlet.ServletContext类型。 它是从所需的.class文件间接引用的 无法解析类型javax.servlet.ServletException。 它是从所需的.class文件间接引用的 POM.xml 4.0.0 spring.primefaces primefaces.testwebapp 0.0.1-SNAPSHOT war SpringPrimefacesWebApp maven-compiler-plugin 1.7 1.7 maven-war-plugin 2.3 false com.sun.faces jsf-api 2.2.11 com.sun.faces jsf-impl 2.2.11 org.primefaces primefaces 5.2 org.springframework.security spring-security-web 4.0.1.RELEASE org.springframework.security spring-security-config 4.0.1.RELEASE org.springframework spring-framework-bom 4.1.6.RELEASE pom import 谢谢您的帮助! 使用mvn clean install -U