mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
revert
This commit is contained in:
parent
10a2180873
commit
8d66d32c07
2 changed files with 19 additions and 38 deletions
|
|
@ -1,8 +1,7 @@
|
|||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
||||
from fastapi import Depends, FastAPI, HTTPException, status
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import RedirectResponse
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
|
||||
|
||||
|
|
@ -90,28 +89,6 @@ if config.AUTH_TYPE == "GOOGLE":
|
|||
], # blocks OAuth registration when disabled
|
||||
)
|
||||
|
||||
# Convenience endpoint for browser-based login:
|
||||
# - FastAPI Users `/auth/google/authorize` returns JSON {authorization_url: ...}
|
||||
# - In production, it's more reliable to do a top-level navigation that
|
||||
# immediately redirects to Google (avoids cross-site XHR/CORS pitfalls).
|
||||
from fastapi import Query
|
||||
from fastapi_users.router.oauth import generate_state_token
|
||||
|
||||
@app.get("/auth/google/start", include_in_schema=False)
|
||||
async def google_oauth_start(
|
||||
request: Request, scopes: list[str] = Query(None)
|
||||
) -> RedirectResponse:
|
||||
base = (config.BACKEND_URL or str(request.base_url)).rstrip("/")
|
||||
callback_url = f"{base}/auth/google/callback"
|
||||
|
||||
state = generate_state_token({}, SECRET)
|
||||
authorization_url = await google_oauth_client.get_authorization_url(
|
||||
callback_url,
|
||||
state,
|
||||
scopes,
|
||||
)
|
||||
return RedirectResponse(authorization_url, status_code=302)
|
||||
|
||||
app.include_router(crud_router, prefix="/api/v1", tags=["crud"])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue