|
| 1 | +# User Item Sync |
| 2 | + |
| 3 | +Create or update OSW `User` items from the MediaWiki accounts of an OSL |
| 4 | +instance, enriching ORCID users from the public ORCID API. The run is |
| 5 | +idempotent and previews every change before writing. |
| 6 | + |
| 7 | +## When to use it |
| 8 | + |
| 9 | +OSL instances gain accounts from manual creation and from whitelisted ORCID |
| 10 | +single sign-on (whose username is the ORCID iD). Those accounts have no |
| 11 | +semantic `User` item until this tool reconciles them. |
| 12 | + |
| 13 | +## Run it |
| 14 | + |
| 15 | +```bash |
| 16 | +uv run python examples/user_sync.py --domain your-instance.example.org --dry-run |
| 17 | +``` |
| 18 | + |
| 19 | +Credentials are read from `accounts.pwd.yaml` (or `--cred-filepath`), the same |
| 20 | +mechanism as `OswExpress`. Start with `--dry-run` to preview, then run without |
| 21 | +it to write after confirming at the prompt. |
| 22 | + |
| 23 | +### Options |
| 24 | + |
| 25 | +| Flag | Effect | |
| 26 | +| --- | --- | |
| 27 | +| `--domain` | Target OSL domain. | |
| 28 | +| `--cred-filepath` | Path to `accounts.pwd.yaml`. | |
| 29 | +| `--dry-run` | Preview only; never writes. | |
| 30 | +| `--yes` | Non-interactive: create and gap-fill, keep existing on conflicts. | |
| 31 | +| `--limit N` | Process at most N accounts (testing). | |
| 32 | +| `--orcid-only` | Only accounts whose username is an ORCID iD. | |
| 33 | +| `--include-system` | Do not skip MediaWiki reserved system accounts. | |
| 34 | +| `--no-redirects` | Do not create `User:` redirect pages. | |
| 35 | +| `--no-organizations` | Do not link ORCID affiliations to Organization items. | |
| 36 | + |
| 37 | +## What it does |
| 38 | + |
| 39 | +1. Enumerate MediaWiki accounts, skipping bots and privileged groups |
| 40 | + (`bot`, `sysop`, `bureaucrat`, `interface-admin`) and MediaWiki reserved |
| 41 | + system usernames. |
| 42 | +2. Enrich ORCID users from `https://pub.orcid.org/v3.0/<id>` (names, public |
| 43 | + email, websites, employment or affiliation). |
| 44 | +3. Map each account to a proposed `User` item with a deterministic id |
| 45 | + (uuid5 on the ORCID iD, else the username), so re-runs are idempotent. |
| 46 | +4. Reconcile against existing items by `username` into NEW, GAP_FILL, CONFLICT |
| 47 | + or UNCHANGED, then preview and resolve conflicts interactively. |
| 48 | +5. Store items, create `User:<username>` redirects to each item, ensure linked |
| 49 | + Organization items, and verify by reloading. |
| 50 | + |
| 51 | +## Notes |
| 52 | + |
| 53 | +- MediaWiki does not expose other users' email or real name, so ORCID is the |
| 54 | + only source of rich data. Non-ORCID accounts get username-based placeholder |
| 55 | + names, flagged in the preview. |
| 56 | +- On a first accepted run the library autofetches schemas and may regenerate |
| 57 | + `src/osw/model/entity.py`; restore it if you do not want that change. |
0 commit comments