Skip to content

Commit d58bfe1

Browse files
author
Kubenew
committed
Add CI, release workflow, docs, and badges
1 parent f618053 commit d58bfe1

9 files changed

Lines changed: 199 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.12"
17+
- run: pip install ruff black
18+
- run: ruff check .
19+
- run: black --check .
20+
21+
test:
22+
runs-on: ubuntu-latest
23+
strategy:
24+
matrix:
25+
python-version: ["3.9", "3.10", "3.11", "3.12"]
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
- run: pip install -e ".[dev]" || pip install -e .
32+
- run: pytest tests/ -v
33+
34+
build:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-python@v5
39+
with:
40+
python-version: "3.12"
41+
- run: pip install build
42+
- run: python -m build

.github/workflows/deploy-docs.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
- run: pip install mkdocs-material
22+
- run: mkdocs gh-deploy --force
23+
24+
deploy:
25+
environment:
26+
name: github-pages
27+
url: ${{ steps.deployment.outputs.page_url }}
28+
runs-on: ubuntu-latest
29+
needs: build
30+
steps:
31+
- uses: actions/configure-pages@v4
32+
- uses: actions/upload-pages-artifact@v3
33+
with:
34+
path: site
35+
- uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version'
8+
required: true
9+
default: '0.1.0'
10+
changelog:
11+
description: 'Changelog'
12+
required: true
13+
default: '- Initial release'
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: softprops/action-gh-release@v1
23+
with:
24+
tag_name: v${{ github.event.inputs.version }}
25+
release_name: fastapi-authz-lite v${{ github.event.inputs.version }}
26+
body: |
27+
## Changelog
28+
${{ github.event.inputs.changelog }}
29+
30+
```bash
31+
pip install fastapi-authz-lite
32+
```
33+
draft: false

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# fastapi-auth-kit
1+
# fastapi-authz-lite
22

3-
`fastapi-auth-kit` provides plug-and-play authentication for FastAPI.
3+
[![PyPI Version](https://img.shields.io/pypi/v/fastapi-authz-lite)](https://pypi.org/project/fastapi-authz-lite/)
4+
[![Python Versions](https://img.shields.io/pypi/pyversions/fastapi-authz-lite)](https://pypi.org/project/fastapi-authz-lite/)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6+
[![Tests](https://github.com/Kubenew/fastapi-auth-kit/actions/workflows/ci.yml/badge.svg)](https://github.com/Kubenew/fastapi-auth-kit/actions/workflows/ci.yml)
7+
8+
`fastapi-authz-lite` provides plug-and-play authentication for FastAPI.
49

510
## Features (v0.1.0)
611

docs/api.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# API Reference
2+
3+
## auth.create_token
4+
5+
Create a JWT token.
6+
7+
```python
8+
token = auth.create_token({"sub": "user@example.com"})
9+
```
10+
11+
## require_user
12+
13+
FastAPI dependency for protected routes.
14+
15+
```python
16+
from fastapi_auth_kit import require_user
17+
18+
@app.get("/protected")
19+
def protected(user = require_user):
20+
return {"user": user}
21+
```

docs/index.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# fastapi-authz-lite
2+
3+
Plug-and-play authentication for FastAPI.
4+
5+
## Features
6+
7+
- JWT access token creation + verification
8+
- Password hashing (bcrypt)
9+
- FastAPI dependency: `require_user()`
10+
11+
## Quick Start
12+
13+
```bash
14+
pip install fastapi-authz-lite
15+
```
16+
17+
```python
18+
from fastapi_auth_kit import auth, require_user
19+
20+
@app.get("/protected")
21+
def protected(user = require_user):
22+
return {"user": user}
23+
```

docs/installation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Installation
2+
3+
```bash
4+
pip install fastapi-authz-lite
5+
```

docs/usage.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Usage
2+
3+
```python
4+
from fastapi import FastAPI
5+
from fastapi_auth_kit import auth
6+
7+
app = FastAPI()
8+
9+
@app.post("/login")
10+
def login():
11+
token = auth.create_token({"sub": "user@example.com"})
12+
return {"access_token": token}
13+
```

mkdocs.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
site_name: fastapi-authz-lite
2+
site_description: Plug-and-play authentication for FastAPI
3+
site_url: https://Kubenew.github.io/fastapi-auth-kit
4+
repo_name: Kubenew/fastapi-auth-kit
5+
repo_url: https://github.com/Kubenew/fastapi-auth-kit
6+
7+
theme:
8+
name: material
9+
palette:
10+
primary: purple
11+
accent: light purple
12+
13+
nav:
14+
- Home: index.md
15+
- Installation: installation.md
16+
- Usage: usage.md
17+
- API: api.md
18+
19+
plugins:
20+
- search

0 commit comments

Comments
 (0)