adding latest
This commit is contained in:
138
fastapiusers/.gitignore
vendored
Normal file
138
fastapiusers/.gitignore
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# mongodb
|
||||
*mongo
|
||||
0
fastapiusers/README.rst
Normal file
0
fastapiusers/README.rst
Normal file
1
fastapiusers/docker-run
Normal file
1
fastapiusers/docker-run
Normal file
@@ -0,0 +1 @@
|
||||
docker run -d --name mongo-fastapiusers -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=root -e MONGO_INITDB_DATABASE=fastapi -v /Users/dtomlinson/git-repos/web-dev/fastapiusers/mongo/data/db:/data/db mongo:4.2.3
|
||||
1
fastapiusers/fastapiusers/__init__.py
Normal file
1
fastapiusers/fastapiusers/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__version__ = '0.1.0'
|
||||
56
fastapiusers/fastapiusers/main.py
Normal file
56
fastapiusers/fastapiusers/main.py
Normal file
@@ -0,0 +1,56 @@
|
||||
from fastapi_users import models
|
||||
from fastapi import FastAPI
|
||||
from fastapi_users.db import MongoDBUserDatabase
|
||||
import motor.motor_asyncio
|
||||
from fastapi_users.authentication import CookieAuthentication
|
||||
from fastapi_users import FastAPIUsers
|
||||
|
||||
|
||||
class User(models.BaseModel):
|
||||
pass
|
||||
|
||||
|
||||
class UserCreate(User, models.BaseUserCreate):
|
||||
pass
|
||||
|
||||
|
||||
class UserUpdate(User, models.BaseUserUpdate):
|
||||
pass
|
||||
|
||||
|
||||
class UserDB(User, models.BaseUserDB):
|
||||
pass
|
||||
|
||||
|
||||
# DATABASE_URL = 'mongodb://root:root@localhost:27017'
|
||||
DATABASE_URL = 'mongodb://127.0.0.1:27017/fastapi'
|
||||
client = motor.motor_asyncio.AsyncIOMotorClient(DATABASE_URL)
|
||||
db = client['database_name']
|
||||
collection = db['users']
|
||||
|
||||
print(db, end='\n')
|
||||
print(collection, end='\n')
|
||||
|
||||
SECRET = 'SECRET'
|
||||
|
||||
auth_backends = []
|
||||
|
||||
cookie_authentication = CookieAuthentication(
|
||||
secret=SECRET, lifetime_seconds=3600
|
||||
)
|
||||
|
||||
auth_backends.append(cookie_authentication)
|
||||
|
||||
user_db = MongoDBUserDatabase(UserDB, collection)
|
||||
|
||||
fastapi_users = FastAPIUsers(
|
||||
user_db, auth_backends, User, UserCreate, UserUpdate, UserDB, SECRET
|
||||
)
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.include_router(fastapi_users.router, prefix='/users', tags=['users'])
|
||||
|
||||
|
||||
# def on_after_register(user: User, request):
|
||||
# print(f'user {user} has been registered.')
|
||||
1035
fastapiusers/poetry.lock
generated
Normal file
1035
fastapiusers/poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
27
fastapiusers/pyproject.toml
Normal file
27
fastapiusers/pyproject.toml
Normal file
@@ -0,0 +1,27 @@
|
||||
[tool.poetry]
|
||||
name = "fastapiusers"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["dtomlinson <dtomlinson@panaetius.co.uk>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
uvicorn = "^0.11.3"
|
||||
fastapi-users = {extras = ["mongodb"], version = "^0.6.6"}
|
||||
httpx_oauth = "^0.2.1"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pytest = "^3.0"
|
||||
python-language-server = "^0.31.8"
|
||||
Rope = "^0.16.0"
|
||||
Pyflakes = "^2.1.1"
|
||||
McCabe = "^0.6.1"
|
||||
pycodestyle = "^2.5.0"
|
||||
pydocstyle = "^5.0.2"
|
||||
autopep8 = "^1.5"
|
||||
YAPF = "^0.29.0"
|
||||
pudb = "^2019.2"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.masonry.api"
|
||||
23
fastapiusers/requirements.txt
Normal file
23
fastapiusers/requirements.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
bcrypt==3.1.7
|
||||
cffi==1.14.0
|
||||
click==7.0
|
||||
dnspython==1.16.0
|
||||
email-validator==1.0.5
|
||||
fastapi==0.48.0
|
||||
fastapi-users==0.6.6
|
||||
futures==3.1.1
|
||||
h11==0.9.0
|
||||
httptools==0.1.1; sys_platform != "win32" and sys_platform != "cygwin" and platform_python_implementation != "PyPy"
|
||||
idna==2.9
|
||||
motor==2.1.0
|
||||
passlib==1.7.2
|
||||
pycparser==2.19
|
||||
pydantic==1.4
|
||||
pyjwt==1.7.1
|
||||
pymongo==3.10.1
|
||||
python-multipart==0.0.5
|
||||
six==1.14.0
|
||||
starlette==0.12.9
|
||||
uvicorn==0.11.3
|
||||
uvloop==0.14.0; sys_platform != "win32" and sys_platform != "cygwin" and platform_python_implementation != "PyPy"
|
||||
websockets==8.1
|
||||
0
fastapiusers/tests/__init__.py
Normal file
0
fastapiusers/tests/__init__.py
Normal file
5
fastapiusers/tests/test_fastapiusers.py
Normal file
5
fastapiusers/tests/test_fastapiusers.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from fastapiusers import __version__
|
||||
|
||||
|
||||
def test_version():
|
||||
assert __version__ == '0.1.0'
|
||||
Reference in New Issue
Block a user