Browse Source

added passlib context configuration

funding-tag
Holger Frey 5 years ago
parent
commit
17d81f4264
  1. 9
      ordr3/security.py
  2. 2
      pyproject.toml

9
ordr3/security.py

@ -1,5 +1,6 @@
""" User Authentication and Authorization """ """ User Authentication and Authorization """
from passlib import CryptContext
from pyramid.security import Everyone, Authenticated from pyramid.security import Everyone, Authenticated
from sqlalchemy.orm.exc import NoResultFound from sqlalchemy.orm.exc import NoResultFound
from pyramid.authorization import ACLAuthorizationPolicy from pyramid.authorization import ACLAuthorizationPolicy
@ -40,6 +41,14 @@ def get_user(request):
return None return None
def get_passlib_context():
""" configures a passlib context and returns it """
ctx = CryptContext(
schemes=["argon2", "bcrypt"], default="argon2", deprecated=["bcrypt"]
)
return ctx
def includeme(config): def includeme(config):
""" initializing authentication and authorization for the Pyramid app """ initializing authentication and authorization for the Pyramid app

2
pyproject.toml

@ -24,7 +24,7 @@ classifiers = [
] ]
requires = [ requires = [
"passlib[argon2] >= 1.7.2", "passlib[argon2,bcrypt] >= 1.7.2",
"pyramid >= 1.10", "pyramid >= 1.10",
"pyramid_debugtoolbar >= 4.6.1", "pyramid_debugtoolbar >= 4.6.1",
"pyramid_jinja2 >= 2.7", "pyramid_jinja2 >= 2.7",

Loading…
Cancel
Save