Spaces:
Sleeping
Sleeping
Commit
•
951a5b3
1
Parent(s):
666e796
fix auth
Browse files
app.ipynb
CHANGED
@@ -76,8 +76,10 @@
|
|
76 |
" print('CARTESIA_API_KEY environment variable was not found.')\n",
|
77 |
" secret_import_failed = True\n",
|
78 |
"try:\n",
|
79 |
-
"
|
80 |
-
"
|
|
|
|
|
81 |
"except:\n",
|
82 |
" print('ALLOWED_OAUTH_PROFILE_USERNAMES environment variable was not found.')\n",
|
83 |
" secret_import_failed = True\n",
|
@@ -360,7 +362,7 @@
|
|
360 |
" print('Profile:', profile)\n",
|
361 |
" if REQUIRE_AUTH == False:\n",
|
362 |
" return 'WARNING_NO_AUTH_REQUIRED_LOCAL'\n",
|
363 |
-
" elif profile is not None and profile.username in
|
364 |
" return f\"{profile.username}\"\n",
|
365 |
" else:\n",
|
366 |
" # print('Unauthorized',profile)\n",
|
|
|
76 |
" print('CARTESIA_API_KEY environment variable was not found.')\n",
|
77 |
" secret_import_failed = True\n",
|
78 |
"try:\n",
|
79 |
+
" temp_ALLOWED_OAUTH_PROFILE_USERNAMES = os.environ['ALLOWED_OAUTH_PROFILE_USERNAMES']\n",
|
80 |
+
" ALLOWED_OAUTH_PROFILE_USERNAMES = tuple([o for o in temp_ALLOWED_OAUTH_PROFILE_USERNAMES.split(',') if o not in ('','None')])\n",
|
81 |
+
" del temp_ALLOWED_OAUTH_PROFILE_USERNAMES\n",
|
82 |
+
" print(f'ALLOWED_OAUTH_PROFILE_USERNAMES environment variable was found. {ALLOWED_OAUTH_PROFILE_USERNAMES}')\n",
|
83 |
"except:\n",
|
84 |
" print('ALLOWED_OAUTH_PROFILE_USERNAMES environment variable was not found.')\n",
|
85 |
" secret_import_failed = True\n",
|
|
|
362 |
" print('Profile:', profile)\n",
|
363 |
" if REQUIRE_AUTH == False:\n",
|
364 |
" return 'WARNING_NO_AUTH_REQUIRED_LOCAL'\n",
|
365 |
+
" elif profile is not None and profile.username in ALLOWED_OAUTH_PROFILE_USERNAMES:\n",
|
366 |
" return f\"{profile.username}\"\n",
|
367 |
" else:\n",
|
368 |
" # print('Unauthorized',profile)\n",
|
app.py
CHANGED
@@ -24,8 +24,10 @@ except:
|
|
24 |
print('CARTESIA_API_KEY environment variable was not found.')
|
25 |
secret_import_failed = True
|
26 |
try:
|
27 |
-
|
28 |
-
|
|
|
|
|
29 |
except:
|
30 |
print('ALLOWED_OAUTH_PROFILE_USERNAMES environment variable was not found.')
|
31 |
secret_import_failed = True
|
@@ -120,7 +122,7 @@ def verify_authorization(profile: gr.OAuthProfile=None) -> str:
|
|
120 |
print('Profile:', profile)
|
121 |
if REQUIRE_AUTH == False:
|
122 |
return 'WARNING_NO_AUTH_REQUIRED_LOCAL'
|
123 |
-
elif profile is not None and profile.username in
|
124 |
return f"{profile.username}"
|
125 |
else:
|
126 |
# print('Unauthorized',profile)
|
|
|
24 |
print('CARTESIA_API_KEY environment variable was not found.')
|
25 |
secret_import_failed = True
|
26 |
try:
|
27 |
+
temp_ALLOWED_OAUTH_PROFILE_USERNAMES = os.environ['ALLOWED_OAUTH_PROFILE_USERNAMES']
|
28 |
+
ALLOWED_OAUTH_PROFILE_USERNAMES = tuple([o for o in temp_ALLOWED_OAUTH_PROFILE_USERNAMES.split(',') if o not in ('','None')])
|
29 |
+
del temp_ALLOWED_OAUTH_PROFILE_USERNAMES
|
30 |
+
print(f'ALLOWED_OAUTH_PROFILE_USERNAMES environment variable was found. {ALLOWED_OAUTH_PROFILE_USERNAMES}')
|
31 |
except:
|
32 |
print('ALLOWED_OAUTH_PROFILE_USERNAMES environment variable was not found.')
|
33 |
secret_import_failed = True
|
|
|
122 |
print('Profile:', profile)
|
123 |
if REQUIRE_AUTH == False:
|
124 |
return 'WARNING_NO_AUTH_REQUIRED_LOCAL'
|
125 |
+
elif profile is not None and profile.username in ALLOWED_OAUTH_PROFILE_USERNAMES:
|
126 |
return f"{profile.username}"
|
127 |
else:
|
128 |
# print('Unauthorized',profile)
|