Tag: spring security

Spring Security targetUrlParameter不重定向

我正在尝试将用户重定向回他们点击登录链接的页面。 (对于未经过身份validation的用户,页面是只读的,但对于已登录的用户,这些页面是可写的。)如何在用户登录后将用户重定向回他们来自的位置? 我正在通过以下链接向用户发送登录页面: /spring_security_login?redirect=/item5 。 登录后,我希望将用户重定向到/item5页面。 但是,它们总是被重定向到/ page。 这是我正在使用的配置: 看来targetUrlParameter没有像预期的那样被拾取。 我正在使用Spring Security 3.1.4

没有cookie的Spring安全会话

我正在尝试在不利用cookie的情况下管理Spring Security中的会话。 原因是 – 我们的应用程序显示在另一个域的iframe中,我们需要在我们的应用程序中管理会话, 并且Safari限制跨域co​​okie的创建 。 (上下文:domainA.com在iframe中显示domainB.com.domainB.com设置JSESSIONID cookie以在domainB.com上使用,但由于用户的浏览器显示domainA.com – Safari限制domainB.com创建cookie) 。 我能想到实现这一目标的唯一方法(针对OWASP安全建议) – 将URL中的JSESSIONID作为GET参数包含在内。 我不想这样做,但我想不出另一种选择。 所以这个问题都是关于: 有没有更好的替代方案来解决这个问题? 如果不是 – 我怎样才能通过Spring Security实现这一目标 回顾Spring的文档,使用enableSessionUrlRewriting应该允许这样做 所以我这样做了: @Override protected void configure(HttpSecurity http) throws Exception { http .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.ALWAYS) .enableSessionUrlRewriting(true) 这没有将JSESSIONID添加到URL,但现在应该允许它。 然后我利用此问题中的一些代码将“跟踪模式”设置为URL @SpringBootApplication public class MyApplication extends SpringBootServletInitializer { @Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); servletContext […]

URL中的Spring Security,尾部斜杠和点

我使用Spring Security 3.1.4来保护部署到Tomcat的Spring MVC 3.2.4应用程序。 我有以下Spring Security配置: 我注意到没有尾部斜杠(例如, /about )的URL模式与具有尾部斜杠的URL(例如, /about/ )不匹配,反之亦然。 换句话说,具有斜杠的URL和没有斜杠的相同URL被Spring Security视为两个不同的URL。 可以使用两个安全规则来解决此问题: 有更好的解决方案吗? 我知道path-type=”regex”允许用正则表达式定义URL模式,但是如果可能的话,我想避免任何不必要的复杂性。 更新 正如Adam Gent所指出的,还有一个问题涉及带有点的URL: /about.foo和/about被Spring MVC视为相同的URL。 但是,Spring Security将它们视为两个不同的URL。 因此,可能还需要一个安全规则:

从数据库或属性中获取Spring Security拦截URL

希望这是超级简单的,存在的,我正在忽略我鼻子底下的东西。 我知道我可以通过注释限制访问: @Secured({“ROLE_ADMIN”}) 或通过配置: 我更愿意从数据库中获取身份validation规则,例如: 最糟糕的情况是,必须有一种通过属性文件填充的方法吗?… /admin/**=ROLE_ADMIN /**=ROLE_USER 等等 请告诉我这存在或我的大脑会爆炸! Grails spring-security插件开箱即用,所以我知道这必须存在。 请不要让我的大脑爆炸! 编辑: 弄清楚了… 您必须提供自定义org.springframework.security.intercept.web.FilterSecurityInterceptor并提供objectDefinitionSource : CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /**login.html=IS_AUTHENTICATED_ANONYMOUSLY /user/**=ROLE_ADMIN 我想我将使用FactoryBean: public class RequestMappingFactoryBean implements FactoryBean { private final static String EOL = System.getProperty(“line.separator”); public Object getObject() throws Exception { StringBuffer sb = new StringBuffer(); sb.append(“CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON”); sb.append(EOL); sb.append(“PATTERN_TYPE_APACHE_ANT”); sb.append(EOL); sb.append(“/**login.html=IS_AUTHENTICATED_ANONYMOUSLY”); sb.append(EOL); sb.append(“/user/**=ROLE_ADMIN”); return sb.toString(); […]

Spring Security 3.2,CSRF和多部分请求

这个问题与此url上的问题有关Spring Security 3.2 CSRF对多部分请求的支持 我尝试了这个完全相同的设置以及要点,但除非我在url中有_csrf令牌,否则我无法使用它。 我在表单主体中将它作为隐藏字段并在安全filter之前指定了filter,但没有任何欢乐,并且每次都使用无效csrf令牌的调试日志消息失败 任何有关这方面的帮助将不胜感激 干杯达米恩

单点登录+弹簧

谁能告诉我如何在我的spring应用程序中实现单点登录。(Tomcat或Jboss服务器) 与我分享任何文档或链接,以便在我的春季应用程序中使用此function。 我使用的是2.5.6弹簧。 请做必要的。

创建名为’defaultServletHandlerMapping的bean时出错

这是eclipse上的一个spring(带有spring security)+ java + maven应用程序。 提交注册表单时遇到以下错误。 随后查看我的其余文件: HTTP Status 500 – Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘defaultServletHandlerMapping’ defined in class org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method ‘defaultServletHandlerMapping’ threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required […]

sitemesh装饰器中的Spring安全标签

我想在site-mesh的装饰器文件中使用spring安全标记库的一些标记。 但是这些标签内的内容从未显示过。 谁能告诉我为什么会这样? 码: <form id="login_form" method="post" action="”> profile messages 由于某种原因,两个块都没有显示。

Spring拦截url配置中ROLE_USER和ROLE_ANONYMOUS有什么区别?

在Spring拦截url配置中ROLE_USER和ROLE_ANONYMOUS之间有什么区别,例如下面的示例?

/ api-url在Spring Boot Security中有一个空的filter列表

具有REST服务的Spring Boot应用程序必须允许公共访问某些服务,同时将其他服务限制为仅授权用户。 当如下所示将configure(WebSecurity web)方法添加到SecurityConfig类时,会向用户的Web浏览器发送403 error ,并且Spring Boot日志文件会发出错误消息,指出: /registration-form has an empty filter list 需要对下面的代码进行哪些具体更改才能使/registration-form服务成功提供给任何用户,包括匿名/未经身份validation的用户? 这是SecurityConfig类: @Configuration @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER) @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) protected static class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Override public void configure(WebSecurity webSecurity) throws Exception { webSecurity.ignoring().antMatchers(“/registration-form”); } @Override protected void configure(HttpSecurity http) throws Exception { http .formLogin() .and() .httpBasic().and() .authorizeRequests() .antMatchers(“/login1”).permitAll() .antMatchers(“/login2”).permitAll() .anyRequest().authenticated(); } […]