Grafana generic oauth未按预期工作


New to oAuth and Grafana
Grafana v9.0.0-pre
oAuth server - https://github.com/authlib/example-oauth2-server

通用oauth配置

[auth.generic_oauth]
name = OAuth
icon = signin
enabled = true
allow_sign_up = true
client_id = <>
client_secret = <>
scopes = profile
empty_scopes = false
email_attribute_name = 
email_attribute_path =
login_attribute_path =
name_attribute_path =
role_attribute_path =
role_attribute_strict = false
groups_attribute_path =
id_token_attribute_name =
team_ids_attribute_path =
auth_url = http://127.0.0.1:5000/oauth/authorize
token_url = http://127.0.0.1:5000/oauth/token
api_url = http://127.0.0.1:5000/api/me
teams_url =
allowed_domains =
team_ids =
allowed_organizations =
tls_skip_verify_insecure = true
tls_client_cert =
tls_client_key =
tls_client_ca =
use_pkce = false

oAuth Client Config

Client Info
client_id: <>
client_secret: <>
client_id_issued_at: <>
client_secret_expires_at: 0
Client Metadata
client_name: grafana
client_uri: http://localhost:3000/
grant_types: ['authorization_code', 'password']
redirect_uris: ['http://localhost:3000/login/generic_oauth']
response_types: ['code']
scope: profile
token_endpoint_auth_method: client_secret_basic

我能够在Grafana UI中看到Sign in with OAuth按钮,并且也可以登录。它重定向到oAuth服务器登录(如果还没有登录),然后请求同意,重定向回Grafana并登录用户。

问题:

  1. 从oAuth服务器注销对Grafana没有影响,用户仍在登录
  2. 从Grafana和oAuth过期的认证令牌对登录的用户没有影响,他们继续登录
  3. 从oAuth服务器撤销令牌(手动更新DB)对登录的用户没有影响,他们继续登录

预期:

  1. 如果令牌过期,退出Grafana
  2. 如果令牌被撤销,退出Grafana

这里的期望正确吗?解释一下泛型oAuth在Grafana中应该如何表现会很有帮助。

你的期望不正确。

1)。访问令牌由Grafana为自己的会话cookie交换,会话cookie可能有不同的生存期。很可能你的IDP服务器也提供了刷新令牌,所以Grafana可以刷新访问令牌,所以用户不需要注销。

2)。这是可能的,但必须由使用的IDP和应用程序(Grafana)实现反向通道注销= IDP广播消息;令牌被撤销;给客户端(Grafana),他们需要处理这些信息。Backchannel logout在Grafana中没有实现。

通常,访问令牌应该有较短的生命周期(例如5分钟),并且令牌刷新应该在适当的地方。如果存在令牌撤销,则令牌刷新将失败,应用程序应注销用户。这是典型的用例,当不支持反向通道注销时。

最新更新