Yearning icon indicating copy to clipboard operation
Yearning copied to clipboard

集成keycloak认证报错

Open wang-xiaowu opened this issue 2 years ago • 5 comments

Describe 描述

  • config.toml
[Oidc]
Enable = true
ClientId = "yearning"
ClientSecret = "xxx"
Scope = "email openid profile"
AuthUrl = "https://keycloak.extension.sopei/realms/sopei-devops/protocol/openid-connect/auth"
TokenUrl = "https://keycloak.extension.sopei/realms/sopei-devops/protocol/openid-connect/token"
UserUrl = "https://keycloak.extension.sopei/realms/sopei-devops/protocol/openid-connect/userinfo"
RedirectUrL = "https://yearning.extension.sopei/oidc/_token-login"
UserNameKey = "preferred_username"
RealNameKey = "name"
EmailKey = "email"
SessionKey = "session_state"
  • 报错日志
yearning-yearning-1  |  [Info] 2023-04-19 14:26:30 "url":"/" "method":"GET" "status":200 "protocol":"HTTP/1.1" "remote_ip":"116.3.194.203" "bytes_in": "0 bytes" "bytes_out": "380 bytes"
yearning-yearning-1  |  [Info] 2023-04-19 14:26:31 "url":"/" "method":"GET" "status":200 "protocol":"HTTP/1.1" "remote_ip":"116.3.194.203" "bytes_in": "0 bytes" "bytes_out": "380 bytes"
yearning-yearning-1  |  [Info] 2023-04-19 14:26:34 "url":"/fetch" "method":"GET" "status":200 "protocol":"HTTP/1.1" "remote_ip":"116.3.194.203" "bytes_in": "0 bytes" "bytes_out": "48 bytes"
yearning-yearning-1  |  [Info] 2023-04-19 14:26:34 "url":"/oidc/state" "method":"GET" "status":200 "protocol":"HTTP/1.1" "remote_ip":"116.3.194.203" "bytes_in": "0 bytes" "bytes_out": "306 bytes"
yearning-yearning-1  |  [Critical] 2023-04-19 14:26:49 (/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/middleware/recovery.go:33) [PANIC RECOVER] runtime error: invalid memory address or nil pointer dereference Traceback:
yearning-yearning-1  | 	/usr/local/go/src/runtime/panic.go:260
yearning-yearning-1  | 	/usr/local/go/src/runtime/panic.go:259
yearning-yearning-1  | 	/Users/henryyee/PersonalProjects/Yearning-go/src/handler/login/oidcLogin.go:72
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/context.go:122
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/middleware/gzip.go:66
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/context.go:122
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/middleware/recovery.go:38
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/context.go:122
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/middleware/logger.go:58
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/context.go:122
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/middleware/cors.go:96
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/context.go:122
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/yee.go:207
yearning-yearning-1  | 	/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/yee.go:133
yearning-yearning-1  | 	/usr/local/go/src/net/http/server.go:2948
yearning-yearning-1  | 	/usr/local/go/src/net/http/server.go:1992
yearning-yearning-1  | 	/usr/local/go/src/runtime/asm_amd64.s:1595
yearning-yearning-1  | 
yearning-yearning-1  |  [Error] 2023-04-19 14:26:49 (/Users/henryyee/go/pkg/mod/github.com/cookie!y/[email protected]/context.go:140) /oidc/_token-login?state=367126378168&session_state=b3c442d1-0881-4961-9390-614fd387b05d&code=133e362f-38f9-45c0-a21c-8e557fb12313.b3c442d1-0881-4961-9390-614fd387b05d.b7b54bb3-dd6b-44f1-80c0-46a49b70f5ee Internal Server Error
yearning-yearning-1  |  [Warn] 2023-04-19 14:26:49 "url":"/oidc/_token-login" "method":"GET" "status":500 "protocol":"HTTP/1.1" "remote_ip":"116.3.194.203" "bytes_in": "0 bytes" "bytes_out": "21 bytes"
yearning-yearning-1  |  [Warn] 2023-04-19 14:26:49 "url":"/favicon.ico" "method":"GET" "status":404 "protocol":"HTTP/1.1" "remote_ip":"116.3.194.203" "bytes_in": "0 bytes" "bytes_out": "-1 bytes"

To Reproduce 如何复现 配置完成后,点击oidc认证,正常跳转至keycloak登录,再keycloak登录成功后跳转回来报错如上信息

Expected behavior 期望的结果

Screenshots 截图 keycloak配置,其他基本为默认,keycloak在yearning登录报错期间没有access denied之类的日志

image

image

  • 补充接口返回字段信息

image

Desktop (please complete the following information): 环境

  • OS: [e.g. iOS] windows
  • Browser [e.g. chrome, safari] chrome
  • Version [e.g. 22] 3.1.3
  • keycloak version:21.0.1

Additional context 其他 Add any other context about the problem here.

wang-xiaowu avatar Apr 19 '23 06:04 wang-xiaowu

问题补充:域名是映射的host

image

wang-xiaowu avatar Apr 20 '23 05:04 wang-xiaowu

同样的问题,将endpoint全改成http就好,开发环境自签名证书引发的

r0y4d3v avatar Apr 14 '24 11:04 r0y4d3v

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I have the same problem. Just change all endpoints to http. The problem is caused by the self-signed certificate of the development environment.

Issues-translate-bot avatar Apr 14 '24 11:04 Issues-translate-bot

大概率是安装服务器请求不通配置的 Keycloak 链接。可以 使用 ping 命令试一下。我就是这个问题。 实在不行可以本地源码启动,添加日志调试:本地启动教程可查看:https://blog.texous.cn/archives/46a6c377-4525-4009-b795-58080c8dac5f#%E6%9C%AC%E5%9C%B0%E6%9E%84%E5%BB%BA%E5%90%AF%E5%8A%A8%E5%8F%82%E8%80%83

texousliu avatar Jan 07 '25 07:01 texousliu

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


There is a high probability that the installation server request cannot pass the configured Keycloak link. You can try it using the ping command. That's my problem. If it really doesn't work, you can start it locally with source code and add log debugging: the local startup tutorial can be viewed at: https://blog.texous.cn/archives/46a6c377-4525-4009-b795 -58080c8dac5f#%E6%9C%AC%E5%9C%B0%E6%9E%84%E5%BB%BA%E5%90%AF%E5%8A%A8%E5%8F%82%E8%80% 83

Issues-translate-bot avatar Jan 07 '25 07:01 Issues-translate-bot