问题标签 [spring-security-oauth2]

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 投票
1 回答
4512 浏览

java - User Registration & Login | SSO using Spring Security OAuth 2.0

I am trying to implement user registration and log in flow | SSO using Spring Security Oauth 2.0 and Google as the authentication provider.

  • How should I initiate registration and login flow? What filter needs to be applied?
  • In registration flow, I will needs user's details (name, email) that are part of successful authorization response, to be persisted in my local database. How do I handle that?

  • What's the purpose of oauth2:client id="oauth2ClientFilter" ?

This is how my application context file looks like:-

EDIT

I did implemented same use case using Spring Security OpenID by:-

  1. Declaring openid:form tag with exchange attributed configured
  2. Extend the UserDetailsService as described here.

I am looking for equivalent configuration for Oauth 2.0.

0 投票
2 回答
28855 浏览

access-token - 将 Spring 的 Token Store 实现为 MySQL 文件的步骤是什么?

我有一个当前使用 Spring OAuth 2.0 In Memory Token Store 的应用程序。我需要将 Spring Security OAuth 2.0 JAR 转换为使用持久文件而不是内存中的文件,以确保访问令牌在服务器重新启动时有效。Spring OAuth 2.0 JAR 提供了使用 JdbcTokenStore 方法支持 MYSQL 数据库的例程,但我找不到任何说明如何更改默认配置(使用 InMemoryTokenStore 方法)以利用受支持的 Jdbc 方法的文档。

我想听听已经实现 Spring Security OAuth 2.0 JdbcTokenStore 方法的人的意见,他们可以提供执行此操作所需的配置示例,也可以将我指向描述该过程的文档。我在互联网上到处搜索,但找不到任何此类文档。

我已经找到了 Token Store 的 Spring Security OAuth 2.0 模式文件,如果有人感兴趣的话,只能在 Test Resource 目录中找到。任何 Pivotal 文档网站都没有记录它的存在。如有必要,我可以通读 Pivotal 源代码的其余部分,但我希望有人可以让我免于使用此路径。

提前感谢您提供的任何帮助。

0 投票
1 回答
4501 浏览

java - 如何使用 Spring 在 OAuth2 身份验证中生成客户端密钥

我正在为我的应用程序使用 Spring 为 OAuth2 创建 api,但规范 ( https://www.rfc-editor.org/rfc/rfc6749 ) 和 Spring OAuth2 文档中都没有关于如何生成客户端密码的内容。

有人知道吗?

0 投票
1 回答
321 浏览

java - 重叠 URL 范围的 Spring 安全性

我不知道如何配置 spring security 来为重叠的 URL 指定不同的 ROLE。

我需要在 /app/ws** 上接受具有角色 ROLE_WEBSERVICE 的用户,即使此用户没有用户 ROLE_ADMIN。

你能指出我正确的文件位置吗?我找不到。谢谢。

0 投票
0 回答
1071 浏览

spring-mvc - SpringMVC 与 OAuth2 到 Struts2 与 OAuth2

将 OAuth2 配置从 SpringMVC 应用程序迁移到 Struts2 应用程序时应考虑哪些要点?

在这个 SpringMVC 应用程序示例之后,我一直在尝试在我的 Struts2 应用程序中实现 OAuth2 。

我一直在删除代码以使示例更简单,现在它们之间的唯一区别是org.springframework.web.servlet.DispatcherServlet示例应用程序中的。

除了两个应用程序具有相同的 OAuth 配置外,我的应用程序不断抛出以下异常:

org.springframework.security.oauth2.client.resource.UserRedirectRequiredException:需要重定向才能获得用户的批准

当示例应用程序运行时。

0 投票
2 回答
7894 浏览

spring-security - Spring Security JWT 和 Oauth2

我想使用 Spring Security 设置一个中央身份验证/授权服务器,我可以从中获取 JWT 令牌,然后我可以使用它来访问另一个 Spring Security 备份的 REST 服务器上的受限资源。

这是我的流程:

1) HTML JS / Mobile 等客户端在身份验证服务器上进行身份验证以获取 JWT 令牌 2) 客户端将此令牌在 HTTP 标头中发送到 REST 服务器以获得对安全资源的访问权限

我认为 JWT 最适合这种情况,因为它可以包含所有相关数据,并且 REST 服务器可以是完全无状态的,只需解码令牌即可在 REST 服务器上获取所有必要的数据(角色、客户端 ID、电子邮件......)。

