Add captive portal login
This commit is contained in:
parent
97f1eace3d
commit
07fae7b603
2 changed files with 40 additions and 0 deletions
38
main.py
Normal file
38
main.py
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
from unificontrol import UnifiClient
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from os import getenv
|
||||||
|
from ssl import get_server_certificate
|
||||||
|
from flask import Flask, request
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
global unifi
|
||||||
|
|
||||||
|
def main():
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
HOSTNAME = str(getenv("HOSTNAME"))
|
||||||
|
USERNAME = str(getenv("USERNAME"))
|
||||||
|
PASSWORD = str(getenv("PASSWORD"))
|
||||||
|
|
||||||
|
cert = get_server_certificate((HOSTNAME, 443))
|
||||||
|
|
||||||
|
global unifi
|
||||||
|
unifi = UnifiClient(host=HOSTNAME,
|
||||||
|
username=USERNAME, password=PASSWORD, cert=cert)
|
||||||
|
|
||||||
|
app.run(host="0.0.0.0", port=80)
|
||||||
|
|
||||||
|
@app.route('/guest/s/default/')
|
||||||
|
def root():
|
||||||
|
ap = request.args.get('ap')
|
||||||
|
id = request.args.get('id')
|
||||||
|
ssid = request.args.get('ssid')
|
||||||
|
url = request.args.get('url')
|
||||||
|
|
||||||
|
ret = f"{ap}\t{id}\t{ssid}\t{url}"
|
||||||
|
print(ret)
|
||||||
|
unifi.authorize_guest(id, 1)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
@ -2,11 +2,13 @@ blinker==1.9.0
|
||||||
certifi==2025.1.31
|
certifi==2025.1.31
|
||||||
charset-normalizer==3.4.1
|
charset-normalizer==3.4.1
|
||||||
click==8.1.8
|
click==8.1.8
|
||||||
|
dotenv==0.9.9
|
||||||
Flask==3.1.0
|
Flask==3.1.0
|
||||||
idna==3.10
|
idna==3.10
|
||||||
itsdangerous==2.2.0
|
itsdangerous==2.2.0
|
||||||
Jinja2==3.1.6
|
Jinja2==3.1.6
|
||||||
MarkupSafe==3.0.2
|
MarkupSafe==3.0.2
|
||||||
|
python-dotenv==1.1.0
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
unificontrol @ git+https://github.com/ThijsRay/unificontrol@bc595d0b17d38f45d624fe08c144e322484fe298
|
unificontrol @ git+https://github.com/ThijsRay/unificontrol@bc595d0b17d38f45d624fe08c144e322484fe298
|
||||||
urllib3==2.4.0
|
urllib3==2.4.0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue