API credentials and CLI authentication¶
KCWorks has two different authentication paths. Do not treat them as the same thing.
Path |
Where it applies |
How identity is established |
|---|---|---|
HTTP API |
REST requests, webhooks, outbound calls to Commons |
Bearer / API key on the wire; the owning account’s permission policy on the target server |
In-process CLI |
|
Flask-Principal identity (often |
Credentials below are still kept distinct so each can be rotated or revoked without affecting the others.
Important
These credentials are separate on purpose. Do not reuse one in place of another, and do not introduce a shared fallback between them.
HTTP API authentication¶
Server-held integration credentials¶
These live in the server environment. They support unattended integrations on every request or record publication. They are the only credentials that must be present in a deployed environment for normal API/webhook traffic.
Variable |
Used for |
Minimum privilege |
|---|---|---|
|
Outbound Profiles lookups ( |
Outbound: read on members and groups at Profiles. Inbound: impersonates |
|
Inbound auth for the single-sign-out webhook ( |
Impersonates |
|
Outbound provisioning of records and collections to the Commons search index ( |
Write on the Commons search documents endpoint |
|
Numeric user id impersonated by the Profiles static bearer on sync webhook routes |
Must be |
|
Numeric user id impersonated by the SSO static bearer on the logout webhook |
Must be |
Capability roles and the three service accounts
(svc-commons-profiles, svc-commons-sso, svc-group-collections) are
created automatically on app finalize by the owning packages. For an explicit
ops run (or to print status):
invenio kcworks-users ensure-service-capabilities
After the accounts exist, point STATIC_API_TOKEN_USER_ID_PROFILES and
STATIC_API_TOKEN_USER_ID_SSO at their numeric ids. Group-collection
mutations use a normal OAuth token for svc-group-collections (not a static
bearer). Full account / role / scope inventory:
Service accounts and OAuth scopes.
Operator / client API credentials¶
These authenticate HTTP clients talking to a KCWorks REST API. They are not
how in-process invenio commands authorize themselves on the local instance.
Client |
How the credential is supplied |
Authenticates against |
Minimum privilege |
|---|---|---|---|
|
|
The target KCWorks instance’s records API |
Create records and upload files in the target collection |
kcworks-import-client runs on an operator’s machine. It prompts for the key
when neither the flag nor KCWORKS_IMPORT_API_KEY is set, and fails instead of
prompting when stdin is not a terminal.
OAuth scopes (HTTP API)¶
KCWorks registers OAuth scopes and enforces them in two places: a central
API before_request map for many RDM REST rules, and @require_oauth_scopes
on webhook / group-collections views. Unmapped routes in the central map are
not denied today. Permission policy on the token owner’s identity still
applies in all cases — scopes narrow the token, capability roles gate the
account. Route inventory: Service accounts and OAuth scopes. Registration
and request-time details: OAuth scopes (developer notes).
In-process CLI authentication¶
invenio commands run inside the application process. They do not present
a bearer token to the local REST API. Authorization is the identity passed into
local services (CLI commands typically use system_identity) checked by local
permission policies.
Command |
Local authz |
Outbound HTTP credential |
|---|---|---|
|
|
None — local RDM services only |
|
Local import runs in-process (record importer services; no local API token) |
|
Record importer package CLI / service |
Local services + importer permission policy |
None |
import-test-records is the hybrid case: local write path is CLI/service auth;
the production (or other remote) fetch is ordinary HTTP API auth with a
caller-supplied token. The application does not load that token from Flask
config or the server environment — pass
--api-token "$MY_SAMPLE_DATA_TOKEN" (or an equivalent function argument).
Note
If import-test-records were run without a remote token, the remote records
API would still accept the request and return only public records. An
incomplete sample set is worse than a failed command, so the CLI requires
--api-token up front.
Credentials that are intentionally absent¶
Variable |
Status |
|---|---|
|
Removed. Export uses local services; sample import takes caller |
|
Removed. Pass |
|
Removed. Export uses local services, not a REST bearer |
|
Removed as application/config. Pass |
|
Removed. Local importer uses in-process services |
|
Removed. Superseded by |
|
Removed. Use |
Local development¶
kcworks-startup.sh pulls server-held HTTP integration credentials from
AWS Secrets Manager (see DEFAULT_SM_KEYS in that script). The keys must
already exist in the JSON secret: the filter in
scripts/kcworks_sm_secret_to_envfile.py fails in strict mode when a requested
key is missing.
Caller-supplied remote-fetch tokens (and import-client API keys) are not pulled; supply them when you run the tool that needs them.