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

Return id_token on login #139

Merged
merged 2 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.

## [0.5.5] - 2022-10-26

### Fixed

- Return `id_token` on login since it can be useful in OIDC logout flow PR [#139](https://github.com/datajoint/pharus/pull/139)

## [0.5.4] - 2022-10-20

### Fixed
Expand Down Expand Up @@ -188,6 +194,8 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
- Support for DataJoint attribute types: `varchar`, `int`, `float`, `datetime`, `date`, `time`, `decimal`, `uuid`.
- Check dependency utility to determine child table references.

[0.5.5]: https://github.com/datajoint/pharus/compare/0.5.4...0.5.5
[0.5.4]: https://github.com/datajoint/pharus/compare/0.5.3...0.5.4
[0.5.3]: https://github.com/datajoint/pharus/compare/0.5.2...0.5.3
[0.5.2]: https://github.com/datajoint/pharus/compare/0.5.1...0.5.2
[0.5.1]: https://github.com/datajoint/pharus/compare/0.5.0...0.5.1
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ To start the API server, use the command:

.. code-block:: bash

PHARUS_VERSION=0.5.3 docker-compose -f docker-compose-deploy.yaml up -d
PHARUS_VERSION=0.5.5 docker-compose -f docker-compose-deploy.yaml up -d

To stop the API server, use the command:

.. code-block:: bash

PHARUS_VERSION=0.5.3 docker-compose -f docker-compose-deploy.yaml down
PHARUS_VERSION=0.5.5 docker-compose -f docker-compose-deploy.yaml down

References
----------
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PHARUS_VERSION=0.5.3 docker-compose -f docker-compose-deploy.yaml pull
# PHARUS_VERSION=0.5.3 docker-compose -f docker-compose-deploy.yaml up -d
# PHARUS_VERSION=0.5.5 docker-compose -f docker-compose-deploy.yaml pull
# PHARUS_VERSION=0.5.5 docker-compose -f docker-compose-deploy.yaml up -d
#
# Intended for production deployment.
# Note: You must run both commands above for minimal outage
Expand Down
18 changes: 11 additions & 7 deletions pharus/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def api_version() -> str:
Content-Type: application/json

{
"version": "0.5.3"
"version": "0.5.5"
}

:statuscode 200: No error.
Expand Down Expand Up @@ -223,29 +223,33 @@ def login() -> dict:
headers=headers,
auth=auth,
)
encoded_jwt = result.json()["access_token"]
auth_info = dict(
jwt=result.json()["access_token"], id=result.json()["id_token"]
)
connect_creds = {
"databaseAddress": request.args["database_host"],
"username": jwt.decode(
encoded_jwt,
auth_info["jwt"],
crypto_serialization.load_der_public_key(
b64decode(environ.get("PHARUS_OIDC_PUBLIC_KEY").encode())
),
algorithms="RS256",
options=dict(verify_aud=False),
)[environ.get("PHARUS_OIDC_SUBJECT_KEY")],
"password": encoded_jwt,
"password": auth_info["jwt"],
}
else: # Database login
# Generate JWT key and send it back
encoded_jwt = jwt.encode(
request.json, environ["PHARUS_PRIVATE_KEY"], algorithm="RS256"
auth_info = dict(
jwt=jwt.encode(
request.json, environ["PHARUS_PRIVATE_KEY"], algorithm="RS256"
)
)
connect_creds = request.json
if connect_creds.keys() < {"databaseAddress", "username", "password"}:
return dict(error="Invalid Request, check headers and/or json body")
_DJConnector._attempt_login(**connect_creds)
return dict(jwt=encoded_jwt)
return dict(**auth_info)
except Exception as e:
return str(e), 500

Expand Down
2 changes: 1 addition & 1 deletion pharus/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Package metadata."""
__version__ = "0.5.4"
__version__ = "0.5.5"