【发布时间】:2023-04-06 17:02:01
【问题描述】:
我正在尝试在我的项目中将 Spring Security 5 OAuth2/OIDC 与 GitLab 集成,并按照官方示例代码oauth2login,添加我的 Gitlab 配置,如下所示。
security:
oauth2:
client:
registration:
gitlab:
client-id: 0cef9527091bb2faec01610a0fb330e3a915672110cf3298ff3aadceaa8ab11f
client-secret: fd84439d06f7a2dabb5d5a64ac478211ab4009aa0fa62d478661a52f4234de72
authorization-grant-type: authorization_code
redirectUriTemplate: '{baseUrl}/login/oauth2/code/{registrationId}'
scope:
- openid
- api
clientName: GitLab
provider:
gitlab:
authorization-uri: https://gitlab.com/oauth/authorize
token-uri: https://gitlab.com/oauth/token
user-info-uri: https://gitlab.com/oauth/userinfo
jwk-set-uri: https://gitlab.com/oauth/discovery/keys
我在我的 Gitlab 设置账户中创建了一个应用程序,将它的授权回调 url 设置为:http://localhost:8080/login/oauth2/code/gitlab。
当我通过mvn spring-boot:run 运行应用程序时。并点击Gitlab,点击GitLab授权页面中的Authorize按钮。
然后页面返回到http://localhost:8080/login,控制台出现异常如下:
at position 15931.
at com.nimbusds.jose.util.JSONObjectUtils.parse(JSONObjectUtils.java:75) ~[nimbus-jose-jwt-5.4.jar:5.4]
at com.nimbusds.jose.jwk.JWKSet.parse(JWKSet.java:304) ~[nimbus-jose-jwt-5.4.jar:5.4]
at com.nimbusds.jose.jwk.source.RemoteJWKSet.updateJWKSetFromURL(RemoteJWKSet.java:145) ~[nimbus-jose-jwt-5.4.jar:5.4]
... 64 common frames omitted
它似乎没有重定向到所需的页面,而是Gitlab登录。
【问题讨论】:
标签: spring spring-boot spring-security oauth-2.0 gitlab