sanic-cookies | The ultimate session management library for Sanic
kandi X-RAY | sanic-cookies Summary
kandi X-RAY | sanic-cookies Summary
sanic-cookies is a Python library. sanic-cookies has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can install using 'pip install sanic-cookies' or download it from GitHub, PyPI.
Much of the code here is borrowed from sanic_session. I wanted to make some changes that would break a big part of sanic_session's API, so I decided to create this repo instead.
Much of the code here is borrowed from sanic_session. I wanted to make some changes that would break a big part of sanic_session's API, so I decided to create this repo instead.
Support
Quality
Security
License
Reuse
Support
sanic-cookies has a low active ecosystem.
It has 6 star(s) with 1 fork(s). There are 2 watchers for this library.
It had no major release in the last 12 months.
There are 1 open issues and 0 have been closed. There are no pull requests.
It has a neutral sentiment in the developer community.
The latest version of sanic-cookies is 0.4.3
Quality
sanic-cookies has no bugs reported.
Security
sanic-cookies has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
License
sanic-cookies is licensed under the MIT License. This license is Permissive.
Permissive licenses have the least restrictions, and you can use them in most projects.
Reuse
sanic-cookies releases are not available. You will need to build from source code and install.
Deployable package is available in PyPI.
Build file is available. You can build the component from source.
Installation instructions, examples and code snippets are available.
Top functions reviewed by kandi - BETA
kandi has reviewed sanic-cookies and discovered the below as its top functions. This is intended to give you an instant insight into sanic-cookies implemented functionality, and help decide if they suit your requirements.
- Open a session object
- Return the session ID associated with the request
- Fetch session information
- Get a value from the cache
- Close session
- Remove cookie from response
- Store a session
- Save session dict
- Fetch a cookie
- Decrypt a value
- Decorator to require authentication
- Decorator for views that require login
- Store a value in the cache
- Delete a session
- Store a value in a request
- Set the expiry for the cookie
- Store session data
- Fetch a value from the store
- Fetch the value for the given sid
Get all kandi verified functions for this library.
sanic-cookies Key Features
No Key Features are available at this moment for sanic-cookies.
sanic-cookies Examples and Code Snippets
Copy
from sanic_cookies import AuthSession, AioRedis, login_required
from sanic import Sanic
aioredis = Aioredis(aioredis_pool_instance)
app = Sanic()
auth_session = AuthSession(
app,
master_interface=aioredis,
session_name='auth_session',
Copy
from sanic_cookies import Session, Aioredis
from sanic import Sanic
aioredis = AioRedis(aioredis_pool_instance)
app = Sanic()
sess = Session(app, master_interface=aioredis, session_name='my_1st_sess')
@app.route('/')
async def index(request):
a
Copy
from sanic_cookies import Session, InMemory
from sanic import Sanic
app = Sanic()
Session(app, master_interface=InMemory())
@app.route('/')
async def handler(request):
async with request['session'] as sess:
sess['foo'] = 'bar'
Community Discussions
No Community Discussions are available at this moment for sanic-cookies.Refer to stack overflow page for discussions.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sanic-cookies
i. Open a Python terminal and generate a new Fernet key:.
In memory from sanic_cookies import Session, InMemory from sanic import Sanic interface = InMemory() app = Sanic() Session(app, master_interface=interface) # You can skip this part if you don't want scheduled stale sessions cleanup @app.listener('before_server_start') def init_inmemory(app, loop): interface.init() @app.listener('after_server_stop') def kill_inmemory(app, loop): interface.kill() @app.route('/') async def handler(request): async with request['session'] as sess: sess['foo'] = 'bar'
Aioredis from aioredis import Aioredis from sanic_cookies import Aioredis as AioredisInterface from sanic import Sanic app = Sanic() aioredis_pool_instance = Aioredis() aioredis = AioredisInterface(aioredis_pool_instance) Session(app, master_interface=interface) @app.route('/') async def handler(request): async with request['session'] as sess: sess['foo'] = 'bar'
Encrypted in-cookie i. Open a Python terminal and generate a new Fernet key: >>> from cryptography.fernet import Fernet >>> SESSION_KEY = Fernet.generate_key() >>> print(SESSION_KEY) b'copy me to your sanic app and keep me really secure' ii. Your app from sanic import Sanic from sanic_cookies import Session, InCookieEncrypted app = Sanic() app.config.SESSION_KEY = SESSION_KEY Session( app, master_interface=InCookieEncrypted(app.config.SESSION_KEY), ) @app.route('/') async def handler(request): async with request['session'] as sess: sess['foo'] = 'bar'
Gino-AsyncPG (Postgres 9.5+): i. Manually create a table: CREATE TABLE IF NOT EXISTS sessions ( created_at timestamp without time zone NOT NULL, expires_at timestamp without time zone, sid character varying, val character varying, CONSTRAINT sessions_pkey PRIMARY KEY (sid) ); ii. Add the interface: from sanic import Sanic from gino.ext.sanic import Gino from sanic_cookies import GinoAsyncPG from something_secure import DB_SETTINGS app = Sanic() app.config.update(DB_SETTINGS) db = Gino() db.init_app(app) interface = GinoAsyncPG(client=db) auth_session = AuthSession(app, master_interface=interface) if __name__ == '__main__': app.run(host='127.0.0.1', port='8080')
In memory from sanic_cookies import Session, InMemory from sanic import Sanic interface = InMemory() app = Sanic() Session(app, master_interface=interface) # You can skip this part if you don't want scheduled stale sessions cleanup @app.listener('before_server_start') def init_inmemory(app, loop): interface.init() @app.listener('after_server_stop') def kill_inmemory(app, loop): interface.kill() @app.route('/') async def handler(request): async with request['session'] as sess: sess['foo'] = 'bar'
Aioredis from aioredis import Aioredis from sanic_cookies import Aioredis as AioredisInterface from sanic import Sanic app = Sanic() aioredis_pool_instance = Aioredis() aioredis = AioredisInterface(aioredis_pool_instance) Session(app, master_interface=interface) @app.route('/') async def handler(request): async with request['session'] as sess: sess['foo'] = 'bar'
Encrypted in-cookie i. Open a Python terminal and generate a new Fernet key: >>> from cryptography.fernet import Fernet >>> SESSION_KEY = Fernet.generate_key() >>> print(SESSION_KEY) b'copy me to your sanic app and keep me really secure' ii. Your app from sanic import Sanic from sanic_cookies import Session, InCookieEncrypted app = Sanic() app.config.SESSION_KEY = SESSION_KEY Session( app, master_interface=InCookieEncrypted(app.config.SESSION_KEY), ) @app.route('/') async def handler(request): async with request['session'] as sess: sess['foo'] = 'bar'
Gino-AsyncPG (Postgres 9.5+): i. Manually create a table: CREATE TABLE IF NOT EXISTS sessions ( created_at timestamp without time zone NOT NULL, expires_at timestamp without time zone, sid character varying, val character varying, CONSTRAINT sessions_pkey PRIMARY KEY (sid) ); ii. Add the interface: from sanic import Sanic from gino.ext.sanic import Gino from sanic_cookies import GinoAsyncPG from something_secure import DB_SETTINGS app = Sanic() app.config.update(DB_SETTINGS) db = Gino() db.init_app(app) interface = GinoAsyncPG(client=db) auth_session = AuthSession(app, master_interface=interface) if __name__ == '__main__': app.run(host='127.0.0.1', port='8080')
Support
For any new features, suggestions and bugs create an issue on GitHub.
If you have any questions check and ask questions on community page Stack Overflow .
Find more information at:
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page