Grafana: front page via API Key from Grafana login access

jast_zsh 2023-01-25 19:26:28 阅读数:897

grafanapageapikeygrafana

场景

Platform to integrategrafana,Want to bypass the user login,Now know that there are2个方法.
前提:先修改配置defaults.ini/grafana.ini允许嵌入

allow_embedding = true

One is to use anonymously,最简单方便

This solution is the premise of your company allow anonymous logingrafana(其实我觉得没啥问题)But from a security point of view is not so good,那好,接着往下看吧.

二是使用grafana颁发一个API Key.

在这里插入图片描述

curl -H "Authorization: Bearer eyJrIjoiT2x0Zmhua3BCa2Z6TXpWUnBIT3UxSlV0M0lnWEhVYUYiLCJuIjoiZGV2b3BzcGxhdGZvcm0iLCJpZCI6MX0=" http://127.0.0.1:3000/api/dashboards/home

到这里就清晰了,只要增加一个Authorization就可以,At the very least interface access no problem.

问题:
1、After the first problems is the proxy browser preview(即OPTIONS请求)过不去,那还玩啥,先过滤掉,看文末nginx配置.
2、vue中使用iframeThe browser cross-domain problems

就加个nginx,配置允许跨域访问.The access is ok,But in such a error.

在这里插入图片描述
解决方法:Do not use the browser non-trace mode access,就可以访问
在这里插入图片描述

5、nginx配置

server {

listen 3000;
server_name localhost;
location / {

root html;
index index.html index.htm;
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods '*';
add_header Access-Control-Allow-Credentials true;
proxy_set_header 'Authorization' 'Bearer eyJrIjoiajNERTZDZ1BUek5IMDFwenJhdGhudWtlejB2cDF4ZWMiLCJuIjoidGVzdCIsImlkIjoxfQ==';
proxy_pass http://10.8.10.23:3000;
# rewrite ^/(.*) /$1 break;
proxy_set_header Host $host;
if ($request_method = OPTIONS) {

return 200;
}
# proxy_buffer_size 128k;
# proxy_buffers 32 128k;
# proxy_busy_buffers_size 128k;
#server_name_in_redirect off;
#proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

参考: https://blog.csdn.net/qq_16240085/article/details/120996841

版权声明:本文为[jast_zsh]所创,转载请带上原文链接,感谢。 https://qdmana.com/2023/025/202301251921570161.html