Grafana 配置实时开通的LDAP认证-基于AD

本文详细介绍了如何在Grafana9-10版本中使用WindowsServer2022域控(AD)进行统一认证,包括全局启用LDAP,配置ldap.toml文件,以及用户组权限映射。步骤涉及修改Grafana.ini和ldap.toml文件中的关键参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

介绍

本教程适用于9-10版本的Grafana,域控(AD)使用Windows Server 2022搭建,域控等级为 2016。

域控域名为 songxwn.com

最终实现AD用户统一认证,统一改密,Grafana用户自动添加。权限由Grafana控制

全局开启LDAP

修改/etc/grafana/grafana.ini 文件

vim /etc/grafana/grafana.ini

修改并取消注释以下参数即可


[auth.ldap]
enabled = true
config_file = /etc/grafana/ldap.toml
allow_sign_up = true

配置LDAP对接文件

修改/etc/grafana/ldap.toml文件

vim /etc/grafana/ldap.toml

文件示例

  • host 为域控制器地址。

  • port 默认为 389即可,不开启加密

  • bind_dn 为域控账号,用于搜索域控账号

  • bind_password 为上面账号的密码

  • search_filter AD固定为(sAMAccountName=%s)

  • search_base_dns 为域控路径,可以去ADSI查看

用户组权限映射 - [[servers.group_mappings]]

  • group_dn 为用户组的路径
  • org_role 为在Grafana用户组的权限,有 Admin、Editor、Viewer (管理、编辑、只读)

如下面所示,我将it1 映射为了Editor,it2 组为Viewer

PS:具体路径建议用ADSI工具查看。


[[servers]]
# Ldap server host (specify multiple hosts space separated)
host = "songxwn.com"
# Default port is 389 or 636 if use_ssl = true
port = 389
# Set to true if LDAP server should use an encrypted TLS connection (either with STARTTLS or LDAPS)
use_ssl = false
# If set to true, use LDAP with STARTTLS instead of LDAPS
start_tls = false
# The value of an accepted TLS cipher. By default, this value is empty. Example value: ["TLS_AES_256_GCM_SHA384"])
# For a complete list of supported ciphers and TLS versions, refer to: https://go.dev/src/crypto/tls/cipher_suites.go
tls_ciphers = []
# This is the minimum TLS version allowed. By default, this value is empty. Accepted values are: TLS1.1, TLS1.2, TLS1.3.
min_tls_version = ""
# set to true if you want to skip ssl cert validation
ssl_skip_verify = false
# set to the path to your root CA certificate or leave unset to use system defaults
# root_ca_cert = "/path/to/certificate.crt"
# Authentication against LDAP servers requiring client certificates
# client_cert = "/path/to/client.crt"
# client_key = "/path/to/client.key"

# Search user bind dn
bind_dn = "admin@songxwn.com"
# Search user bind password
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
bind_password = 'password@123'
# We recommend using variable expansion for the bind_password, for more info https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#variable-expansion
# bind_password = '$__env{LDAP_BIND_PASSWORD}'

# Timeout in seconds (applies to each host specified in the 'host' entry (space separated))
timeout = 15

# User search filter, for example "(cn=%s)" or "(sAMAccountName=%s)" or "(uid=%s)"
search_filter = "(sAMAccountName=%s)"

# An array of base dns to search through
search_base_dns = ["dc=songxwn,dc=com"]

## For Posix or LDAP setups that does not support member_of attribute you can define the below settings
## Please check grafana LDAP docs for examples
# group_search_filter = "(&(objectClass=posixGroup)(memberUid=%s))"
# group_search_base_dns = ["ou=groups,dc=grafana,dc=org"]
# group_search_filter_user_attribute = "uid"

# Specify names of the ldap attributes your ldap uses
[servers.attributes]
name = "givenName"
surname = "sn"
username = "sAMAccountName"
member_of = "memberOf"
email =  "mail"


# Map ldap groups to grafana org roles
[[servers.group_mappings]]
group_dn = "cn=admins,ou=groups,dc=grafana,dc=org"
org_role = "Admin"
# To make user an instance admin  (Grafana Admin) uncomment line below
# grafana_admin = true
# The Grafana organization database id, optional, if left out the default org (id 1) will be used
# org_id = 1

[[servers.group_mappings]]
group_dn = "cn=it1,cn=users,dc=songxwn,dc=com"
org_role = "Editor"

[[servers.group_mappings]]
# If you want to match all (or no ldap groups) then you can use wildcard
group_dn = "cn=it2,cn=users,dc=songxwn,dc=com"
org_role = "Viewer"

参考

https://grafana.com/docs/grafana/latest/setup-grafana/configure-security/configure-authentication/ldap/

博客

https://songxwn.com/

<think>好的,用户想将RT-Thread移植到玄铁E906处理器,但找不到相关教程。首先,我需要回忆RT-Thread移植流程,并结合玄铁E906的特性来分析可能需要的步骤。根据引用资料,RT-Thread的内核移植主要涉及libcpu和BSP部分,比如适配CPU架构、中断处理、上下文切换等。玄铁E906是基于RISC-V架构的,而RT-Thread已经支持RISC-V,所以可能已有部分代码可参考。 接下来,用户提供的引用提到需要修改board.c和rtconfig.h,这可能适用于E906的移植。需要确认E906的具体架构细节,比如寄存器、中断控制器、时钟配置等。然后考虑是否需要编写新的libcpu层,或者是否有现有的RISC-V支持可以复用。同时,BSP部分需要处理外设驱动,如UART、定时器等,这可能涉及玄铁E906的特定外设。 另外,引用中的资料提到RT-Thread有Nano版本,适合资源受限的情况,可能用户需要选择适合的版本。可能需要查阅RT-Thread官方文档,查看是否有RISC-V的支持指南,或者社区是否有相关案例。此外,用户可能需要关注工具链的支持,比如使用GCC进行编译,确保交叉编译工具链正确配置。 总结步骤可能包括:准备开发环境、获取RT-Thread源码、分析E906硬件特性、移植libcpu/BSP层、配置rtconfig.h、实现必要的外设驱动、编译调试等。同时,用户可能需要参考现有的RISC-V移植示例,调整适配玄铁E906的具体差异。需要提醒用户注意中断处理和上下文切换的实现,这些是移植的关键部分。最后,建议用户查阅官方文档和社区资源,或联系技术支持获取帮助。</think>### RT-Thread移植到玄铁E906处理器的关键步骤分析 根据引用资料[1][2][3][4]中关于RT-Thread移植的核心方法论,结合玄铁E906(RISC-V架构)的特性,移植工作可分为以下关键阶段: #### 一、移植准备 1. **开发环境搭建** - 安装RISC-V工具链(如平头哥定制版GCC) - 确认调试工具支持(如J-Link或OpenOCD) - 准备玄铁E906开发板硬件手册 2. **源码获取** - 推荐使用RT-Thread Nano版本(引用[3]) - 需包含以下核心目录: ```bash rt-thread/ ├── include ├── libcpu/risc-v # RISC-V通用支持 ├── src └── bsp/e906 # 新建BSP目录 ``` #### 二、CPU架构适配 1. **上下文切换实现** - 在`libcpu/risc-v`目录下新增`context_gcc.S`文件 - 实现玄铁E906的寄存器压栈/弹栈操作: ```assembly __rt_hw_context_switch: csrrw sp, mscratch, sp sw ra, 0*4(sp) sw t0, 1*4(sp) ... # 保存所有必要寄存器 ``` 2. **中断控制器驱动** - 适配玄铁E906的PLIC(Platform-Level Interrupt Controller) - 实现中断入口函数: ```c void rt_hw_interrupt_handler(void) { uint32_t irq = __plic_claim_irq(); rt_interrupt_enter(); ... // 调用注册的中断服务例程 rt_interrupt_leave(); } ``` #### 三、BSP开发(关键) 1. **时钟初始化** - 配置计时器(TIMER)驱动: ```c void rt_hw_timer_init(void) { // 设置TIMER时钟源和分频 E906_TIMER->CTRL = 0x07; // 设置tick频率为100Hz E906_TIMER->LOAD = CPU_FREQ / 100; // 注册中断处理函数 rt_hw_interrupt_install(TIMER_IRQn, rt_hw_timer_isr); } ``` 2. **串口驱动开发** - 实现`uart_configure()`函数: ```c static void uart_configure(struct rt_serial_device *serial) { struct e906_uart *uart = serial->parent.user_data; // 设置波特率115200 uart->BRDIV = (SYS_CLK / 115200) >> 4; // 使能接收中断 uart->IER |= 0x01; } ``` #### 四、系统配置 1. **rtconfig.h关键配置** - 根据引用[1]建议,需调整以下参数: ```c #define RT_NAME_MAX 8 #define RT_ALIGN_SIZE 4 #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_USING_CONSOLE ``` 2. **链接脚本适配** - 根据玄铁E906内存布局编写`link.lds`: ```ld MEMORY { RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 64K } SECTIONS { .text : { *(.text) } > RAM .data : { *(.data) } > RAM } ``` #### 五、验证与调试 1. **最小系统测试** - 创建闪烁LED的测试线程: ```c void led_thread_entry(void *param) { rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT); while(1) { rt_pin_write(LED_PIN, !rt_pin_read(LED_PIN)); rt_thread_mdelay(500); } } ``` 2. **常见问题处理** - 中断不响应:检查PLIC优先级阈值设置 - 系统时钟偏差:校准CPU主频配置 - 内存访问错误:确认MPU/MMU配置状态 #### 六、资源参考 1. 官方移植指南: - RT-Thread官方RISC-V移植文档[^2] - 平头哥玄铁E906技术参考手册 2. 示例工程: ```bash git clone https://github.com/RT-Thread/rt-thread.git -b risc-v ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值