Oauth2 是正确的选择吗?如果是这样,有人可以指出我正确的方向吗?如果 JWT 不是正确的选择,我愿意接受其他解决方案:) 我应该提到,在我的情况下,也可以在 REST 服务器上从数据库加载客户端信息,但它不应该负责验证用户(意味着没有用户名/密码检查,只是令牌解码/验证......)

0 投票
5 回答
22598 浏览

java - 如何在春季安全中撤销身份验证令牌?

在注销控制器中,我尝试编写很多代码组合。现在我有这个:

但是在提供代码执行令牌后仍然有效。

我错了什么?如何最终撤销令牌?

0 投票
1 回答
461 浏览

java - Spring Security OAuth 协助 - openshift jbossews

我会提前道歉;这是我第一次使用 Spring Security。

我遇到了一个问题,我的 open shift jbossews spring 上下文无法启动,但在我的独立 tomcat 服务器上完美运行。我正在尝试使用令牌授权与我们的 API 进行通信,并为用户提供基本的表单身份验证。如果您需要更多信息,请告诉我。

在 tomcat 上,我可以查看网络服务器,让我的 curl 获取我的令牌并调用 /api/** 中的服务。

堆栈跟踪

web.xml

oauth-context.xml

安全上下文.xml

servletApp-context.xml

0 投票
0 回答
643 浏览

spring-security - Can I use spring integration and spring security to create OAuth 2.0 Reverse Proxy?

Spring Integration Yoda out there

I am working on enabling REST web service calls to JavaScript widgets launched from JSF application. The implementation of the services already exists on REST easy and does not include OAuth 2.0 security. The goal is to leave the services as is while passing all JS calls through security gateway.

To achieve the goal, I started with my 1st prototype on Mule Enterprise with their OAuth augmentation of spring security and HTTP inbound/outbound endpoints. This was the Mule suggested approach.

After that, my 2nd prototype is on Spring Security/Spring integration. And is essentially the same OAuth 2.0 provider, security rules and HTTP inbound/outbound gateways. While working with spring support I was told that this would not work (reasons below). From my understanding Mule and SI are very similar and I should be able to replace one "glue" with another. This may not be the envisioned use of SI, I would like to validate if I can still use it.

Also, what is the configuration of the gateways that will essentially create a pipe and reduce the overhead?

Thank you for taking time to validate or disprove my theory.

Irena

Configuration code excerpt:

Support reply:

SI is probably not suitable for this kind of functionality. Here are the reasons:

  • spring integration uses "Message" type for messages. Everything that goes into a channel has to be of type "Message". This effectively means every HttpRequest needs to be converted to SI Message and vice versa. The same with HttpResponse.

  • spring integration does not directly expose HttpRequest objects. Rather they are processed implicitly internally in SI which simplifies Request processing. i.e. simple access to request parameters, header values, path variables... but in your case this is a complication. And the complication is visible in the inbound gateway configuration.

  • the more generic problem might occur later, especially in case of large requests (i.e. file upload). All such requests will be processed internally in memory in the proxy and that might cause problems

  • there might be a concurrency performance problems as every request will be processed in separate thread, however this problem is not SI specific

I gave you some reasons to reconsider using SI for proxy purposes. I'm not sure what inspired you to make this decision, have you seen any example, tutorial or blog post regarding this? Please let me know if yes, I'll look at it.

It's up to you what decision you make going forward. But at the same time I'm not giving you any idea as what to use instead as this is beyond the scope the technical support. But in case you're interested I can contact our engineering and arrange a consultancy service for you.

0 投票
1 回答
564 浏览

java - 浏览器 REST 客户端要求提供凭据,但 RESTEasy 服务失败

我使用 Spring security Oauth2 在 java 中创建了一个 RESTEasy 服务,用于身份验证和令牌生成。一切对我来说都很好,但是当我尝试访问我的服务以从浏览器 REST 客户端生成令牌时,它会要求提供凭据,但它会失败,但同时如果我通过 Java 中的 HTTPClient 访问相同的服务,它对我有用,

java中的Http客户端为我工作,但在浏览器休息客户端中它要求凭据并返回错误请求 浏览器休息客户端响应

知道为什么会这样吗?

我的配置,