问题标签 [spring-security-rest]
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.
spring-boot - How to validate facebook authorization token and sign up user using Spring(java)
I am developing an app whose frontend is written using React.js and the backend REST API is written using the Spring framework. I wanted to add social logins to my website, so after days of googling and research, I understood that OAuth2 is the solution. I came to know that the frontend should handle getting the authorization token from the Resource Server(Facebook here) and my backend(java) should validate that token and connect with Facebook to get an access token. Then that access token should be stored in my database along with the user details(e.g email).
Here is my requirement, once the user clicks on the "Continue with Facebook" button, my app should create there account in my own database using details - email and Name(the signup feature). And later whenever they click on this button again, they will be logged in not sign up. The way other websites handle it.
As of now, I have the button working in my app, which brings me the authorization token from Facebook.
Can someone please guide me the path I should follow here.
Also, any special attention to some error handling I should follow.
spring - HttpSecurity 配置不适用于 Spring 上的 Keycloak 适配器
完整代码:https ://github.com/czetsuya/Spring-Keycloak-with-REST-API
我正在尝试在 Spring 中实现一个由 Keycloak (4.8.1) 保护的 REST API,带有一个仅承载客户端。
问题:configure(HttpSecurity http) 不受尊重,只要用户通过身份验证,REST 端点就可以访问。
例如,使用 .antMatchers("/admin*").hasRole("ADMIN"),/admin 应该只能由具有 ADMIN 角色的用户访问,但我可以使用 USER 角色访问。
我还尝试在 application.yml 中设置安全约束(但没有帮助):
将@EnableGlobalMethodSecurity 与@PreAuthorize("hasRole('ADMIN')") 结合使用可以解决问题,但真的没有其他办法了吗?
这是application.xml。
以下是对 pom 的依赖:
以及 SecurityConfig 类的一部分:
启用详细日志后。我发现正在应用 application.yml 中定义的安全约束,而不是 java 类中定义的约束。
现在的问题是如何使用 java 约束而不是定义的 application.yml。
java - 如何忽略特定 API 的 OncePerRequestFilter
我为令牌身份验证创建了一个自定义过滤器AuthenticationTokenFilter
,它由OncePerRequestFilter
. 我将一些 API 配置为SecurityConfig
我的AuthenticationTokenFilter
.
我在这里找到了类似的答案,但我已经忽略了WebSecurity
配置。那么,为什么我需要在过滤器级别上写相同的内容。
我在哪里做错了,或者我在错误的环境中。
spring - 使用 spring security 和 mongodb 进行 Rest 身份验证
我已经实现了一个Spring
应用程序,mongodb
现在我已经使用 Spring security 和 Mongodb 实现了 Rest 身份验证,现在我必须添加Authorization
标头,如果没问题,它只会显示来自 api 调用的数据Authorization
,从现在开始没问题,但我想知道如何获得这个值?我的意思是我想登录应用程序,我应该获得授权吗?如果不是,登录响应应该返回此授权以在下一次调用中使用它?我也读过aws token
of oauth2
,但是我真的很想知道这个过程,我的意思是,一个普通用户可以登录到应用程序然后通过授权拨打电话的流程是什么?
我的平台是:
数据库——MongoDB
服务器——春天
网络——角
应用——安卓
这是一个问答游戏项目,可以支持多游戏选项(超过 1 名玩家同时玩)
所以我需要了解的是从 APP / WEB 我必须打个电话让我们说 api/v1/login 然后发送用户和密码,好的,我必须创建 bcrypted 和 salt 的东西来存储它的部分在哪里进入数据库?我是否必须在应用程序上执行此操作,然后在登录调用中通过 JSON 发送例如 SHA 内容,或者最好将密码发送到服务器,以便服务器完成所有工作并将这些内容存储在数据库中?
oauth-2.0 - 保护 Rest API
我有两组 RestAPI 用于在两个不同框架上开发的同一应用程序。
使用 OAuth 2 保护 SpringBoot 上的一个。在 RestAPI 的 Jooby 微框架上开发的第二组 API。
由于Jooby 上的服务不安全,我该怎么做?这样这两组 API 都是安全的。
登录与 SpringBoot App 和 OAuth 2.0 一起使用,同样的用户凭据也应该用于 jooby api。为这两个 API 集放置某种通用网关是否有意义?
grails - Grails spring security rest插件的过滤器链没有按预期工作
我正在使用 grails 2.5.4 版和 spring security rest 插件 1.5.4 版。我在 config.groovy 中添加了过滤器链图
它有效,但是当我获取 springSecurityServie 的主要对象时,它为我提供了匿名用户
但是当我把它作为过滤器链时它工作正常
java - Spring Security 和 Oauth2 的误区
我目前正在开发一个 Spring Boot 应用程序,我的任务是确保应用程序的安全性。他们建议使用 OAuth2 令牌身份验证,即使在我设法通过其他 spring 安全教程创建安全性的其他应用程序中也是如此。这是根据我在不同来源找到的教程创建的:
在测试登录时,我使用带有以下参数的邮递员:
http://localhost:8080/oauth/token?grant_type=password
标头:基本 btoa(pfjA@Dmin,4gM~$laY{gnfShpa%8Pcjwcz-J.NVS)
内容类型:应用程序/x-www-form-urlencoded
正文:form-data -> 用户名并传递应该是来自数据库的有效用户凭据。如果凭据正确,用户将做出响应
“access_token”:“f0dd6eee-7a64-4079-bb1e-e2cbcca6d7bf”,
"token_type": "承载者",
“expires_in”:86399,
“范围”:“读写信任”
现在我必须将此令牌用于所有其他请求,否则我无权使用该应用程序。
我的问题:这是其他版本的 Spring Security 还是什么?我读到了 OAuth2 身份验证,但我读到一个应用程序可以同时具有 Spring Security 和 OAuth2。如果我们决定实施应用程序安全的方式有问题,有人可以解释一下吗?
非常感谢!
java - 配置 SpringSecurity 以使用 JWT
我有一个受 SpringSecurity 3.2.2 保护的个人 Web 项目(Struts-Hibernate),我一直在阅读有关 JWT 的内容,所以我想改进我的项目以使用它,我一直在阅读一些教程,但我不知道如何去做吧。
现在,我使用 springSecurity xml 文件加载配置,其中一个名为 CustomProviderAuthentication 的类负责根据情况抛出异常或返回 UsernamePasswordAuthenticationToken(来自 Spring)。
这是我的 springSecurity.xml:
我的疑问是:
1) 用户登录后,我应该在哪里返回生成的令牌?
2) 如何配置 spring 安全过滤器以使用令牌而不是会话?
- 3) 如果令牌不存在,我如何配置 Spring 安全过滤器以重定向到登录?
提示表示赞赏。
spring - spring security JWT 实现是否处理 alg:none 攻击?
JWT 实现可能会受到不同的攻击,其中之一就是攻击(在此处alg:none
查看更多详细信息)。
我spring-security-jwt
在我的 pom.xml 文件中使用了依赖项,但无法确定此实现是否处理了alg:none
攻击。
Spring Security JWT 实现是否缓解了这种攻击?