Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authenticate using User JWT-Token #293

Merged
merged 11 commits into from
Nov 7, 2023
Merged

Authenticate using User JWT-Token #293

merged 11 commits into from
Nov 7, 2023

Conversation

aMahanna
Copy link
Member

@aMahanna aMahanna commented Nov 3, 2023

Closes #238

Introduces a user_token parameter to the arango.client.ArangoClient.db method to build a JwtConnection object without a username/password and without auth_method="jwt"

also introduces set_token to arango.connection.JwtConnection and arango.connection.JwtSuperuserConnection

import os
from arango import ArangoClient

token = os.environ["ARANGODB_USER_JWT"]
db = ArangoClient().db(user_token=token)
db = ArangoClient().db(username=..., password=..., user_token=token) # Valid, but ignores `username` and `password` params

db.conn.set_token(token=...) # Valid
db.conn.refresh_token() # Raises `arango.exceptions.JWTRefreshError`, since `username/password` is not set
ArangoClient().db(user_token=expired_token) # Raises `JWTExpiredError`

@aMahanna aMahanna requested a review from geenen124 November 3, 2023 20:19
@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2023

Codecov Report

Merging #293 (74e1b0b) into main (744a6e9) will decrease coverage by 0.57%.
Report is 22 commits behind head on main.
The diff coverage is 92.05%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             main     #293      +/-   ##
==========================================
- Coverage   99.01%   98.44%   -0.57%     
==========================================
  Files          26       26              
  Lines        3958     4062     +104     
==========================================
+ Hits         3919     3999      +80     
- Misses         39       63      +24     
Files Coverage Δ
arango/aql.py 95.04% <100.00%> (ø)
arango/client.py 98.46% <100.00%> (+0.04%) ⬆️
arango/cluster.py 100.00% <100.00%> (ø)
arango/exceptions.py 100.00% <100.00%> (ø)
arango/executor.py 99.35% <100.00%> (-0.13%) ⬇️
arango/http.py 100.00% <ø> (ø)
arango/job.py 100.00% <100.00%> (ø)
arango/request.py 94.44% <100.00%> (ø)
arango/typings.py 100.00% <100.00%> (ø)
arango/utils.py 87.50% <100.00%> (-12.50%) ⬇️
... and 3 more

@aMahanna aMahanna requested a review from geenen124 November 6, 2023 17:17
Copy link
Contributor

@geenen124 geenen124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aMahanna aMahanna requested a review from geenen124 November 7, 2023 16:10
@aMahanna aMahanna merged commit 879434f into main Nov 7, 2023
6 checks passed
@aMahanna aMahanna deleted the feature/user-token-238 branch November 7, 2023 16:19
@aMahanna aMahanna restored the feature/user-token-238 branch November 7, 2023 16:19
@aMahanna aMahanna deleted the feature/user-token-238 branch November 7, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Authenticate using User JWT-Token
3 participants