Skip to content

Commit

Permalink
Add support for secret key (#405)
Browse files Browse the repository at this point in the history
Secret keys are JWTs prefixed with nbwt_ or edbt_ for authentication,
default to secret_key in $config_dir/$cloud_profile.json for cloud instances.
  • Loading branch information
fantix committed Feb 9, 2023
1 parent 33a2f6a commit df1f6fb
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 24 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,23 @@ jobs:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
edgedb-version: [stable , nightly]
os: [ubuntu-latest, macos-latest, windows-2019]
os: [ubuntu-20.04, ubuntu-latest, macos-latest, windows-2019]
loop: [asyncio, uvloop]
exclude:
# uvloop does not support windows
- loop: uvloop
os: windows-2019
# Python 3.7 on ubuntu-22.04 has a broken OpenSSL 3.0
- python-version: 3.7
os: ubuntu-latest
- python-version: 3.8
os: ubuntu-20.04
- python-version: 3.9
os: ubuntu-20.04
- python-version: 3.10
os: ubuntu-20.04
- python-version: 3.11
os: ubuntu-20.04

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -70,7 +81,7 @@ jobs:
server-version: ${{ matrix.edgedb-version }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
if: steps.release.outputs.version == 0
with:
python-version: ${{ matrix.python-version }}
Expand Down
9 changes: 9 additions & 0 deletions docs/api/asyncio_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Client
.. py:function:: create_async_client(dsn=None, *, \
host=None, port=None, \
user=None, password=None, \
secret_key=None, \
database=None, \
timeout=60, \
concurrency=None)
Expand Down Expand Up @@ -85,6 +86,14 @@ Client
other users and applications may be able to read it without needing
specific privileges.

:param secret_key:
Secret key to be used for authentication, if the server requires one.
If not specified, the value parsed from the *dsn* argument is used,
or the value of the ``EDGEDB_SECRET_KEY`` environment variable.
Note that the use of the environment variable is discouraged as
other users and applications may be able to read it without needing
specific privileges.

:param float timeout:
Connection timeout in seconds.

Expand Down
9 changes: 9 additions & 0 deletions docs/api/blocking_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Client
.. py:function:: create_client(dsn=None, *, \
host=None, port=None, \
user=None, password=None, \
secret_key=None, \
database=None, \
timeout=60, \
concurrency=None)
Expand Down Expand Up @@ -85,6 +86,14 @@ Client
other users and applications may be able to read it without needing
specific privileges.

:param secret_key:
Secret key to be used for authentication, if the server requires one.
If not specified, the value parsed from the *dsn* argument is used,
or the value of the ``EDGEDB_SECRET_KEY`` environment variable.
Note that the use of the environment variable is discouraged as
other users and applications may be able to read it without needing
specific privileges.

:param float timeout:
Connection timeout in seconds.

Expand Down
2 changes: 2 additions & 0 deletions edgedb/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ def create_async_client(
credentials_file: str = None,
user: str = None,
password: str = None,
secret_key: str = None,
database: str = None,
tls_ca: str = None,
tls_ca_file: str = None,
Expand All @@ -397,6 +398,7 @@ def create_async_client(
credentials_file=credentials_file,
user=user,
password=password,
secret_key=secret_key,
database=database,
tls_ca=tls_ca,
tls_ca_file=tls_ca_file,
Expand Down
2 changes: 2 additions & 0 deletions edgedb/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ def __init__(
credentials_file: str = None,
user: str = None,
password: str = None,
secret_key: str = None,
database: str = None,
tls_ca: str = None,
tls_ca_file: str = None,
Expand All @@ -687,6 +688,7 @@ def __init__(
"credentials_file": credentials_file,
"user": user,
"password": password,
"secret_key": secret_key,
"database": database,
"timeout": timeout,
"tls_ca": tls_ca,
Expand Down
2 changes: 2 additions & 0 deletions edgedb/blocking_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def create_client(
credentials_file: str = None,
user: str = None,
password: str = None,
secret_key: str = None,
database: str = None,
tls_ca: str = None,
tls_ca_file: str = None,
Expand All @@ -420,6 +421,7 @@ def create_client(
credentials_file=credentials_file,
user=user,
password=password,
secret_key=secret_key,
database=database,
tls_ca=tls_ca,
tls_ca_file=tls_ca_file,
Expand Down
Loading

0 comments on commit df1f6fb

Please sign in to comment.