-
-
Save doino-gretchenliev/d9faf0bf1bbad8919764cd1fbf8d2c64 to your computer and use it in GitHub Desktop.
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 |
Install the requirements: pip install -r requirements.txt
.
How can I setup hassio to do this on startup? I'm using it in a Docker container so it has to be reinstalled when the container restarts
You should plug in somewhere at the entry point script or prepare your image.
Hi, i'm trying to differentiate HA trigger between A, P, S and D / H status in Hotspot > Hosts status.
The reason for this is that there's some clients that only connects and not logged in to my hotspot server, and that messes up the automation. My AP is unifi and my radius server and hotspot server is mikrotik. Currently using unifi counter as trigger but of course i'm getting alot of false positive trigger due to above issue
Can this be done with your script?
How would i create a sensor then?
Hi, I tried to install your scripts.
I'm running HA os on ODROID. At first I installed python3.
I installed radius with pip command (not with the requirement file).
However when I try to login, I get a ivalid username error.
In HA log I see a Permission denied error on the radius-auth-sh file.
What can I do to fix this?
Is there any way for users not to be administrators?
Is there any way for users not to be administrators?
It's an authentication script. Probably you can attach roles to users afterwards.
Hi, do you have any plan to make this as custom component in HACS? It would be much easier to install requirements and use your awesome code :)
What do you do with the requirements.txt file?