Skip to content

Commit b503b21

Browse files
committed
doc: show constructor docs and some type improvements
1 parent 7fb4f62 commit b503b21

File tree

7 files changed

+44
-14
lines changed

7 files changed

+44
-14
lines changed

docs/conf.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
project = "fastapi-third-party-auth"
2121
copyright = "2020, Harry M. Winters, Richard Löwenström"
22-
author = "Harry M. Winters"
22+
author = "Harry M. Winters, Richard Löwenström"
2323

2424
# The full version, including alpha/beta/rc tags
2525
release = "0.0.0"
@@ -46,9 +46,17 @@
4646
# The theme to use for HTML and HTML Help pages. See the documentation for
4747
# a list of builtin themes.
4848
#
49-
html_theme = "alabaster"
49+
html_theme = "sphinx_rtd_theme"
5050

5151
# Add any paths that contain custom static files (such as style sheets) here,
5252
# relative to this directory. They are copied after the builtin static files,
5353
# so a file named "default.css" will overwrite the builtin "default.css".
5454
html_static_path: List[str] = []
55+
56+
autodoc_default_options = {
57+
"members": True,
58+
"member-order": "bysource",
59+
"special-members": "__init__",
60+
"undoc-members": True,
61+
"exclude-members": "__weakref__",
62+
}

docs/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Welcome to fastapi-third-party-auth's documentation!
2-
========================================
2+
====================================================
33

44
Verify and decrypt 3rd party OpenID Connect tokens to protect your
55
`FastAPI <https://github.com/tiangolo/fastapi>`_ endpoints.
@@ -87,7 +87,6 @@ Grant Types
8787
-----------
8888
.. automodule:: fastapi_third_party_auth.grant_types
8989
:members:
90-
:undoc-members:
9190

9291
IDToken Types
9392
-------------

fastapi_third_party_auth/auth.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from your_app.auth import auth
1212
1313
@app.get("/auth")
14-
def test_auth(authenticated_user: IDToken = Depends(auth.required)):
14+
def test_auth(authenticated_user: IDToken = Security(auth.required)):
1515
return f"Hello {authenticated_user.preferred_username}"
1616
"""
1717

@@ -51,7 +51,7 @@ def __init__(
5151
scopes: List[str] = list(),
5252
grant_types: List[GrantType] = [GrantType.IMPLICIT],
5353
signature_cache_ttl: int = 3600,
54-
idtoken_model: Type = IDToken,
54+
idtoken_model: Type[IDToken] = IDToken,
5555
):
5656
"""Configure authentication and use method :func:`require` or :func:`optional`
5757
to check user credentials.
@@ -117,7 +117,7 @@ def __init__(
117117
auto_error=False,
118118
)
119119

120-
async def __call__(self, request: Request) -> Optional[str]:
120+
async def __call__(self, request: Request) -> None:
121121
return None
122122

123123
def required(
@@ -137,7 +137,7 @@ def required(
137137
behind the scenes by Depends.
138138
139139
Return:
140-
IDToken: Dictionary with IDToken information
140+
IDToken (self.idtoken_model): User information
141141
142142
raises:
143143
HTTPException(status_code=401, detail=f"Unauthorized: {err}")
@@ -172,7 +172,7 @@ def optional(
172172
behind the scenes by Depends.
173173
174174
Return:
175-
IDToken: Dictionary with IDToken information
175+
IDToken (self.idtoken_model): User information
176176
177177
raises:
178178
IDToken validation errors
@@ -201,7 +201,7 @@ def authenticate_user(
201201
is not authenticated.
202202
203203
Return:
204-
IDToken: Dictionary with IDToken information
204+
IDToken (self.idtoken_model): User information
205205
206206
raises:
207207
HTTPException(status_code=401, detail=f"Unauthorized: {err}")

fastapi_third_party_auth/grant_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class GrantType(str, Enum):
5-
"""Grant types shown in docs."""
5+
"""Grant types that can be used in the interactive documentation."""
66

77
AUTHORIZATION_CODE = "authorization_code"
88
CLIENT_CREDENTIALS = "client_credentials"

fastapi_third_party_auth/idtoken_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class IDToken(BaseModel):
1414
1515
See the specifications here. https://openid.net/specs/openid-connect-core-1_0.html#IDToken
1616
17-
Attributes:
17+
Parameters:
1818
iss (str): Issuer Identifier for the Issuer of the response.
1919
sub (str): Subject Identifier.
20-
aud (str): Audience(s) that this ID Token is intended for.
20+
aud (Union[str, List[str]]): Audience(s) that this ID Token is intended for.
2121
exp (str): Expiration time on or after which the ID Token MUST NOT be accepted for processing.
2222
iat (iat): Time at which the JWT was issued.
2323

poetry.lock

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ types-cachetools = "^0.1.9"
2828
types-requests = "^2.25.0"
2929
pre-commit = "^2.13.0"
3030
uvicorn = "^0.15.0"
31+
sphinx-rtd-theme = "^1.0.0"
3132

3233
[tool.poetry.extras]
3334
docs = ["sphinx"]

0 commit comments

Comments
 (0)