Grafana Oauth统一认证

2021/4/12 18:58:50

本文主要是介绍Grafana Oauth统一认证,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

使用grafana auth.generic_oauth方式访问grafana dashboards,记录配置及接口开发过程。以供以后查阅

需求:在自建平台上以认证用户,跳转至grafana,且是已登陆状态。

根据官方文档介绍,有三种方法实现:

  1. 使用API KEY方式;需要解决跨域问题。

  2. 配置打开匿名登陆方式,不符合需求。

  3. 使用auth.generic_oauth方式,需要在自建平台开发统一认证接口。


一、Grafana Oauth配置

  1. 配置认证接口跳转域名:

[server]

# Protocol (http, https, h2, socket)

protocol = http


# The ip address to bind to, empty will bind to all interfaces

http_addr = 10.106.223.203


# The http port to use

http_port = 3000


# The public facing domain name used to access grafana from a browser

domain = 10.106.223.203      # 我这里是测试环境,IP地址或正式域名都可以,认证接口可以访问到就行


# Redirect to correct domain if host header does not match domain

# Prevents DNS rebinding attacks

enforce_domain = false


# The full public facing url

root_url = %(protocol)s://%(domain)s:%(http_port)s/         # 如果使用的是正式域名,可能不需要“:%(http_port)s/”端口信息,删掉就行

2. Grafana Oauth配置

[auth.generic_oauth]

name = OAuth

enabled = true       # 默认是false,改为true。打开oauth认证

allow_sign_up = true

client_id = panda   # 客户端ID,自行决定使用方式。我这里使用client_id去验证自建平台中是否存在这个用户,并以这个用户去登陆Grafana

client_secret = panda@example.com     # 没看到GET或POST请求中有这个参数。字面意思是验证client密码的

scopes = user:email      # 统一认证接口回传的参数域'{"name": "panda", "email": "panda@example.com"}'

#scopes = user:email:org

email_attribute_name = email:primary       # 不知道怎么用

email_attribute_path =

login_attribute_path =

role_attribute_path =

id_token_attribute_name =

auth_url = http://10.106.223.203:7000/sso/oauth/authorize/       # 自建平台认证接口

token_url = http://10.106.223.203:7000/sso/oauth/token/          # 自建平台用户token生成接口

api_url = http://10.106.223.203:7000/sso/oauth/user/                # 自建平台验证token,并回传用户信息接口

allowed_domains = 

#allowed_domains = 10.106.223.203

team_ids =

allowed_organizations =

tls_skip_verify_insecure = false

tls_client_cert =

tls_client_key =

tls_client_ca =




这篇关于Grafana Oauth统一认证的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程