[V2+] Secrets added.

(For local testing purposes.)
[+] Fixed SSL/TLS issues.

Signed-off-by: Charles Le Maux <charles.le-maux@epitech.eu>
This commit is contained in:
Charles Le Maux 2024-06-29 17:13:24 +01:00
parent 34267cda12
commit 6cda6461cc
10 changed files with 76 additions and 11 deletions

1
.gitignore vendored
View File

@ -164,6 +164,7 @@ cython_debug/
/__pycache__/
/servers/
/users/
!/secrets/
unit_test.py
logs.txt
!*.py

View File

@ -50,7 +50,7 @@ document.addEventListener('DOMContentLoaded', () => {
const form = event.target.closest('form');
const action = button.dataset.action;
const token = "gqZN3eCHF3V2er3Py3rlgk8u2t83";
const framework = "paper"
const framework = "paper";
const subdomain = document.getElementById('subdomain').value;
const email = document.getElementById('accountEmail').value;
const port = document.getElementById('accountPort').value;

1
app.py
View File

@ -108,4 +108,5 @@ def dynamic_route_handler(path):
if __name__ == '__main__':
ssl_context = ('/fullchain.pem', '/privkey.pem')
app.run(host='0.0.0.0', port=3000, debug=False)

View File

@ -5,7 +5,7 @@ import jwt
from firebase_admin import auth, credentials, firestore
from google.api_core.exceptions import Aborted, DataLoss, NotFound, OutOfRange, PermissionDenied, ResourceExhausted
cred = credentials.Certificate('servii.json')
cred = credentials.Certificate('secrets/servii.json')
app = firebase_admin.initialize_app(cred)
firestore_database = firestore.client()
@ -55,7 +55,7 @@ def user_field_exists(user_id: str, field: str) -> bool:
def server_name_taken(user_id: str, server_name: str) -> bool:
servers = firestore_database.collection('users').document(user_id).collection('servers')
query = servers.where('name', '==', server_name)
query = servers.where(field_path='name', op_string='==', value=server_name)
for _ in query.stream():
return True
return False

View File

@ -13,7 +13,7 @@ def set_subdomain(user: UserRecord, subdomain: str) -> tuple[HTTPStatus, str or
user_id: str = user.uid
store = firebase_manager.firestore_database
_users = store.collection("users")
query = _users.where("subdomain", "==", subdomain)
query = _users.where(field_path="subdomain", op_string="==", value=subdomain)
for _ in query.stream():
return HTTPStatus.ALREADY_REPORTED, "Subdomain already associated."
try:

0
secrets/__init__.py Normal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gNeffcqAX1LPFjB0/5bQFpivcZN/yfiS8d35AoGAUO/bTx6aPqqyPUFl1QjP
rtlQFWey8J5kliOyrafmlI7Lf6uihUXSu/RFdK5yRTzhj9rat9hmDwUJ+b2bFtzd
95teLHHMmbhiN2ZcDAFfRwUWQqfrf3JEmOFrGSI7wXKtUouOt7IjDpx7a3YGcduB
ie71IHpZX8A+6yb3J79T6j4=
-----END PRIVATE KEY-----

13
secrets/servii.json Normal file
View File

@ -0,0 +1,13 @@
{
"type": "service_account",
"project_id": "servi-e6705",
"private_key_id": "f68b7cfdc507b94b8b55137d8f1810b34be52868",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCVcjYV3J0aAoaC\njJfni2hWTyvBtJVUCT5XF/xAkJ9SEgZM+RpJBYMac8wnh+37Y4yBQc76K+0ZEmRT\noXx8Eb0vmz0sTG3armchmbfC1UZCn0AI9vR8vPSBev/+sCWxWri+6vCpy3fnpJ4o\n4ZIhgr8TEkQ6yi3pKsRXBJYbZXoj+CVmYVAYjYBYFZQwwl/3OUAZr6TFltISqcII\nlxnm2PUV7mEe++S6K515kN69mLEV5S+ylQljzDOiZihz6ETt8HRa/SPArW7RpyJZ\n8rfO1IuncvF1m2IEFrVWWwGsYuwSNQapOae3ngqOkYbyVJ7HqSIj06YftA+0tNpW\nV1gOmYLlAgMBAAECggEAAU7kvRgJrd+SSTaffVsiy/95NFUOBW/Va4uJYhCWmHA2\nKvquPi/ks2+c2A/ilSqVheKP1l3+kYEm0VEFmVUla1eoAHbNzvF9z2eFmj0KexYH\nbO7zDCTpJgKUciidN9pT++OQYaywP54GvoqnO6M4LXcqyjsYxJJsFlkOiXc2sAfV\nFf5E9gpBut+580y64q0A4b4eLxZ2bwT4oyYzKQp4hDX92Ycd3/dPSbTDAH2eltD5\nrhMa6oQK6tEL+De631qoA+dLrU/exZ5rqNapltz+hMGOzWIEBLBOzburGrjiTcns\nbZn7E5bXe/NjX8e2yMiKrjCwqv31cX6wD5uIaIWCuQKBgQDKPKcFhRp9cgCwevpL\nXjFHx/0y5BDtUIvrIo+F0O3UXhxJd9IW+D0BXgSfKXzREra4b08Pk+pmjm6k2dbi\n/v5kM7nE2dkc6UMAouLRgTv3yky8F1fCC5pQFPb/uZt0OtvFox18DVDEeFd7XJCa\nBwDHQuEDDchRgK3vgO2+midJ/QKBgQC9LNorlVgdwimfYB435Jt5sw7NVS2PT43j\nVvAfx5urxObMuSvjG8BwFPWk6A9YOU65ecdsG5o1f3a1gsYyvM9g0SSblyt9uWLP\n68xXiq2Wejl7gKyZjWbFqFNs++JwMaSq+r1YHWe+ohXRf5LW3tMlj4zgkfveUlAj\n1j9HauNdCQKBgQCfLuiElsVIEnDqeJIEuuptRsRMx2lvcmP/u59exBo/e6gmR/MM\n824JYnie0ygU5Pb/61U+vL3W5au/hFv5Jp8UPgauJI8Zi52apZuFLoUGQKzvrCv+\nZ+WZvTbCCNWMwjt0sDSoDU8Spmqthimno3WAYmr8XV/cjz3ZdBEuYuYj/QKBgEhO\nEWFhJpnRMYl5+nLQjOBaIQk4Sj6hYJEJFKSA7a4chz6uc+jNHaN5T15lWCAXX1Cj\nDCb08d8KxfugbVLNOdI+feh+QiA+sFbaQHMhTTHbq4bZ6p6SHjrkGGbqa2UIhHDZ\nf29jZdjGKOK3CQ/ZgQi1MlpPUd5qxbi81djdMOPJAoGBAIBTqrCN2PC++TnmOdsx\nGKWfdw4LDwIRJYK0wcoxemmfJDdJ4zKUZbwfGDFGjLjl2h07NWl5CKo/gskb70JM\nKksCMImraA7ipZrl9B+++6x/ovp2QuaEwXRmBHJm0/Ys2BZlgB/Tknj0tuiPkqZ0\n8pK9DpR/a6vbW5KsHp9D+6Wc\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-ijgb2@servi-e6705.iam.gserviceaccount.com",
"client_id": "107003409354710428353",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-ijgb2%40servi-e6705.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}

View File

@ -1,7 +0,0 @@
from firebase_admin import functions
import file_manager
import firebase_manager
file_manager.append_stream_config(3005, "antho")