背景
grafana从版本6.3升级到7.2.1,通过chrome浏览器无法登录,需要清除浏览器缓存会话才可以正常登录,这样用户体验并不好,不可能使得所有用户都要在登录前都清除一下浏览器缓存会话。
chrome 版本信息
Google Chrome 86.0.4240.198 (正式版本) (64 位) (cohort: Stable) 修订版本 d8a506935fc2273cfbac5e5b629d74917d9119c7-refs/branch-heads/4240@{#1431} 操作系统 Windows 10 OS Version 1909 (Build 18363.1198) JavaScript V8 8.6.395.25 Flash 32.0.0.453
服务端报错信息
t=2020-11-24T18:45:34+0800 lvl=info msg="Successful Login" logger=http.server User=admin@localhost
t=2020-11-24T18:45:34+0800 lvl=eror msg="Failed to look up user based on cookie" logger=context error="user token not found"
问题排查
Cookie path
Starting from Grafana v7.0.0, the cookie path does not include the trailing slash if Grafana is served from a subpath in order to align with RFC 6265. However, stale session cookies (set before the upgrade) can result in unsuccessful logins because they can not be deleted during the standard login phase due to the changed cookie path. Therefore users experiencing login problems are advised to manually delete old session cookies, or administrators can fix this for all users by changing the login_cookie_name, so the old cookie would get ignored
从Grafana v7.0.0开始,如果为了与RFC 6265对齐从一个子路径提供Grafana, cookie路径就不包括末尾的斜杠。但是,陈旧的会话cookie(在升级之前设置)可能导致登录不成功,因为由于更改了cookie路径,在标准登录阶段无法删除它们。因此,建议遇到登录问题的用户手动删除旧的会话cookie,或者管理员可以通过更改login_cookie_name为所有用户修复这个问题,这样旧的cookie就会被忽略
简单翻译一下就是你从6版本跨度到7版本陈旧的会话cookie不启作用了。
如何解决
两种方法
客户端清除浏览器会话缓存
服务端修改login_cookie_name后重启grafana服务
验证
打开浏览器开发者模式会发现新增一个新的会话名称grafana_monitor_session
资料参考:
https://grafana.com/docs/grafana/latest/installation/upgrading/#cookie-path
https://grafana.com/docs/grafana/latest/administration/configuration/#cookie_secure
本文来自:CSDN博客
感谢作者:CSDN博客
查看原文:grafana登录失败无法从cookie中获取用户信息_grafana error while signing in user_独步秋风的博客