Spaces:
Sleeping
Sleeping
Commit
·
9da11e1
1
Parent(s):
9e84d53
Removed auth_functions; added firebase key
Browse files- .gitignore +0 -2
- Functions/auth_functions.py +0 -33
- Resources/key.json +13 -0
- app.py +1 -1
.gitignore
CHANGED
|
@@ -83,8 +83,6 @@ http-client.private.env.json
|
|
| 83 |
.idea/ApifoxUploaderProjectSetting.xml
|
| 84 |
|
| 85 |
# Manually added
|
| 86 |
-
Resources/key.json
|
| 87 |
-
Resources/salt.py
|
| 88 |
Resources/upload.py
|
| 89 |
Resources/users.json
|
| 90 |
Resources/videos.json
|
|
|
|
| 83 |
.idea/ApifoxUploaderProjectSetting.xml
|
| 84 |
|
| 85 |
# Manually added
|
|
|
|
|
|
|
| 86 |
Resources/upload.py
|
| 87 |
Resources/users.json
|
| 88 |
Resources/videos.json
|
Functions/auth_functions.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
from Resources.salt import salt
|
| 2 |
-
import hashlib
|
| 3 |
-
from Functions.db_connection import users_ref, get_user_ref
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def encrypt(password):
|
| 7 |
-
result = hashlib.pbkdf2_hmac('sha256', bytes(password, "utf-8"), salt, 100000)
|
| 8 |
-
return result.hex()
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
def get_password_by_username(username):
|
| 12 |
-
user_password = users_ref.child(username).get()
|
| 13 |
-
return user_password
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
def auth_function(username, password):
|
| 17 |
-
user_password = get_password_by_username(username)
|
| 18 |
-
if user_password is None:
|
| 19 |
-
return False
|
| 20 |
-
pass_input = encrypt(password)
|
| 21 |
-
if user_password == pass_input:
|
| 22 |
-
return True
|
| 23 |
-
return False
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
def register(username, password):
|
| 27 |
-
if get_password_by_username(username) is not None:
|
| 28 |
-
return "Registration error: Username already exists"
|
| 29 |
-
user_ref = get_user_ref(username)
|
| 30 |
-
pass_hash = encrypt(password)
|
| 31 |
-
user_ref.set(pass_hash)
|
| 32 |
-
return "Registration successful!"
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resources/key.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"type": "service_account",
|
| 3 |
+
"project_id": "video-link-db",
|
| 4 |
+
"private_key_id": "9f93ccbff54ea5fe7b9d6c0214489219cbd35d6a",
|
| 5 |
+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDU04GhYRtyIauV\nz2pjmDLXbAe6jBE8vACfOH0QHEUp1lEgeeCKDLVIEaGrCt6krs9hw5MQXw7ZwYqq\n7tFlL9Bi21FHgRErdcHAT9mXvAZIuZZ2HYVE3HsKwUKLm3ITx7Z5EBDPAjFatNRX\n8AwM1SN+lD/8DOmLHko1rMGZXPyZDRQso55quD7xsUSHGiKjfiM4NRNdFrW9qstn\n1wZWIG+RxgEbl9REoUffeRJJCE6EfS53yp35aHew4Ob+nla+l8S0jWP4xb+sLqXF\nz4BWCOA0lOw1Y27D4qJeahV7puzZhA7DJFYxVVJ3xdXwSVCLOrrVxMhF3YBwwktW\nLb8YrFlnAgMBAAECggEAJG332HnYytZ8mm4gld+thDZXtFTZdn3v1VFEBwfvxtOK\nm3aBOuAl/6oU9EQuDB5oHSHvAHRlBF0esVejvCBNGT7VUNoE6F2FxrdkVZa3tKcf\n3CP9deYPoa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9q7A4iANwICKEzXDpUY9LLZa4d/ZmQfoJ9LNMrny45Q\nOEdT5Vt0L5KxIzV/NvCugxpb\n-----END PRIVATE KEY-----\n",
|
| 6 |
+
"client_email": "firebase-adminsdk-fbsvc@video-link-db.iam.gserviceaccount.com",
|
| 7 |
+
"client_id": "106345596697639062366",
|
| 8 |
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
| 9 |
+
"token_uri": "https://oauth2.googleapis.com/token",
|
| 10 |
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
| 11 |
+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40video-link-db.iam.gserviceaccount.com",
|
| 12 |
+
"universe_domain": "googleapis.com"
|
| 13 |
+
}
|
app.py
CHANGED
|
@@ -57,4 +57,4 @@ with gr.Blocks(css=css) as main_page:
|
|
| 57 |
outputs=save_result)
|
| 58 |
main_page.load(get_username)
|
| 59 |
|
| 60 |
-
main_page.launch()
|
|
|
|
| 57 |
outputs=save_result)
|
| 58 |
main_page.load(get_username)
|
| 59 |
|
| 60 |
+
main_page.launch(auth=[("admin", "pass123"), ("sample_user", "1stpassword23"), ("testenko", "testenko543")])
|