如何为 OAuth2 提供自定义客户端身份验证方案 属性

How can I provide a custom client-authentication-scheme property for OAuth2

我正在编写一个 Spring 启动应用程序,它需要向另一个组提供的 OAuth2 客户端验证用户身份。 OAuth2客户端提供了两种认证方案:formsso。我正在构建的应用程序需要使用 sso 方案,因为该应用程序没有将用户重定向到登录表单的选项。

Spring security 包含一个枚举,它提供了可以使用的 security.oauth2.client.client-authentication-scheme 选项,sso 没有提供,所以我需要能够以某种方式扩展它或提供一个自定义选项。

最终,应用程序需要生成一个 GET 请求,该请求将采用以下形式:https://iapi.mycompany.com/authentication-service/v2/authorize?response_type=code&client_id=myClientIdHere&redirect_uri=https:/myclient.mycompany.com/redirect&state=someStateString&login_method=sso

据我所知,实际上只有 login_method=sso 部分是需要生产的自定义部分。关于如何说服 Spring 安全人员为我做这件事有什么想法吗?

原来解决方案是注释掉 application.properties 中的 security.oauth2.client.client-authentication-scheme 属性 并将 ?login-method=sso 附加到 security.oauth2.client.user-authorization-uri 属性 .

最终 属性 看起来像这样:

security.oauth2.client.user-authorization-uri=https://iapi.mycompany.com/authentication-service/v2/authorize?login_method=sso