Add ability to authenticate with a JWT loaded from a file. #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR, along with an upcoming PR to
xdmod
, makes it possible forxdmod-data
to authenticate to the XDMoD REST API via a JSON Web Token (JWT) loaded from a file. This is needed to support XDMoD being connected to a JupyterHub. The JupyterHub will periodically write temporary JWTs to the file~/.xdmod-jwt.env
; the changes in this PR make it so that every time a request is made byxdmod-data
to the XDMoD REST API, that file is read and the token is added as a headerAuthentication: Bearer <JWT>
to the request.The current method of instead setting an
XDMOD_API_TOKEN
environment variable is still needed since users connecting outside of a JupyterHub will still be supported. This PR makes it so that if that environment variable is defined when theDataWarehouse
is constructed, it will use that token in the request headers instead of the JWT from the file. This also supports the ability in the JupyterHub setup to interface with multiple XDMoD portals from the same notebook, as in the following:Tests performed
Type of change:
Checklist:
CHANGELOG.md
has been updatedxdmod_data/__version__.py
has been updated to the next development versionxdmod-notebooks
repository as necessary, and the notebooks all run successfully