Skip to content

Commit

Permalink
chore: improve callback logging (#167)
Browse files Browse the repository at this point in the history
* chore: improve callback logging

* test: fix tests
  • Loading branch information
tomasvotava committed May 18, 2024
1 parent df1f8ea commit 3d6e748
Show file tree
Hide file tree
Showing 4 changed files with 1,057 additions and 476 deletions.
3 changes: 1 addition & 2 deletions examples/google.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Google Login Example
"""
"""Google Login Example"""

import os
import uvicorn
Expand Down
10 changes: 10 additions & 0 deletions fastapi_sso/sso/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""SSO login base dependency."""

import json
import logging
import os
import warnings
from types import TracebackType
Expand All @@ -16,6 +17,8 @@
from fastapi_sso.pkce import get_pkce_challenge_pair
from fastapi_sso.state import generate_random_state

logger = logging.getLogger(__name__)


class DiscoveryDocument(TypedDict):
"""Discovery document."""
Expand Down Expand Up @@ -84,6 +87,7 @@ def __init__(
self._generated_state: Optional[str] = None

if self.allow_insecure_http:
logger.debug("Initializing %s with allow_insecure_http=True", self.__class__.__name__)
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"

# TODO: Remove use_state argument and attribute
Expand Down Expand Up @@ -332,6 +336,12 @@ async def verify_and_process(
headers = headers or {}
code = request.query_params.get("code")
if code is None:
logger.debug(
"Callback request:\n\tURI: %s\n\tHeaders: %s\n\tQuery params: %s",
request.url,
request.headers,
request.query_params,
)
raise SSOLoginError(400, "'code' parameter was not found in callback request")
self._state = request.query_params.get("state")
pkce_code_verifier: Optional[str] = None
Expand Down
Loading

0 comments on commit 3d6e748

Please sign in to comment.