Skip to content

Commit

Permalink
change config to be OS env everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
iskanred committed Apr 30, 2024
1 parent b0fccaf commit 21fa1e3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 24 deletions.
30 changes: 15 additions & 15 deletions bin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
from internal.item.router import router as item_router
from internal.user.router import router as user_router

fb_config = {
"type": os.environ.get("TYPE"),
"project_id": os.environ.get("PROJECTID"),
"private_key_id": os.environ.get("PRIVATEKEYID"),
"private_key": os.environ.get("PRIVATEKEY"),
"client_email": os.environ.get("CLIENTEMAIL"),
"client_id": os.environ.get("CLIENTID"),
"token_uri": os.environ.get("TOKENURI"),
"apiKey": os.environ.get("APIKEY"),
"authDomain": os.environ.get("AUTHDOMAIN"),
"projectId": os.environ.get("PROJECTID"),
"databaseURL": "",
"storageBucket": ""
}


def create_app() -> FastAPI:
app = FastAPI()
Expand All @@ -18,21 +33,6 @@ def create_app() -> FastAPI:

Base.metadata.create_all(bind=engine)

fb_config = {
"type": os.environ.get("TYPE"),
"project_id": os.environ.get("PROJECTID"),
"private_key_id": os.environ.get("PRIVATEKEYID"),
"private_key": os.environ.get("PRIVATEKEY"),
"client_email": os.environ.get("CLIENTEMAIL"),
"client_id": os.environ.get("CLIENTID"),
"token_uri": os.environ.get("TOKENURI"),
"apiKey": os.environ.get("APIKEY"),
"authDomain": os.environ.get("AUTHDOMAIN"),
"projectId": os.environ.get("PROJECTID"),
"databaseURL": "",
"storageBucket": ""
}

if not firebase_admin._apps:
firebase_admin.initialize_app(credentials.Certificate(fb_config))
pyrebase.initialize_app(fb_config).auth()
Expand Down
22 changes: 17 additions & 5 deletions internal/data/auth.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import json
import os

from pyrebase import pyrebase

fb_config = {
"type": os.environ.get("TYPE"),
"project_id": os.environ.get("PROJECTID"),
"private_key_id": os.environ.get("PRIVATEKEYID"),
"private_key": os.environ.get("PRIVATEKEY"),
"client_email": os.environ.get("CLIENTEMAIL"),
"client_id": os.environ.get("CLIENTID"),
"token_uri": os.environ.get("TOKENURI"),
"apiKey": os.environ.get("APIKEY"),
"authDomain": os.environ.get("AUTHDOMAIN"),
"projectId": os.environ.get("PROJECTID"),
"databaseURL": "",
"storageBucket": ""
}


def pb_auth():
auth = pyrebase.initialize_app(
json.load(open("./configs/firebase-pyrebase.json"))
).auth()
return auth
return pyrebase.initialize_app(fb_config).auth()
21 changes: 17 additions & 4 deletions ui/auth.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import json
import os

import pyrebase
import requests
import streamlit as st

import ui.utils as utils

pb_auth = pyrebase.initialize_app(
json.load(open("./configs/firebase-pyrebase.json"))
).auth()
fb_config = {
"type": os.environ.get("TYPE"),
"project_id": os.environ.get("PROJECTID"),
"private_key_id": os.environ.get("PRIVATEKEYID"),
"private_key": os.environ.get("PRIVATEKEY"),
"client_email": os.environ.get("CLIENTEMAIL"),
"client_id": os.environ.get("CLIENTID"),
"token_uri": os.environ.get("TOKENURI"),
"apiKey": os.environ.get("APIKEY"),
"authDomain": os.environ.get("AUTHDOMAIN"),
"projectId": os.environ.get("PROJECTID"),
"databaseURL": "",
"storageBucket": ""
}

pb_auth = pyrebase.initialize_app(fb_config).auth()


def create_user_with_email_and_password(email, username, password):
Expand Down

0 comments on commit 21fa1e3

Please sign in to comment.