Skip to content

Commit 41c9c3f

Browse files
committed
Update README.md and refactor code base
1 parent fbd07bc commit 41c9c3f

File tree

11 files changed

+17
-12
lines changed

11 files changed

+17
-12
lines changed

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,31 @@ pip install "git+https://github.com/${repo}.git@${latest}"
2121
## Usage
2222

2323
```python
24-
import fastapiauthenticator
24+
import fastapiauthenticator as api
2525

2626
from fastapi import FastAPI
2727

2828
app = FastAPI()
2929

30-
3130
@app.get("/public")
32-
def public_route():
31+
async def public_route():
3332
return {"message": "This is a public route"}
3433

35-
36-
def private_route():
34+
async def private_route():
3735
return {"message": "This is a private route"}
3836

39-
40-
fastapiauthenticator.Authenticator(app=app, secure_function=private_route)
37+
api.protect(
38+
app=app,
39+
params=api.Parameters(
40+
path="/private",
41+
function=private_route
42+
)
43+
)
4144
```
4245

46+
> `FastAPIAuthenticator` supports both `APIRoute` and `APIWebSocketRoute` routes.<br>
47+
> Refer [samples] directory for different use-cases.
48+
4349
## Coding Standards
4450
Docstring format: [`Google`][google-docs] <br>
4551
Styling conventions: [`PEP 8`][pep8] and [`isort`][isort]
@@ -80,6 +86,7 @@ Licensed under the [MIT License][license]
8086
[google-docs]: https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
8187
[pep8]: https://www.python.org/dev/peps/pep-0008/
8288
[isort]: https://pycqa.github.io/isort/
89+
[samples]: https://github.com/thevickypedia/FastAPIAuthenticator/tree/main/samples
8390

8491
[label-pyversion]: https://img.shields.io/badge/python-3.11%20%7C%203.12-blue
8592
[label-platform]: https://img.shields.io/badge/Platform-Linux|macOS|Windows-1f425f.svg
File renamed without changes.
File renamed without changes.
File renamed without changes.

fastapiauthenticator/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(
4242
4343
Args:
4444
app: FastAPI application instance to which the authenticator will be added.
45-
params: Parameters for the secure routes, can be a single `Parameters` object or a list of `Parameters`.
45+
params: Parameters for the secure routes can be a single `Parameters` object or a list of `Parameters`.
4646
timeout: Session timeout in seconds, default is 300 seconds (5 minutes).
4747
username: Username for authentication, can be set via environment variable 'USERNAME'.
4848
password: Password for authentication, can be set via environment variable 'PASSWORD'.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ version = { attr = "fastapiauthenticator.version.version" }
1616

1717
[project.optional-dependencies]
1818
dev = [
19+
"websockets==15.0.*",
1920
"pre-commit==4.2.*",
20-
"uvicorn==0.34.*"
21+
"uvicorn==0.34.*",
2122
]
2223

2324
[build-system]

requirements-dev.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)