Skip to content

Commit 43e5340

Browse files
jsstevensonkorikuzma
authored andcommitted
feat: add more reasonable graph credential config control flow (#496)
* use a default password (`"neo4j"`) matching the actual neo4j default * separate default behavior for credentials and DB location. Previously you'd have to set both to avoid default behavior. In practice it seems like neo4j tends to think of them as separate though (credentials are usually passed in tandem though so I didn't separate them further). So now, you can pass your own DB location but use default username/password, or vice versa.
1 parent c57f117 commit 43e5340

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

server/src/metakb/database.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,13 @@ def _get_credentials(
5454
uri = f"bolt://{secret['host']}:{secret['port']}"
5555
credentials = (secret["username"], secret["password"])
5656
else:
57-
if all(
58-
[
59-
"METAKB_DB_URL" in environ,
60-
"METAKB_DB_USERNAME" in environ,
61-
"METAKB_DB_PASSWORD" in environ,
62-
]
63-
):
64-
uri = environ["METAKB_DB_URL"]
57+
if not uri:
58+
uri = environ.get("METAKB_DB_URL", "bolt://localhost:7687")
59+
if (not credentials[0]) and (not credentials[1]):
6560
credentials = (
66-
environ["METAKB_DB_USERNAME"],
67-
environ["METAKB_DB_PASSWORD"],
61+
environ.get("METAKB_DB_USERNAME", "neo4j"),
62+
environ.get("METAKB_DB_PASSWORD", "neo4j"),
6863
)
69-
else: # local default settings
70-
uri = "bolt://localhost:7687"
71-
credentials = ("neo4j", "password")
7264
return uri, credentials
7365

7466

0 commit comments

Comments
 (0)