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

kwargs bugfix #149

Merged
merged 2 commits into from
Jan 10, 2023
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
@@ -1,6 +1,13 @@
# Changelog

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.7.1] - 2023-01-10

### Bugfix

- Keyword arguments fixed, host -> databaseAddress and user -> username PR [#149] (https://github.com/datajoint/pharus/pull/149)

## [0.7.0] - 2023-01-05

### Added
Expand Down Expand Up @@ -242,6 +249,7 @@ 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.7.1]: https://github.com/datajoint/pharus/compare/0.7.0...0.7.1
[0.7.0]: https://github.com/datajoint/pharus/compare/0.6.4...0.7.0
[0.6.4]: https://github.com/datajoint/pharus/compare/0.6.3...0.6.4
[0.6.3]: https://github.com/datajoint/pharus/compare/0.6.2...0.6.3
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.7.0 docker-compose -f docker-compose-deploy.yaml up -d
PHARUS_VERSION=0.7.1 docker-compose -f docker-compose-deploy.yaml up -d

To stop the API server, use the command:

.. code-block:: bash

PHARUS_VERSION=0.7.0docker-compose -f docker-compose-deploy.yaml down
PHARUS_VERSION=0.7.1 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.7.0 docker-compose -f docker-compose-deploy.yaml pull
# PHARUS_VERSION=0.7.0 docker-compose -f docker-compose-deploy.yaml up -d
# PHARUS_VERSION=0.7.1 docker-compose -f docker-compose-deploy.yaml pull
# PHARUS_VERSION=0.7.1 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
28 changes: 14 additions & 14 deletions pharus/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def wrapper(**kwargs):
if "database_host" in request.args:
encoded_jwt = request.headers.get("Authorization").split()[1]
connect_creds = {
"host": request.args["database_host"],
"user": jwt.decode(
"databaseAddress": request.args["database_host"],
"username": jwt.decode(
encoded_jwt,
crypto_serialization.load_der_public_key(
b64decode(environ.get("PHARUS_OIDC_PUBLIC_KEY").encode())
Expand All @@ -86,8 +86,8 @@ def wrapper(**kwargs):
algorithms="RS256",
)
connection = dj.Connection(
host=connect_creds["host"],
user=connect_creds["user"],
host=connect_creds["databaseAddress"],
user=connect_creds["username"],
password=connect_creds["password"],
)
return function(connection, **kwargs)
Expand Down Expand Up @@ -126,7 +126,7 @@ def api_version() -> str:
Content-Type: application/json

{
"version": "0.7.0"
"version": "0.7.1"
}

:statuscode 200: No error.
Expand Down Expand Up @@ -173,8 +173,8 @@ def login() -> dict:
Accept: application/json

{
"host": "tutorial-db.datajoint.io",
"user": "user1",
"databaseAddress": "tutorial-db.datajoint.io",
"username": "user1",
"password": "password1"
}

Expand Down Expand Up @@ -237,8 +237,8 @@ def login() -> dict:
)
time.sleep(1)
connect_creds = {
"host": request.args["database_host"],
"user": jwt.decode(
"databaseAddress": request.args["database_host"],
"username": jwt.decode(
auth_info["jwt"],
crypto_serialization.load_der_public_key(
b64decode(environ.get("PHARUS_OIDC_PUBLIC_KEY").encode())
Expand All @@ -256,12 +256,12 @@ def login() -> dict:
)
)
connect_creds = request.json
if connect_creds.keys() < {"host", "user", "password"}:
if connect_creds.keys() < {"databaseAddress", "username", "password"}:
return dict(error="Invalid Request, check headers and/or json body")
try:
dj.Connection(
host=connect_creds["host"],
user=connect_creds["user"],
host=connect_creds["databaseAddress"],
user=connect_creds["username"],
password=connect_creds["password"],
)
except pymysql.err.OperationalError as e:
Expand All @@ -276,8 +276,8 @@ def login() -> dict:
password=root_password,
).query("FLUSH PRIVILEGES")
dj.Connection(
host=connect_creds["host"],
user=connect_creds["user"],
host=connect_creds["databaseAddress"],
user=connect_creds["username"],
password=connect_creds["password"],
)
else:
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.7.0"
__version__ = "0.7.1"
8 changes: 4 additions & 4 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def token(client):
yield client.post(
"/login",
json=dict(
host=getenv("TEST_DB_SERVER"),
user=getenv("TEST_DB_USER"),
databaseAddress=getenv("TEST_DB_SERVER"),
username=getenv("TEST_DB_USER"),
password=getenv("TEST_DB_PASS"),
),
).json["jwt"]
Expand All @@ -47,8 +47,8 @@ def group1_token(client, connection):
yield client.post(
"/login",
json=dict(
host=getenv("TEST_DB_SERVER"),
user="group1",
databaseAddress=getenv("TEST_DB_SERVER"),
username="group1",
password="group1",
),
).json["jwt"]
Expand Down