Spaces:
Sleeping
Sleeping
Create AuthVerification.py
Browse files- AuthVerification.py +15 -0
AuthVerification.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
def get_accepted_ip_passwords():
|
5 |
+
ip____passwords_accepted = [os.environ.get(f'USER_{i}', None) for i in range(900) if os.environ.get(f'USER_{i}', False)]
|
6 |
+
return ip____passwords_accepted
|
7 |
+
|
8 |
+
def auth_verification(password, request: gr.Request):
|
9 |
+
ip = request.client.host
|
10 |
+
ip____password = f'{ip}____{password}'
|
11 |
+
ip____passwords_accepted = get_accepted_ip_passwords()
|
12 |
+
can_enter_the_space = ip____password in ip____passwords_accepted
|
13 |
+
return can_enter_the_space
|
14 |
+
|
15 |
+
|