Summary
Add an optional "IA auth" plugin that allows a logged-out patron to borrow a book by providing their Internet Archive S3 credentials as an Authorization: LOW <access>:<secret> HTTP header. When valid, Lenny creates the loan record and sets a session cookie — skipping the OTP flow entirely.
This is useful for Internet Archive Labs' official Lenny instance where patrons are expected to have IA accounts.
How It Works
- Patron sends
Authorization: LOW <access>:<secret> header to POST /v1/api/items/{id}/borrow
- Lenny (if
IA_AUTH_ENABLED=true) validates the S3 keys against archive.org/services/xauthn/?op=s3auth
- Extracts the patron's IA screenname as their identifier
- Creates a loan record in the Lenny database
- Sets a signed session cookie for the patron
- Returns the normal borrow response
Configuration
New env var (opt-in, default false):
Only Lenny instances that explicitly enable this plugin will use it. The OTP flow remains unchanged for all other instances.
Files to Change
lenny/configs/__init__.py — add IA_AUTH_ENABLED config var
lenny/core/auth.py — add verify_ia_s3_keys(access, secret) -> Optional[str] function that validates via archive.org/services/xauthn/?op=s3auth
lenny/routes/api.py — in borrow_item(), check for IA S3 auth before the session cookie check when IA_AUTH_ENABLED is set
Companion Issue
References
Summary
Add an optional "IA auth" plugin that allows a logged-out patron to borrow a book by providing their Internet Archive S3 credentials as an
Authorization: LOW <access>:<secret>HTTP header. When valid, Lenny creates the loan record and sets a session cookie — skipping the OTP flow entirely.This is useful for Internet Archive Labs' official Lenny instance where patrons are expected to have IA accounts.
How It Works
Authorization: LOW <access>:<secret>header toPOST /v1/api/items/{id}/borrowIA_AUTH_ENABLED=true) validates the S3 keys againstarchive.org/services/xauthn/?op=s3authConfiguration
New env var (opt-in, default
false):Only Lenny instances that explicitly enable this plugin will use it. The OTP flow remains unchanged for all other instances.
Files to Change
lenny/configs/__init__.py— addIA_AUTH_ENABLEDconfig varlenny/core/auth.py— addverify_ia_s3_keys(access, secret) -> Optional[str]function that validates viaarchive.org/services/xauthn/?op=s3authlenny/routes/api.py— inborrow_item(), check for IA S3 auth before the session cookie check whenIA_AUTH_ENABLEDis setCompanion Issue
References
OL_S3_ACCESS_KEY/OL_S3_SECRET_KEYfor admin-side OL auth; patron auth is a parallel but separate concept