Skip to content

Instantly share code, notes, and snippets.

@doino-gretchenliev
Last active May 6, 2025 06:56
Show Gist options
  • Save doino-gretchenliev/d9faf0bf1bbad8919764cd1fbf8d2c64 to your computer and use it in GitHub Desktop.
Save doino-gretchenliev/d9faf0bf1bbad8919764cd1fbf8d2c64 to your computer and use it in GitHub Desktop.
Home Assistant RADIUS authentication #home-assistant #homeassistant #radius #authentication #python
homeassistant:
auth_providers:
- type: command_line
command: "/config/auth/radius-auth.sh"
meta: true
#!/usr/bin/env python
import os
import radius
radius_client = radius.Radius('secret',
host='127.0.0.1',
port=1883)
def main():
username = os.environ['username']
password = os.environ['password']
try:
print("# Trying authentication for user [{}]".format(username))
result = radius_client.authenticate(username, password)
except:
print("# Error during authentication!")
exit(1)
if result:
print("name = {}".format(username.capitalize()))
print("# User [{}] successfully authenticated!".format(username))
exit(0)
else:
print("# Authentication failed for user [{}].".format(username))
exit(1)
if __name__ == "__main__":
main()
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
python $SCRIPT_DIR/home-assistant-radius-auth.py
-e git+git://github.com/btimby/py-radius.git@6c277f89207dd877e930d69fa59681b2279ffbac#egg=radius
@RssFra97
Copy link

RssFra97 commented May 6, 2025

I have some questions, does this system still work in Home Assistant? Can it be used in parallel with the standard Home Assistant login method? Does it work with a Windows Server 2022 NPS RADIUS server?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment