示例#1
0
    def __init__(self, db_config, blocking_auth=True, verbose=10, store=None):
        guest = db_config.get('guest')

        self.app = pyrebase.initialize_app(db_config)
        self.logger = logging.getLogger('FirebaseProvider')
        self.logger.setLevel(verbose)

        self.auth = None
        if not guest and 'serviceAccount' not in db_config.keys():
            self.auth = FirebaseAuth(self.app, db_config.get("use_email_auth"),
                                     db_config.get("email"),
                                     db_config.get("password"), blocking_auth)

        self.store = store if store else FirebaseArtifactStore(
            db_config, verbose=verbose, blocking_auth=blocking_auth)

        self._experiment_info_cache = {}
        self._experiment_cache = {}

        iothreads = 10

        if ThreadPool:
            self.pool = ThreadPool(iothreads)
        else:
            self.pool = None

        if self.auth and not self.auth.expired:
            self.__setitem__(self._get_user_keybase() + "email",
                             self.auth.get_user_email())
示例#2
0
    def __init__(self, config, verbose=10, blocking_auth=True):
        # TODO: implement connection
        self.url = config.get('serverUrl')
        self.verbose = verbose
        self.logger = logging.getLogger('HTTPProvider')
        self.logger.setLevel(self.verbose)

        self.auth = None
        self.app = pyrebase.initialize_app(config)
        guest = config.get('guest')
        if not guest and 'serviceAccount' not in config.keys():
            self.auth = FirebaseAuth(self.app, config.get("use_email_auth"),
                                     config.get("email"),
                                     config.get("password"), blocking_auth)
示例#3
0
    def __init__(self, db_config, measure_timestamp_diff=True,
                 blocking_auth=True, verbose=10):

        guest = db_config.get('guest')

        self.app = pyrebase.initialize_app(db_config)

        self.auth = None
        if not guest and 'serviceAccount' not in db_config.keys():
            self.auth = FirebaseAuth(self.app,
                                     db_config.get("use_email_auth"),
                                     db_config.get("email"),
                                     db_config.get("password"),
                                     blocking_auth)

        self.logger = logging.getLogger('FirebaseArtifactStore')
        self.logger.setLevel(verbose)
        super(FirebaseArtifactStore, self).__init__(measure_timestamp_diff)
示例#4
0
文件: model.py 项目: Mistobaan/studio
    def __init__(self, db_config, blocking_auth=True, verbose=10, store=None):
        guest = db_config.get('guest')

        self.app = pyrebase.initialize_app(db_config)
        self.logger = logging.getLogger('FirebaseProvider')
        self.logger.setLevel(verbose)

        self.auth = None
        if not guest and 'serviceAccount' not in db_config.keys():
            self.auth = FirebaseAuth(self.app, db_config.get("use_email_auth"),
                                     db_config.get("email"),
                                     db_config.get("password"), blocking_auth)

        self.store = store if store else FirebaseArtifactStore(
            db_config, verbose=verbose, blocking_auth=blocking_auth)

        if self.auth and not self.auth.expired:
            myemail = self._get(self._get_user_keybase() + "email")
            if not myemail or myemail != self.auth.get_user_email():
                self.__setitem__(self._get_user_keybase() + "email",
                                 self.auth.get_user_email())

        self.max_keys = db_config.get('max_keys', 100)
示例#5
0
    def __init__(self, config, verbose=10, measure_timestamp_diff=True):
        self.logger = logging.getLogger('GCloudArtifactStore')
        self.logger.setLevel(verbose)

        auth_config = config.get('auth')
        if not auth_config:
            self.client = storage.Client()
        else:
            assert auth_config['type'].lower() == 'firebase'
            app = pyrebase.initialize_app(auth_config)
            self.auth = FirebaseAuth(app,
                                     auth_config.get("use_email_auth"),
                                     auth_config.get("email"),
                                     auth_config.get("password"))

            self.client = storage.Client(credentials=self.auth.get_token())

        try:
            self.bucket = self.client.get_bucket(config['bucket'])
        except BaseException as e:
            self.logger.exception(e)
            self.bucket = self.client.create_bucket(config['bucket'])

        super(GCloudArtifactStore, self).__init__(measure_timestamp_diff)
示例#6
0
from fastapi import FastAPI, Depends, status, HTTPException
from fastapi_cloudauth.firebase import FirebaseCurrentUser, FirebaseClaims

from auth import FirebaseAuth
from model import AuthModel
from db import DatabaseManager
from user import User

from dotenv import load_dotenv
load_dotenv()

app = FastAPI()
firebase_auth = FirebaseAuth()
get_current_user = FirebaseCurrentUser()


@app.get("/")
def index():
    return {'message': 'Thanks for visiting the api'}


@app.get("/student/upcomming_classes")
def get_upcomming_classes(user: FirebaseClaims = Depends(get_current_user)):
    # user = UserModel(user[''])
    return f"Hello, {user.__dict__}"


@app.get("/student/profile")
def get_student_profile(user: FirebaseClaims = Depends(get_current_user)):
    profile = User(user)
    return dict(user)
示例#7
0
 def __init__(self, data):
     fa = FirebaseAuth()
     fa.initialisedb()
     self.root = fa.createdb(data)