Ejemplo n.º 1
0
def oauth_server(config, login):

    app = AsyncPathMapDispatch(
        {
            '/login/oauth/access_token': {'body': {'access_token': 'b'}},
            '/user': {
                "body": {
                    "login": login,
                    "avatar_url": "",
                    "id": 1,
                    "name": "monalisa",
                }
            },
        }
    )
    # we need to remove the client, because it might have been already
    # registered in quetz.main
    _prev_registry_item = auth_github.oauth._registry.pop("github")
    _prev_clients_item = auth_github.oauth._clients.pop("github")
    auth_github.register(config, client_kwargs={'app': app})

    yield

    auth_github.oauth._registry["github"] = _prev_registry_item
    auth_github.oauth._clients["github"] = _prev_clients_item
Ejemplo n.º 2
0
    auth_google,
    authorization,
    db_models,
    indexing,
    rest_models,
)
from quetz.config import Config
from quetz.dao import Dao
from quetz.database import get_session as get_db_session

from .condainfo import CondaInfo

app = FastAPI()

config = Config()
auth_github.register(config)

app.add_middleware(
    SessionMiddleware,
    secret_key=config.session_secret,
    https_only=config.session_https_only,
)

api_router = APIRouter()

pkgstore = config.get_package_store()

app.include_router(auth_github.router)

if config.configured_section('google'):
    auth_google.register(config)