
[英]How to configure CORS in a Spring Boot + Spring Security application?
我使用带有 Spring Security 和 Cors 支持的 Spring Boot。 如果我执行以下代码 结果我得到 如果我使用错误的凭据进行测试,例如 而不是得到401(这是spring security中错误身份验证的标准代码)我得到 带有以下浏览器通知: 获取http ...
[英]How to configure CORS in a Spring Boot + Spring Security application?
我使用带有 Spring Security 和 Cors 支持的 Spring Boot。 如果我执行以下代码 结果我得到 如果我使用错误的凭据进行测试,例如 而不是得到401(这是spring security中错误身份验证的标准代码)我得到 带有以下浏览器通知: 获取http ...
[英]How to fix Hibernate LazyInitializationException: failed to lazily initialize a collection of roles, could not initialize proxy - no Session
在我的 spring 项目的自定义 AuthenticationProvider 中,我正在尝试读取登录用户的权限列表,但我面临以下错误: 从 StackOverflow 中的此处阅读其他主题,我了解这是由于框架处理此类属性的方式而发生的,但我无法为我的案例找到任何解决方案。 有人可以指出我做错 ...
[英]Spring boot Security Disable security
当我使用security.basic.enabled=false禁用具有以下依赖项的 Spring Boot 项目的安全性时: <dependency> <groupId>org.springframework.boot</groupId> ...
[英]Unsupported Media Type in postman
我正在使用 oauth2 和 jwt 实现 spring 安全性。 以下是我的登录功能 下来我有控制器 但是当我尝试与邮递员一起发布请求时,它会告诉我 但是当我在 ajax 调用中执行cosole.log(data)时,它会打印令牌?我不知道出了什么问题。感谢任何帮助。 ...
[英]Spring security CORS Filter
我们将Spring Security添加到我们现有的项目中。 从这一刻起,我们从我们的服务器收到一个 401 No 'Access-Control-Allow-Origin' header is present on the requested resource错误。 那是因为没有Access-Co ...
[英]Failed to load ApplicationContext (with annotation)
这是我的 class 用于测试。 异常(很多异常,主要: Failed to load ApplicationContext , Error creating bean with name 'defaultServletHandlerMapping' 。 Failed to instantiat ...
[英]How to manually set an authenticated user in Spring Security / SpringMVC
新用户提交“新帐户”表单后,我想手动登录该用户,这样他们就不必在后续页面上登录。 通过 spring 安全拦截器的正常表单登录页面工作正常。 在 new-account-form 控制器中,我正在创建一个 UsernamePasswordAuthenticationToken 并在 Securi ...
[英]How to check “hasRole” in Java Code with Spring Security?
如何在 Java 代码中检查用户权限或权限? 例如 - 我想根据角色为用户显示或隐藏按钮。 有这样的注释: 如何在Java代码中制作它? 就像是 : ...
[英]Spring 5.0.3 RequestRejectedException: The request was rejected because the URL was not normalized
不确定这是 Spring 5.0.3 的错误还是我这边修复问题的新功能。 升级后,我收到此错误。 有趣的是,这个错误只出现在我的本地机器上。 使用 HTTPS 协议的测试环境中的相同代码工作正常。 继续... 我收到此错误的原因是因为我用于加载生成的 JSP 页面的 URL 是/location/t ...
[英]How to manage exceptions thrown in filters in Spring?
我想使用通用方法来管理 5xx 错误代码,让我们具体说一下当数据库在我的整个 spring 应用程序中关闭时的情况。 我想要一个漂亮的错误 json 而不是堆栈跟踪。 对于控制器,我有一个@ControllerAdvice class 用于不同的异常,这也捕获了数据库在请求中间停止的情况。 但这并 ...
[英]How to disable 'X-Frame-Options' response header in Spring Security?
我的 jsp 上有 CKeditor,每当我上传内容时,都会弹出以下错误: 我试过删除 Spring Security,一切都很顺利。 如何在 spring 安全 xml 文件中禁用此功能? <http>标签之间应该写什么 ...
[英]When using Spring Security, what is the proper way to obtain current username (i.e. SecurityContext) information in a bean?
我有一个使用 Spring Security 的 Spring MVC Web 应用程序。 我想知道当前登录用户的用户名。 我正在使用下面给出的代码片段。 这是公认的方式吗? 我不喜欢在这个控制器中调用静态方法 - 这违背了 Spring 的全部目的,恕我直言。 有没有办法将应用程序配置为注入当前 ...
[英]Spring Security exclude url patterns in security annotation configurartion
我有使用 java 配置方法配置了 Spring 安全性的 spring web 应用程序。 我想从身份验证中排除一些 URL 模式(例如:静态资源等)。 我之前使用 spring security xml 配置完成了此操作,但无法使用 java 配置解决,因为添加 antmatchers 无济于事 ...
[英]Handle spring security authentication exceptions with @ExceptionHandler
我正在使用 Spring MVC 的@ControllerAdvice和@ExceptionHandler来处理 REST Api 的所有异常。 它适用于 web mvc 控制器抛出的异常,但它不适用于 spring 安全自定义过滤器抛出的异常,因为它们在调用 controller 方法之前运行我有 ...
[英]An Authentication object was not found in the SecurityContext - Spring 3.2.2
我正在尝试从 class 调用受保护的方法,该方法在成功登录时实现ApplicationListener<AuthenticationSuccessEvent>接口(Spring 3.2.2 和 Spring Security 3.2.0 M1)。 这是我之前的问题。 该应用程序在以下 ...
[英]How to disable spring security for particular url
我正在使用无状态 spring 安全性,但在注册的情况下,我想禁用 spring 安全性。我禁用了使用 但它不起作用,我收到以下错误: 我认为这意味着 spring 安全过滤器正在工作 我的网址的顺序总是“/api/v1” 我的弹簧配置是 我的身份验证过滤器是 我的控制器是 我 ...
[英]Spring Security configuration: HTTP 403 error
我正在尝试按照 web 上的指南使用 Spring Security 来保护我的网站。 所以在我的服务器端我有以下课程。 我的WebSecurityConfigurerAdapter : 我的 controller: 让我非常困惑的是服务器不响应POST / DELETE方法,而GET方法工作正常。 ...
[英]How do I get the Session Object in Spring?
我对Spring和Spring安全性比较陌生。 我试图编写一个程序,我需要使用Spring安全性在服务器端验证用户, 我想出了以下内容: 我的用例是,当用户通过身份验证时,我需要放置一个属性,如: myUserObject是某个类的对象,我可以跨多个用户请求访问整个服 ...
[英]Spring 3.0 - Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
任何想法可能是什么原因? 无法找到XML架构命名空间的Spring NamespaceHandler [ http://www.springframework.org/schema/security] 这是我的applicationContext.xml: 在我的po ...
[英]Serving static web resources in Spring Boot & Spring Security application
我正在尝试开发 Spring Boot web 应用程序并使用 Spring security java 配置保护它。 按照 Spring 博客中的建议将我的 static web 资源放入“ src/main/resources/public ”后,我能够获得 static 资源。 即在浏览器中 ...