Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /fief-dev_fief /fief /dependencies /fief.py
| import asyncio | |
| from fief_client import FiefAsync | |
| from uvicorn.server import Server | |
| from fief.logger import logger | |
| from fief.settings import settings | |
| def _is_uvicorn_ssl() -> bool: | |
| """ | |
| Hacky way to determine if the Uvicorn server is running with SSL, | |
| by retrieving the server instance from the running asyncio tasks. | |
| """ | |
| try: | |
| for task in asyncio.all_tasks(): | |
| coroutine = task.get_coro() | |
| if coroutine is not None: | |
| frame = coroutine.cr_frame # type: ignore | |
| if frame is not None: | |
| args = frame.f_locals | |
| if self := args.get("self"): | |
| if isinstance(self, Server): | |
| return self.config.is_ssl | |
| except RuntimeError: | |
| pass | |
| return False | |
| _is_ssl = _is_uvicorn_ssl() | |
| _scheme = "https" if _is_ssl else "http" | |
| if _is_ssl: | |
| logger.debug("Uvicorn server is running with SSL") | |
| else: | |
| logger.debug("Uvicorn server is running without SSL") | |
| fief = FiefAsync( | |
| f"{_scheme}://localhost:{settings.port}", # Always call Fief on localhost | |
| settings.fief_client_id, | |
| settings.fief_client_secret, | |
| encryption_key=settings.fief_encryption_key, | |
| host=settings.fief_domain, | |
| verify=False, | |
| ) | |
| async def get_fief() -> FiefAsync: | |
| """ | |
| This is Fief-ception. | |
| We are configuring a Fief client to authenticate Fief users to their account. | |
| """ | |
| return fief | |
Xet Storage Details
- Size:
- 1.46 kB
- Xet hash:
- f9928f23a62be5bb31044163a465888e45b1c7cba5009696a7244a113c2281b5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.