grafana登录失败无法从cookie中获取用户信息

背景

grafana从版本6.3升级到7.2.1,通过chrome浏览器无法登录,需要清除浏览器缓存会话才可以正常登录,这样用户体验并不好,不可能使得所有用户都要在登录前都清除一下浏览器缓存会话。

chrome 版本信息

Google Chrome86.0.4240.198 (正式版本) (64 位) (cohort: Stable)
修订版本d8a506935fc2273cfbac5e5b629d74917d9119c7-refs/branch-heads/4240@{#1431}
操作系统Windows 10 OS Version 1909 (Build 18363.1198)
JavaScriptV8 8.6.395.25
Flash32.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

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

独步秋风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值