Skip to content

Commit

Permalink
Upgrade to 3.1.3 propelauth-py for API Keys (#6)
Browse files Browse the repository at this point in the history
Also update tests for the leeway change
  • Loading branch information
andrew-propelauth authored Jun 6, 2023
1 parent 515ed2a commit 9598ec8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
27 changes: 25 additions & 2 deletions propelauth_fastapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,19 @@ def _handle_forbidden_exception(e: ForbiddenException, debug_mode: bool):
"create_magic_link", "create_access_token",
"migrate_user_from_external_source", "create_org", "add_user_to_org",
"update_org_metadata",
"delete_user", "disable_user", "enable_user",
"allow_org_to_setup_saml_connection", "disallow_org_to_setup_saml_connection"
"delete_user", "disable_user", "enable_user", "disable_user_2fa",
"enable_user_can_create_orgs", "disable_user_can_create_orgs",
"allow_org_to_setup_saml_connection", "disallow_org_to_setup_saml_connection",

"fetch_api_key",
"fetch_current_api_keys",
"fetch_archived_api_keys",
"create_api_key",
"update_api_key",
"delete_api_key",
"validate_api_key",
"validate_personal_api_key",
"validate_org_api_key",
])


Expand Down Expand Up @@ -166,6 +177,18 @@ def init_auth(auth_url: str, api_key: str, token_verification_metadata: TokenVer
enable_user=auth.enable_user,
disable_user=auth.disable_user,
delete_user=auth.delete_user,
disable_user_2fa=auth.disable_user_2fa,
enable_user_can_create_orgs=auth.enable_user_can_create_orgs,
disable_user_can_create_orgs=auth.disable_user_can_create_orgs,
allow_org_to_setup_saml_connection=auth.allow_org_to_setup_saml_connection,
disallow_org_to_setup_saml_connection=auth.disallow_org_to_setup_saml_connection,
fetch_api_key=auth.fetch_api_key,
fetch_current_api_keys=auth.fetch_current_api_keys,
fetch_archived_api_keys=auth.fetch_archived_api_keys,
create_api_key=auth.create_api_key,
update_api_key=auth.update_api_key,
delete_api_key=auth.delete_api_key,
validate_api_key=auth.validate_api_key,
validate_personal_api_key=auth.validate_personal_api_key,
validate_org_api_key=auth.validate_org_api_key,
)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name="propelauth-fastapi",
version="2.1.2",
version="2.1.3",
description="A FastAPI library for managing authentication, backed by PropelAuth",
long_description=README,
long_description_content_type="text/markdown",
Expand All @@ -20,7 +20,7 @@
author="PropelAuth",
author_email="support@propelauth.com",
license="MIT",
install_requires=["propelauth-py==3.1.2", "requests"],
install_requires=["propelauth-py==3.1.3", "requests"],
setup_requires=pytest_runner,
tests_require=["pytest==4.4.1"],
test_suite="tests",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_optional_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_optional_user_with_wrong_token(optional_user_route, client, rsa_keys):

def test_optional_user_with_expired_token(optional_user_route, client, rsa_keys):
user_id = random_user_id()
access_token = create_access_token({"user_id": user_id}, rsa_keys.private_pem, expires_in=timedelta(minutes=-1))
access_token = create_access_token({"user_id": user_id}, rsa_keys.private_pem, expires_in=timedelta(minutes=-5))
response = client.get(optional_user_route, headers={"Authorization": "Bearer " + access_token})
assert response.status_code == 200
assert response.text == "none"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_require_org_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_require_org_member_with_expired_token(app, auth, client, rsa_keys):
access_token = create_access_token({
"user_id": user_id,
"org_id_to_org_member_info": org_id_to_org_member_info
}, rsa_keys.private_pem, expires_in=timedelta(minutes=-1))
}, rsa_keys.private_pem, expires_in=timedelta(minutes=-5))

response = client.get(route_for(org["org_id"]), headers={"Authorization": "Bearer " + access_token})
assert response.status_code == 401
Expand Down
2 changes: 1 addition & 1 deletion tests/test_require_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_require_user_with_wrong_token(require_user_route, client, rsa_keys):

def test_require_user_with_expired_token(require_user_route, client, rsa_keys):
user_id = random_user_id()
access_token = create_access_token({"user_id": user_id}, rsa_keys.private_pem, expires_in=timedelta(minutes=-1))
access_token = create_access_token({"user_id": user_id}, rsa_keys.private_pem, expires_in=timedelta(minutes=-5))
response = client.get(require_user_route, headers={"Authorization": "Bearer " + access_token})
assert response.status_code == 401

Expand Down

0 comments on commit 9598ec8

Please sign in to comment.