Registration and authorization (including social) for aiohttp apps
With just a few settings you’ll give for your aiohttp site:
registration with email confirmation
authorization by email or social account (facebook, google and vkontakte for now)
reset password by email
change email with confirmation
edit current password
You can see all of this staff alive here
Databases
You can use this lib with different database backends:
UI themes
The library designed to easily change UI themes. Currently bootstrap-3 and bootstrap-4 themes are available. But it’s very easy to add new themes, actually theme - is just a folder with jinja2 templates.
Installation and configuration
Just install the library from pypi:
pip install aiohttp-login
Choice and configure one of database storages.
For postgres with asyncpg:
import asyncpg
from aiohttp_login.asyncpg_storage import AsyncpgStorage
pool = await asyncpg.create_pool(dsn='postgres:///your_db')
storage = AsyncpgStorage(pool)
For mongodb with motor:
from motor.motor_asyncio import AsyncIOMotorClient
from aiohttp_login.motor_storage import MotorStorage
db = AsyncIOMotorClient(io_loop=loop)['your_db']
storage = MotorStorage(db)
Now configure the library with a few settings:
app = web.Application(loop=loop)
app.middlewares.append(aiohttp_login.flash.middleware)
aiohttp_jinja2.setup(
app,
loader=jinja_app_loader.Loader(),
context_processors=[aiohttp_login.flash.context_processor],
)
aiohttp_login.setup(app, storage, {
'CSRF_SECRET': 'secret',
'VKONTAKTE_ID': 'your-id',
'VKONTAKTE_SECRET': 'your-secret',
'GOOGLE_ID': 'your-id',
'GOOGLE_SECRET': 'your-secret',
'FACEBOOK_ID': 'your-id',
'FACEBOOK_SECRET': 'your-secret',
'SMTP_SENDER': 'Your Name <your@gmail.com>',
'SMTP_HOST': 'smtp.gmail.com',
'SMTP_PORT': 465,
'SMTP_USERNAME': 'your@gmail.com',
'SMTP_PASSWORD': 'password'
})
That’s all. Look at the live example and its code in the example folder. Full list of available settings you can find in aiohttp_login/cfg.py file.
Run the example
Create a virtual environment and install the dependencies:
cd example python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
Create postgres database and tables:
createdb aiohttp_login psql -d aiohttp_login -f ../aiohttp_login/pg_tables.sql
Rename settings.py.template to settings.py and populate it with real data.
Run the server:
python app.py
Run tests
pip install -r requirements-dev.txt py.test
Release files for aiohttp-login 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiohttp-login-1.4.0.tar.gz | 20.1 kB | Details |
Release files / aiohttp-login-1.4.0.tar.gz
| Download URL | aiohttp-login-1.4.0.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1aa0f0a01ea613c6e80a918fe4e88f698b7ad0b39bbeaf2066e39ed75aa075f7
|
|
BLAKE2b-256 checksum How to use checksums |
ab02ebf8e45a84a12d077cd1df1e2901f73f6b33205ff331eda7f00562f4022f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |