几天以来,我一直在尝试将OneLogin OIDC与SpringBoot连接起来,但现在还不能。
我是OIDC的新手,所以,也许我缺少一些基本知识。
我已按照“ OpenLogin管理”面板中的以下说明进行操作: https://developers.onelogin.com/openid-connect/connect-to-onelogin
尝试了(主分支)中的代码: https://github.com/onelogin/onelogin-oidc-java/tree/master/spring-boot-app
发现几天前在同一存储库中有一个拉取请求,其解决方案非常不同(karson-demo-2019-oct分支): https://github.com/onelogin/onelogin-oidc-java/tree/karson-demo-2019-oct/spring-boot-app
但不幸的是,该解决方案无法正常工作。
我使用的是karson-demo-2019-oct分支的相同代码,仅向YAML文件添加了一些属性(请参见下文)
我在OneLogin管理面板中将重定向URI配置为https://localhost:8081/
。
我转到https://localhost:8081/
后,单击“单击此处”,出现以下错误:
oops! something went wrong
error: redirect_uri_mismatch
error_description: redirect_uri did not match any client's registered redirect_uris
state: bi14wv
URL类似于:
https://openid-connect.onelogin.com/oidc/auth?client_id=XXXXXXXXXXXXXXXXXXXXXX&redirect_uri=https://localhost:8081/login&response_type=code&scope=openid%20profile%20email&state=bi14wv
如果我在OneLogin“管理”面板的“重定向URI”列表中添加https://localhost:8081/login
(最后带有“ login”),则会发生以下情况:
当我转到https://localhost:8081/
并单击“单击此处”时,将显示OneLogin表单。然后,我用我的用户登录,然后出现以下消息:
Whitelabel Error Page
This application has no explicit mapping for /error,so you are seeing this as a fallback.
Tue Nov 05 15:32:02 PST 2019
There was an unexpected error (type=Unauthorized,status=401).
Unauthorized
此错误页面的网址类似于:
https://localhost:8081/login?code=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&state=ZZZZZ
如您所见,在指定的重定向URI(https://localhost:8081
)之后有一个“登录”,我认为这可能是由于在解决方案中编写了index.html的方式。
由于OneLogin门户网站不接受带有http(仅https)的重定向URI,因此我需要在application.yml中添加几行以启用SSL:
security:
oauth2:
client:
clientId: XXXXXXXXXXXXXXXXXXXXXX
clientSecret: XXXXXXXXXXXXXXXXXXXXX
accessTokenUri: https://openid-connect.onelogin.com/oidc/token
userauthorizationUri: https://openid-connect.onelogin.com/oidc/auth
tokenName: access_token
authorizedGrantTypes: authorization_code
authenticationScheme: form
clientAuthenticationScheme: form
scope: openid,profile,email
resource:
userInfoUri: https://openid-connect.onelogin.com/oidc/me
server:
port : 8081
ssl:
key-store-type: pkcs12
key-store: classpath:XXXXXXXXXXXX
key-store-password: XXXXXXXXXXXX
key-alias: XXXXXXXXXXX
这是正确的吗? 您能帮我找出我想念的东西吗?