Skip to content

Commit

Permalink
76 - Fixed conversion of token cookie into authorizaiton bearer token… (
Browse files Browse the repository at this point in the history
#77)

* 76 - Fixed conversion of token cookie into authorizaiton bearer token on request

* bumped min fastapi version

* 76 - Fixed conversion of token cookie into authorizaiton bearer token on request

* updated python build tests 3.10 version

* updated python build tests 3.10 version

* fixed precommit flake8 repo. Fixed path check in cookie token -> bearer token conversion in EasyAuthClient

* precommit re run formatting

Co-authored-by: Joshua (codemation) <joshua.jamison@nostos-genomics.com>
  • Loading branch information
codemation and Joshua (codemation) authored Dec 14, 2022
1 parent 79afc2e commit e6b8ee6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.10.8"]

steps:
- uses: actions/checkout@v2
Expand All @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7,3.8,3.9,3.10.0]
python-version: [3.7,3.8,3.9,3.10.8]
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7,3.8,3.9,3.10.0]
python-version: [3.7,3.8,3.9,3.10.8]
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
Expand Down
6 changes: 3 additions & 3 deletions easyauth/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ async def detect_token_in_cookie(request, call_next):
token_in_cookie = value
if token_in_cookie and not token_in_cookie == "INVALID":
if auth_ind:
request_dict["headers"].pop(auth_ind)
if not request_dict["path"] == f"{default_login_path}":
request_dict["headers"].append(
request.headers.__dict__["_list"].pop(auth_ind)
if request_dict["path"] != f"{default_login_path}":
request.headers.__dict__["_list"].append(
("authorization".encode(), f"bearer {token_in_cookie}".encode())
)
else:
Expand Down
6 changes: 3 additions & 3 deletions easyauth/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ async def detect_token_in_cookie(request, call_next):
token_in_cookie = value
if token_in_cookie and token_in_cookie != "INVALID":
if auth_ind:
request_dict["headers"].pop(auth_ind)
request.headers.__dict__["_list"].pop(auth_ind)
if request_dict["path"] != "/login":
request_dict["headers"].append(
request.headers.__dict__["_list"].append(
("authorization".encode(), f"bearer {token_in_cookie}".encode())
)
else:
Expand Down Expand Up @@ -869,7 +869,7 @@ async def mock_function(*args, **kwargs):

try:
token = self.decode_token(token)[1]
except Exception:
except Exception as e:
self.log.error("error decoding token")
if (
response_class is HTMLResponse
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pydbantic==0.0.22
bcrypt==3.2.0
python-jwt==3.3.0
makefun==1.9.5
fastapi>=0.65.2
fastapi>=0.88.0
uvicorn==0.15.0
PyJWT==2.0.0
python-multipart==0.0.5
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"easyschedule==0.107",
"PyJWT==2.0.0",
"python-jwt==3.3.0",
"fastapi>=0.65.2",
"fastapi>=0.88.0",
"uvicorn",
"python-multipart==0.0.5",
"easyadmin==0.169",
Expand Down
Binary file modified tests/auth.db
Binary file not shown.

0 comments on commit e6b8ee6

Please sign in to comment.