-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update password hasher to argon2 (#37)
* feat: Replace bcryp with argon2 for password hash References: - https://passlib.readthedocs.io/en/stable/narr/quickstart.html#recommended-hashes - https://pypi.org/project/argon2-cffi/ - https://pypi.org/project/bcrypt/ Signed-off-by: William José Moreno Reyes <williamjmorenor@gmail.com> * docs: Update docs Signed-off-by: William José Moreno Reyes <williamjmorenor@gmail.com> * Test: Update test Signed-off-by: William José Moreno Reyes <williamjmorenor@gmail.com> --------- Signed-off-by: William José Moreno Reyes <williamjmorenor@gmail.com>
- Loading branch information
1 parent
72a166b
commit 52d24cf
Showing
4 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# Librerias de terceros | ||
alembic | ||
appdirs | ||
argon2-cffi | ||
babel | ||
bleach | ||
bcrypt | ||
configobj | ||
diskcache | ||
flask | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright 2021 -2023 William José Moreno Reyes | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Contributors: | ||
# - William José Moreno Reyes | ||
|
||
|
||
import os | ||
import sys | ||
import pytest | ||
|
||
from now_lms import log | ||
|
||
""" | ||
Casos de uso mas comunes. | ||
""" | ||
|
||
|
||
@pytest.fixture | ||
def lms_application(): | ||
from now_lms import app | ||
|
||
app.config.update( | ||
{ | ||
"TESTING": True, | ||
"SECRET_KEY": "jgjañlsldaksjdklasjfkjj", | ||
"SQLALCHEMY_TRACK_MODIFICATIONS": False, | ||
"WTF_CSRF_ENABLED": False, | ||
"DEBUG": True, | ||
"PRESERVE_CONTEXT_ON_EXCEPTION": True, | ||
"SQLALCHEMY_ECHO": True, | ||
"SQLALCHEMY_DATABASE_URI": "sqlite://", | ||
} | ||
) | ||
|
||
yield app | ||
|
||
|
||
def test_contraseña_incorrecta(lms_application, request): | ||
|
||
if request.config.getoption("--slow") == "True": | ||
|
||
from now_lms import database, initial_setup | ||
from now_lms.auth import validar_acceso | ||
|
||
with lms_application.app_context(): | ||
from flask_login import current_user | ||
from flask_login.mixins import AnonymousUserMixin | ||
|
||
database.drop_all() | ||
initial_setup(with_tests=False, with_examples=False) | ||
|
||
with lms_application.test_client() as client: | ||
# Keep the session alive until the with clausule closes | ||
client.post("/user/login", data={"usuario": "lms-admin", "acceso": "lms_admin"}) | ||
assert isinstance(current_user, AnonymousUserMixin) | ||
assert validar_acceso("lms-admn", "lms-admin") is False |