Skip to content

Commit ce3d5c5

Browse files
committed
fix: restore accounts.pwd.yaml default at project root for file login
The credential refactor moved the default credential path into ./osw_files/, diverging from the documented ./accounts.pwd.yaml at the project root and breaking the zero-config multi-instance transfer file. Restore the root default, protect it with root-anchored .gitignore entries (the existing */ patterns missed the root), align the express.py docstrings, and document the .env vs. accounts.pwd.yaml credential paths.
1 parent f85586f commit ce3d5c5

4 files changed

Lines changed: 41 additions & 9 deletions

File tree

‎.gitignore‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ playground
6161

6262
.env
6363

64-
# Automatically added by osw.auth.CredentialManager.save_credentials_to_file:
64+
# Credential files and osw work dirs, in subdirectories and at the project root.
65+
# The root accounts.pwd.yaml is the default credential file (read only, never
66+
# written automatically); ignoring it prevents a hand-maintained credential
67+
# file from being staged. Credentials primarily come from .env / env vars.
6568
*/osw_files/*
66-
69+
/osw_files/
6770
*/accounts.pwd.yaml
71+
/accounts.pwd.yaml
6872
.ign
6973
.claude

‎docs/dev.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,28 @@ every push to `main` (workflow `integration.yml`).
8181
--wiki_password "<password>"
8282
```
8383

84+
### Credentials
85+
86+
Credentials are never written to disk automatically. For a single instance,
87+
set `OSW_USERNAME` / `OSW_PASSWORD` (e.g. via a `.env` file) or answer the
88+
interactive prompt; both are kept in memory only.
89+
90+
For transfers between several OpenSemanticLab instances, keep a hand-maintained
91+
`accounts.pwd.yaml` at the project root (read only, gitignored by default), with
92+
one entry per instance IRI:
93+
94+
```yaml
95+
https://wiki-a.example.org:
96+
username: <login>
97+
password: <password>
98+
https://wiki-b.example.org:
99+
username: <login>
100+
password: <password>
101+
```
102+
103+
`OswExpress(domain=...)` with no credential arguments reads this file if present;
104+
each connection is matched to the longest IRI it contains.
105+
84106
## Documentation
85107

86108
Serve locally with live reload at `http://localhost:8000`, or run the

‎src/osw/defaults.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
OSW_FILES_DIR_DEFAULT = BASE_PATH / "osw_files"
1313
DOWNLOAD_DIR_DEFAULT = OSW_FILES_DIR_DEFAULT / "downloads"
1414
CRED_FILENAME_DEFAULT = "accounts.pwd.yaml"
15-
CRED_FILEPATH_DEFAULT = OSW_FILES_DIR_DEFAULT / CRED_FILENAME_DEFAULT
15+
# Default credential file lives at the project root (current working directory),
16+
# matching the documented location and enabling a hand-maintained multi-instance
17+
# transfer file. It is only ever read; credentials are never written here
18+
# automatically. See osw.auth.CredentialManager.
19+
CRED_FILEPATH_DEFAULT = BASE_PATH / CRED_FILENAME_DEFAULT
1620
WIKI_DOMAIN_DEFAULT = "wiki-dev.open-semantic-lab.org"
1721

1822

‎src/osw/express.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ class FileResult(OswBaseModel):
315315
variable 'OSW_DOMAIN'. If None the domain is parsed from the URL."""
316316
cred_filepath: Optional[Union[str, Path]] = None
317317
"""The filepath to the credentials file. Will only be used if cred_mngr is
318-
None. If cred_filepath is None, a credentials file named 'accounts.pwd.yaml' is
319-
expected to be found in the current working directory.
318+
None. If cred_filepath is None, the default credentials file 'accounts.pwd.yaml'
319+
in the current working directory (project root) is read if present.
320320
"""
321321
cred_mngr: Optional[CredentialManager] = None
322322
"""A credential manager object. If None, a new credential manager will be created
@@ -552,8 +552,9 @@ def osw_download_file(
552552
variable 'OSW_DOMAIN'. If None the domain is parsed from the URL.
553553
cred_filepath
554554
The filepath to the credentials file. Will only be used if cred_mngr is
555-
None. If cred_filepath is None, a credentials file named 'accounts.pwd.yaml'
556-
is expected to be found in the current working directory.
555+
None. If cred_filepath is None, the default credentials file
556+
'accounts.pwd.yaml' in the current working directory (project root) is read
557+
if present.
557558
cred_mngr
558559
A credential manager object. If None, a new credential manager will be created
559560
using the cred_filepath.
@@ -774,8 +775,9 @@ def osw_upload_file(
774775
the URL. If fpt_or_url is no URL user must specify the domain.
775776
cred_filepath
776777
The filepath to the credentials file. Will only be used if cred_mngr is
777-
None. If cred_filepath is None, a credentials file named 'accounts.pwd.yaml'
778-
is expected to be found in the current working directory.
778+
None. If cred_filepath is None, the default credentials file
779+
'accounts.pwd.yaml' in the current working directory (project root) is read
780+
if present.
779781
cred_mngr
780782
A credential manager object. If None, a new credential manager will be created
781783
using the cred_filepath.

0 commit comments

Comments
 (0)