fix: restore oauth redirect links to fix import error upon server start up
This commit is contained in:
parent
0f3c54d91d
commit
6c0a79b319
1 changed files with 19 additions and 0 deletions
|
|
@ -29,6 +29,25 @@ _msg = apiRouteContext("oauthConnectTicket")
|
||||||
|
|
||||||
_CONNECT_TICKET_TTL_SEC = 600
|
_CONNECT_TICKET_TTL_SEC = 600
|
||||||
|
|
||||||
|
# OAuth providers sometimes redirect to the API root if the app redirect URL omits the path.
|
||||||
|
OAUTH_FLOW_CALLBACK_PATHS: Dict[str, str] = {
|
||||||
|
"clickup_connect": "/api/clickup/auth/connect/callback",
|
||||||
|
"msft_connect": "/api/msft/auth/connect/callback",
|
||||||
|
"google_connect": "/api/google/auth/connect/callback",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def oauth_callback_redirect_path(state: str) -> str | None:
|
||||||
|
"""Map connect-ticket JWT (OAuth ``state`` param) to the correct callback route."""
|
||||||
|
try:
|
||||||
|
data = jose_jwt.decode(state, SECRET_KEY, algorithms=[ALGORITHM])
|
||||||
|
except JWTError:
|
||||||
|
return None
|
||||||
|
flow = data.get("flow")
|
||||||
|
if not isinstance(flow, str):
|
||||||
|
return None
|
||||||
|
return OAUTH_FLOW_CALLBACK_PATHS.get(flow)
|
||||||
|
|
||||||
|
|
||||||
def issue_connect_ticket(flow: str, connection_id: str, user_id: str) -> str:
|
def issue_connect_ticket(flow: str, connection_id: str, user_id: str) -> str:
|
||||||
"""Issue a short-lived JWT for starting a data-connection OAuth popup."""
|
"""Issue a short-lived JWT for starting a data-connection OAuth popup."""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue