AdguardTeam / AdGuardHome

Network-wide ads & trackers blocking DNS server
https://adguard.com/adguard-home/overview.html
GNU General Public License v3.0
25.63k stars 1.84k forks source link

Use ubus for authentication for better integration with OpenWRT luci #7444

Open yshui opened 5 days ago

yshui commented 5 days ago

Prerequisites

The problem

With AdGuardHome running on an openwrt router, I need to separately log into openwrt and adguardhome's web interfaces, which is inconvenient.

Proposed solution

I search the codebase and noticed there is a special "GLMode" authentication, which reads a token file from /tmp:

https://github.com/AdguardTeam/AdGuardHome/blob/1d6d85cff4bf5915156f28d07582b4f0bb359d04/internal/home/authglinet.go#L17

GL-Inet turns out to be a router manufacturer, so I assume this mode is so that users that have logged into the router's interface don't have to log into AGH again.

I think OpenWRT can get similar treatment. OpenWRT's web interface uses ubus for authentication, and all current sessions can be listed by running ubus call session list on the router. So in theory AGH can use ubus to check if a session token is valid or not.

Alternatives considered and additional information

No response