Skip to content

Commit

Permalink
Rebase Branch (#133)
Browse files Browse the repository at this point in the history
* chore: fix dockerfile commands ✨ (#130)

* Chore: change Name from `AuthX` to `authx` ✨ (#131)

* docs: Fix UpperCase

* chore: Fix Code Examples (UpperCase)

* docs: change `AuthX` to `authx`

* CI: Add Build Docs for PR

* Bump version from 0.1.1 to 0.1.2 ✨(#132)

* 📝 Update release notes

* Docs: Fix `no-bare-urls`
  • Loading branch information
yezz123 authored Nov 8, 2021
1 parent 4015643 commit a6010e5
Show file tree
Hide file tree
Showing 25 changed files with 161 additions and 129 deletions.
52 changes: 16 additions & 36 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,21 @@
name: Publish docs to Netlify
on:
push:
branches:
- main
name: Build Docs

on: [pull_request]

jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: pip install -r requirements.dev.txt
- name: Build docs
run: mkdocs build -d build
runs-on: ubuntu-latest

- name: Deploy docs
uses: jsmrcaga/[email protected]
with:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_DEPLOY_TO_PROD: true
NETLIFY_DEPLOY_MESSAGE: "Prod deploy v${{ github.ref }}"
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.dev.txt
- name: Build
run: mkdocs build
41 changes: 41 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish docs to Netlify
on:
push:
branches:
- main

jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: pip install -r requirements.dev.txt
- name: Build docs
run: mkdocs build -d build

- name: Deploy docs
uses: jsmrcaga/[email protected]
with:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_DEPLOY_TO_PROD: true
NETLIFY_DEPLOY_MESSAGE: "Prod deploy v${{ github.ref }}"
10 changes: 4 additions & 6 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: pull latest
run: make pull
run: docker-compose pull
- name: Build image
run: make build
- name: Test code format -- pre-commit
run: make lint
- name: pytest
run: make test
run: docker-compose build
- name: Test image
run: docker-compose run --rm authx pytest --cov=authx/ --cov-report=html
34 changes: 7 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
help:
@echo "Targets:"
@echo " make test"
@echo " make start"
@echo " make down"
@echo " make pull"
@echo " make build"
@echo " make docker-test"
@echo " make lint"
@echo " make mkdocs"
@echo " make clean"
@echo " make clean-test"
@echo " make bumpversion-major"
@echo " make bumpversion-minor"
@echo " make bumpversion-patch"
@echo " make mkdocs"
@echo " make gh-deploy"

test:
docker-test:
docker-compose run --rm authx pytest --cov=authx/ --cov-report=html

start:
docker-compose up -d

down:
docker-compose down

pull:
docker-compose pull

build:
docker-compose build

lint:
docker-compose run --rm authx pre-commit run --all-files
pre-commit run --all-files

mkdocs:
mkdocs serve --livereload

clean:
find . -name '*.pyc' -exec rm -f {} +
Expand All @@ -52,9 +38,3 @@ bumpversion-minor:

bumpversion-patch:
bumpversion patch

mkdocs:
docker-compose run --rm authx mkdocs serve --livereload

gh-deploy:
mkdocs gh-deploy --force
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ __Note:__ Check [Release Notes](https://yezz123.github.io/AuthX/release/).

```python
from fastapi import FastAPI
from AuthX import Authentication
from authx import Authentication

app = FastAPI()
auth = Authentication()
Expand All @@ -79,8 +79,8 @@ app.include_router(auth.search_router, prefix="/api/users")

```python
from fastapi import FastAPI
from AuthX import Authentication
from AuthX.database import MongoDBBackend, RedisBackend
from authx import Authentication
from authx.database import MongoDBBackend, RedisBackend

app = FastAPI()
auth = Authentication()
Expand All @@ -100,8 +100,8 @@ auth.set_database(MongoDBBackend) # motor client

```python
from fastapi import FastAPI,APIRouter, Depends
from AuthX import User, Authentication
from AuthX.database import MongoDBBackend, RedisBackend
from authx import User, Authentication
from authx.database import MongoDBBackend, RedisBackend

app = FastAPI()
auth = Authentication()
Expand Down Expand Up @@ -138,10 +138,10 @@ def admin_test():
### Dependency injections only 📦

```python
from AuthX import AuthX
from AuthX.database import RedisBackend
from authx import authx
from authx.database import RedisBackend

auth = AuthX(#Provide Config)
auth = authx(#Provide Config)

# startup
auth.set_cache(RedisBackend) # aioredis
Expand Down Expand Up @@ -172,7 +172,7 @@ pip install -r requirements.dev.txt
You can run all the tests with:

```bash
make test
make docker-test
```

The command will start a MongoDB container for the related unit tests. So you should have [Docker](https://www.docker.com/get-started) installed.
Expand Down
2 changes: 1 addition & 1 deletion Setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.1
current_version = 0.1.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion authx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Ready to use and customizable Authentications and Oauth2 management for FastAPI"""

__version__ = "0.1.1"
__version__ = "0.1.2"

__license__ = "MIT"

Expand Down
6 changes: 3 additions & 3 deletions docs/configuration/auth/jwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ as a logout mechanism.

```py
# jwt.py
from AuthX.core.jwt import JWTBackend
from authx.core.jwt import JWTBackend

cache_backend = # Redis Configuration
access_expiration = # Access Token Expiration
Expand All @@ -37,7 +37,7 @@ async def create_token():
payload = await jwt_backend.decode_token(token)
```

__Notes:__ : For testing this function, you can mock the `cache_backend` and assert the payload, to understand you can check the Tests [core/jwt.py](https://github.com/yezz123/AuthX/blob/main/tests/core/test_core_jwt.py).
__Notes:__ : For testing this function, you can mock the `cache_backend` and assert the payload, to understand you can check the Tests [core/jwt.py](https://github.com/yezz123/authx/blob/main/tests/core/test_core_jwt.py).

Now, lets create the Function used to decode access tokens.

Expand Down Expand Up @@ -87,7 +87,7 @@ The Revoke Token is used to revoke the access token, and is used to generate a n

```py
from datetime import datetime
from AuthX.core.jwt import JWTBackend
from authx.core.jwt import JWTBackend

def logout():

Expand Down
4 changes: 2 additions & 2 deletions docs/configuration/core/user_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Let's try to test a `Usermanager` & creator based on this:
```py
import pytest

from AuthX.core.jwt import JWTBackend
from AuthX.core.user import User
from authx.core.jwt import JWTBackend
from authx.core.user import User
from tests.utils import MockCacheBackend, private_key, public_key

jwt_backend = JWTBackend(MockCacheBackend(), private_key, public_key, 60, 60 * 10)
Expand Down
4 changes: 2 additions & 2 deletions docs/configuration/models/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ There are four Pydantic models variations provided as mixins:
You should define each of those variations, inheriting from each mixin:

```py
from AuthX.models import user
from authx.models import user


class register(user.UserInRegister):
Expand All @@ -41,7 +41,7 @@ class private(user.UserPrivateInfo):
You can of course add your own properties there to fit to your needs. In the example below, we add a required string property, `first_name`, and an optional string property, `phone`.

```py
from AuthX.models import user
from authx.models import user


class register(user.UserInRegister):
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/models/social.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ There are one Pydantic model variation provided as mixin:
You should define it, inheriting from the mixin:

```py
from AuthX.models import social
from authx.models import social

class Create(social.SocialInCreate):
pass
Expand Down
6 changes: 3 additions & 3 deletions docs/configuration/routers/administration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ To Setup the Admin service, you will need to add all requirements to the object

```py
from typing import Callable, Optional
from AuthX.services.admin import AdminService
from AuthX.api import UsersRepo
from authx.services.admin import AdminService
from authx.api import UsersRepo

AdminService.setup(
repo = UserRepo,
Expand All @@ -30,7 +30,7 @@ This one gonna help use to use the setup repository and the `admin_required`.
Let's Provide the `AdminService`:

```py
from AuthX import Authentication
from authx import Authentication
from fastapi import FastAPI

app = FastAPI()
Expand Down
12 changes: 6 additions & 6 deletions docs/configuration/routers/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ The auth router will generate a set of endpoints for authenticating users.
To Setup the authentication service, you will need to add all requirements to the object `AuthService`.

```py
from AuthX.services.auth import AuthService
from AuthX.api import UsersRepo
from AuthX.core.jwt import JWTBackend
from authx.services.auth import AuthService
from authx.api import UsersRepo
from authx.core.jwt import JWTBackend

AuthService.setup(
repo = UsersRepo,
auth_backend = JWTBackend,
debug = True,
base_url = 'http://localhost:8000',
site = 'AuthX',
site = 'authx',
recaptcha_secret = None,
smtp_username = None,
smtp_password = None,
smtp_host = None,
smtp_tls = False,
display_name = 'AuthX',
display_name = 'authx',
)
```

This one gonna help use to use the authentication service, that we provide.

```py
from AuthX import Authentication
from authx import Authentication
from fastapi import FastAPI

app = FastAPI()
Expand Down
12 changes: 6 additions & 6 deletions docs/configuration/routers/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Routers

We're almost there! The last step is to configure the `AuthX` object that will wire the user manager, the authentication classes and let us generate the actual **API routes**.
We're almost there! The last step is to configure the `authx` object that will wire the user manager, the authentication classes and let us generate the actual **API routes**.

## Configure `AuthX`
## Configure `authx`

Configure `AuthX` object with all the elements we defined before. More precisely:
Configure `authx` object with all the elements we defined before. More precisely:

* `UserManager`: Dependency callable getter to inject the
user manager class instance. See [UserManager](../core/index.md).
Expand All @@ -17,7 +17,7 @@ Configure `AuthX` object with all the elements we defined before. More precisely
* `SocialInCreate` – Social User model for creating.

```py
from AuthX import Authentication
from authx import Authentication

Authentication = Authentication(
debug=True,
Expand All @@ -35,7 +35,7 @@ Authentication = Authentication(
smtp_host=None,
smtp_password=None,
smtp_tls=False,
display_name="AuthX",
display_name="authx",
recaptcha_secret=None,
social_creds=None,
social_providers=None,
Expand All @@ -45,7 +45,7 @@ Authentication = Authentication(
__Note:__ We gonna discuss what we define in `Authentication` Next.

!!! info
We Have also an other configuration option, `AuthX` and `User`.
We Have also an other configuration option, `authx` and `User`.

## Available routers

Expand Down
Loading

0 comments on commit a6010e5

Please sign in to comment.