我将 Grafana 中的图表嵌入到我的 HTML 页面的 iframe 中。
它一直要求我在 iframe 中输入 un/pw。
如何绕过登录?
有没有办法在代码中绕过它?
这是 Grafana 中的设置吗?
我进一步探索,找到了 API 部分,创建了一个 API 密钥,现在我有了密钥令牌。
eyJrIjoiMnpVSVA***********QiOjF9
如何使用上面的键👆🏼将图表嵌入到我的 iframe 中?
[auth.anonymous]
# enable anonymous access
enabled = true
# set to true if you host Grafana behind HTTPS. default is false.
cookie_secure = true
# set cookie SameSite attribute. defaults to `lax`. can be set to "lax", "strict" and "none"
cookie_samesite = none
# set to true if you want to allow browsers to render Grafana in a <frame>, <iframe>, <embed> or <object>. default is false.
allow_embedding = true
然后重新启动grafana或PC。
您不能将
API key
用作 GUI
。如果您不想允许“匿名身份验证”,那么最好的选择是“身份验证代理”,您可以在其中实现自己的自定义业务逻辑进行身份验证。
您将完全自由地设置身份验证代理,如何将身份验证信息(JWT 令牌、cookie、密钥)传递给身份验证代理,身份验证代理将仅添加标头(例如 X-WEBAUTH-USER
),该标头将用作Grafana 中的用户身份。
如果您只想显示 Grafana 中的一些图表,则无需使用 API 密钥。
grafana.ini
文件(/etc/grafana/grafana.ini)中的一些配置设置。
以下是您需要的配置:
[auth.anonymous]
# enable anonymous access
enabled = true
# specify organization name that should be used for unauthenticated users
org_name = ORGANIZATION
# specify role for unauthenticated users
org_role = Viewer
[auth]
# Set to true to disable (hide) the login form, useful if you use OAuth
disable_login_form = true
[security]
# set to true if you want to allow browsers to render Grafana in a <frame>, <iframe>, <embed> or <object>. default is false.
allow_embedding = true
在 Grafana 网站的
Server Admin页面上,转到Orgs
,您的主要组织名称应与您在上面配置中设置的相同 (org_name = ORGANIZATION
)。
保存所有设置并重新启动 grafana-server,就可以开始了!