dusktreader / flask-praetorian Goto Github PK
View Code? Open in Web Editor NEWStrong, Simple, and Precise security for Flask APIs (using jwt)
Home Page: http://flask-praetorian.readthedocs.io/en/latest/
License: MIT License
Strong, Simple, and Precise security for Flask APIs (using jwt)
Home Page: http://flask-praetorian.readthedocs.io/en/latest/
License: MIT License
After executing pip install:
File "/tmp/pip-build-79fz6d8x/flask-praetorian/setup.py", line 7, in
with open('.project_metadata.json') as meta_file:
FileNotFoundError: [Errno 2] No such file or directory: '.project_metadata.json'
Eternal tokens don't work because the value of the max interval is too great to add to the current time. So just use a very large interval instead of the maximum one.
Also, there isn't an easy way to parse a string to an Interval. So, instead of having the JWT_*_LIFESPAN variables expect to be an Interval, instead make them a dict that can be used to create an interval
pypi no longer uses the README by default. Fix that up
Lots of docstrings need to be added. Docstrings should only be added when the behavior of the function and or class is not completely self-explanatory
$ flake8 tests
tests/conftest.py:27:9: E722 do not use bare except'
(especially when it is added to the app via app.extensions
)
It should be possible for the User class used by the client code to have a validate method. This method could be used to make sure that a user is still active, hasn't changed username, etc.
The method should raise an exception if it fails
That way, the application can do what it wants with the user id and won't have to go through the extra steps (hitting the db) to get the user instance.
Otherwise, you can't import current_user_id from flask_praetorian
Create the necessary elements to get document generation working via Sphinx
See if flask-jwt-extended can be a drop-in replacement for flask-jwt
It should depict either a Roman guard or a Roman soldier's helmet and fit in relatively well with the rest of the flask ecosystem
The code that identifies the user based on id should raise a custom exception when the user cannot be found
Make sure the documentation doesn't talk about flask-jwt or flask-jwt-extended.
Also, make sure that it's removed from the requirements
So that a user supplied jwt instance can be used as an alternative to Praetorian's own instance
When passlib1.7 is released, add argon2 support so that it may be used as the encryption scheme. It should also become the default at that point.
This issue requested by dev.
The tutorial/example needs to cover:
To make the testing more robust, include a few integration tests that verify behavior with some non-plaintext hashing methods
Hello, I'm going through the quickstart guide for the first time to give flask-praetorian a try. In the quickstart,
POST /auth HTTP/1.1
Host: localhost:5000
Content-Type: application/json
{
"username": "TheDude",
"password": "abides"
}
should be
POST /login
for the current example as it does not have /auth endpoint. The docs should also reflect that.
The jsonify method of the exceptions currently uses the exception's default status code. We should allow the client code to override this
It should be possible to provision tokens that never expire. It should be possible also to have a token's refresh window never expire.
Figure out what needs to be done so that the /auth endpoint inherited from flask_jwt is available to swagger for projects that use it to automatically document their api. Make sure that the swagger documentation includes some good explanation of how the endpoint works
Perhaps a bit more description of things and better examples
Turns out that argon2 has a dependency in Ubuntu for libffi-dev. Installing via pip will not resolve this dependency.
Try adding cffi as an explicit install requirement or some of the other approaches mentioned here:
Kozea/cairocffi#14
If there is not a solution that resolves all dependencies without having to install anything but python and pip on the system, switch the default back to bcrypt
In both the decorator docstring, call out the necessary order of the decorators. Make sure it has an example as well
We will need the ability to verify a password using it's encryption algorithm and then re-encrypt with a new algorithm. This is necessary if an application decides to switch encryption methods but still needs current passwords to function correctly.
The @roles_required
and @roles_accepted
decorators should do some error checking to make sure that the @jwt.jwt_required
or @auth_required
decorators have already been applied. If they have not, a sensible exception should be raised indicating that
follow this template:
The MIT License (MIT)
=====================
Copyright © `<year>` `<copyright holders>`
<license text>
There should be a brief description of the required properties and attributes of the user class in the README
Also update the README example to show requirements for lookup
and identify
the bcrypt dependency (and default setting) causes some issue on systems where there are issues installing cffi.
by switching to sha512, we can eliminate that dependency problem
Trim down PraetorianError accordingly. add dependencies in setup.py
When running the test suite, the following warnings come up:
pytest-capturelog plugin has been merged into the core, please remove it from your requirements.
tests/test_base.py::TestPraetorian::()::test_encrypt_password
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py:794: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
tests/test_base.py::TestPraetorian::()::test_validate_jwt_data
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
tests/test_base.py::TestPraetorian::()::test_encode_jwt_token
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
tests/test_base.py::TestPraetorian::()::test_encode_eternal_jwt_token
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
tests/test_base.py::TestPraetorian::()::test_refresh_jwt_token
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
tests/test_base.py::TestPraetorian::()::test_read_token_from_header
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
tests/test_base.py::TestPraetorian::()::test_pack_header_for_user
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
tests/test_decorators.py::TestPraetorianDecorators::()::test_auth_required
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/work/flask-praetorian/tests/test_decorators.py:77: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
default_guard.access_lifespan
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2064: PendulumDeprecationWarning: The subtract_timedelta() method will be removed in version 2.0.
return self.subtract_timedelta(other)
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
tests/test_decorators.py::TestPraetorianDecorators::()::test_roles_required
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
tests/test_decorators.py::TestPraetorianDecorators::()::test_roles_accepted
/Users/tbeck/.virtualenvs/praetorian/lib/python3.6/site-packages/pendulum/pendulum.py:2081: PendulumDeprecationWarning: The add_timedelta() method will be removed in version 2.0.
return self.add_timedelta(other)
-- Docs: http://doc.pytest.org/en/latest/warnings.html
The init_app method of the Praetorian class should have some good, robust error handling
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.