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

Add an API Token Auth Mechanism #33

Merged
merged 2 commits into from
Nov 20, 2022
Merged

Conversation

JSv4
Copy link
Owner

@JSv4 JSv4 commented Nov 19, 2022

Prior to this PR, the only way to authenticate against OpenContracts is to use the JWT token, the password auth (if you've turned off auth0 authentication) or Django's session authentication. None of these are well-suited to server-side connections. It would be nice to be able to connect other backend tools and infrastructure to the platform.

This PR lets you use Authentication Tokens linked to a particular user's account. It uses DRF's token authentication app (so DRF is a dependency, but we're using this already, so no new dependencies). It provides a Graphene Middleware and an Authentication Backend, the first base on the Graphql JWT Middleware and the latter based on DRF's token auth backend.

@codecov
Copy link

codecov bot commented Nov 19, 2022

Codecov Report

Merging #33 (2aaa8d5) into main (24ea8e6) will decrease coverage by 0.33%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main      #33      +/-   ##
==========================================
- Coverage   66.19%   65.86%   -0.34%     
==========================================
  Files          47       47              
  Lines        1855     1834      -21     
==========================================
- Hits         1228     1208      -20     
+ Misses        627      626       -1     
Impacted Files Coverage Δ
opencontractserver/shared/resolvers.py 91.42% <ø> (+3.62%) ⬆️
opencontractserver/utils/permissioning_utils.py 87.67% <ø> (-1.77%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

… test documentation is terrible and WRONG). Also noticed a whole mess of log statements in the authenticator and permissioning system that are cluttering up the logs. Commented those out.
@JSv4
Copy link
Owner Author

JSv4 commented Nov 20, 2022

Coverage went down for a stupid reason in permissioning_utils.py... the comments were "using" certain vars so that counted as coverage. Lame. Those aren't proper tests and I'm not writing them now.

@JSv4 JSv4 merged commit 10b1d56 into main Nov 20, 2022
@JSv4 JSv4 deleted the JSv4/add-token-auth-for-backend-services branch November 20, 2022 00:21
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.

None yet

1 participant