问题标签 [spring-security4]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
5795 浏览

spring-security - 在 SpringSecurity 4 中覆盖 BasicAuthenticationEntryPoint 的最简单方法是什么?

我无法在 SO 上找到答案(例如这里 。Spring Security: Commence method in class extends BasicAuthenticationEntryPoint no being called

我只想覆盖 BasicAuthenticationEntryPoint 而不覆盖其他过滤器和其他人员:

不幸的是,它不起作用,我需要配置过滤器。

然后我有这个警告。

因此我需要禁用自动配置,但我不想这样做:

在 SpringSecurity 4 中覆盖 BasicAuthenticationEntryPoint 的最简单方法是什么?

0 投票
1 回答
663 浏览

java - SecurityContext 权限不等于 ServletRequest 角色?

我试图用注释(@Secured@PreAuthorize)替换一些手动权限检查。在调试它为什么不起作用时,我惊讶地发现这两个断言中的第二个在@RequestMapping控制器方法的顶部失败了。

我假设(因为我无法让他们授权任何事情)@SecuredhasRole()使用后者查找?

这些角色不应该从SecurityContext当局自动填充吗?

Authentication设置应该分别添加角色的过滤器是吗?


编辑:

将 spring 安全配置减少到 spring boot 的(1.3.0)默认值,加上设置身份验证的过滤器。

0 投票
3 回答
174323 浏览

spring-mvc - 何时使用 Spring Security 的 antMatcher()?

我们什么时候使用antMatcher()vs antMatchers()

例如:

我在这里期望的是,

  • 任何与/high_level_url_A/**_ _/high_level_url_A/sub_level_1/high_level_url_A/sub_level_2
  • 任何与/high_level_url_B/**_ _/high_level_url_B/sub_level_1/high_level_url_A/sub_level_2
  • 我不在乎的任何其他模式 - 但应该公开吗?

我看到的最新例子不包括antMatcher()这些天。这是为什么?antMatcher()不再需要?

0 投票
1 回答
458 浏览

spring-security - How is possible to access to the logged out user name in Spring Security?

We use Spring Security 4.0.x and I need to find the way to access the logged out user name. I have configured LogoutSuccessHandler:

I see the authentication object in the method signature:

Unfortunately, the authentication object is empty. I see that the LogoutHandler (SecurityContextLogoutHandler) clears the authentication before logoutSuccessHandler but I can not find the way how to configure LogoutHandler via <logout .. configuration.

How is possible to access to the logged out user name in Spring Security?

0 投票
1 回答
495 浏览

spring-boot - 如果 maxSessionsPreventsLogin 设置为 true 并且某些使用我的登录凭据的用户尝试登录,如何在我的 thymelaf 登录页面中显示错误?

我正在使用spring security 4。场景是我希望一个用户一次登录。也就是说,如果我的登录凭据知道某人并且我已经登录,但是除非并且直到我注销我通过设置 maximumSessions(1) 和 maxSessionsPreventsLogin(true) 成功实施,否则某人应该无法登录。

我的要求是,即使我已经登录,如果有人使用我的登录凭据尝试登录。我想显示错误消息,例如用户已经在我的 thyemeaf 登录页面中登录。

在我的情况下,如果有人使用我的登录凭据尝试登录,即使我已经登录,它也会显示无效的登录名或密码错误。

我想显示自定义错误消息,例如用户已经在我的 thymeaf 登录页面中登录。我怎么能实现呢?注意:- 我正在使用自定义登录成功处理程序和自定义注销成功处理程序

0 投票
1 回答
358 浏览

spring - 升级到 Spring Security 4 现在我无法登录

我刚刚升级到 Spring Security 4.2.3.RELEASE,现在我无法登录。具体来说,当我登录时,提交这些参数

我得到错误

从上面你可以清楚地看到它在那里。下面是我的 Spring 安全配置。我还需要检查什么才能使其正常工作?

0 投票
0 回答
163 浏览

spring-security - AuthenticationProvider函数在迁移到spring security 4后不调用

AuthenticationProvider 函数在将 spring security 2 迁移到 spring security 4 后不调用。

我正在使用自定义提供程序和 ldap 身份验证,我的所有配置都可以,但是当我尝试连接时,我的 AccessDecisionVoter.vote 中有一个 anonymousUser

请在此处查看描述代码:

任何解决方案/想法来解决我的问题?非常感谢

0 投票
1 回答
27 浏览

grails - 如何在grails spring security core 4中获取默认保存的请求uri?

在 grails 2.2 中,我们可以让保存的 uri 在登录前重定向,如下所示。重定向 url 将保存在 session[WebAttributes.SAVED_REQUEST] 中。

有没有办法在 grails 4 和 spring security core 4 中实现相同的功能?

这是我所做的

我从插件中复制了 Login 控制器类来覆盖 auth 方法。

默认身份验证看起来像这样,我输入了 DefaultSavedRequest defaultSavedRequest = session[WebAttributes.SAVED_REQUEST] 行。

我得到这个错误。

我完整阅读了文档,但找不到与从会话中获取保存的请求 uri 相关的任何内容?

https://grails-plugins.github.io/grails-spring-security-core/snapshot/index.html

我感谢任何帮助。谢谢!