Feature: API Key Authentication for Programmatic Access #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
Add API key authentication to lamassu-server's admin API, enabling programmatic access from external applications without going through the interactive login flow (username/password + 2FA).
Use Case: A web app needs to manage cash unit counts, sync membership data, and perform other operations via the GraphQL API.
Current State
The admin API currently only supports session-based authentication:
lamassu_sid)This makes it difficult for external services to integrate programmatically.
Proposed Solution
Add Bearer token authentication via API keys.
Database Schema
API Key Format
lam_identifies it as a Lamassu keyImplementation
1. CLI Command for Key Generation
Create
bin/lamassu-create-api-key:2. Authentication Middleware
Create
packages/server/lib/new-admin/middlewares/apiKeyAuth.js:3. Modify Auth Directive
Update
packages/server/lib/new-admin/graphql/directives/auth.js:4. Update Apollo Context
Usage Example
Update Cash Unit Counts
Sync Membership Data
Implementation Checklist
Phase 1: Core Infrastructure
api_keystablelamassu-create-api-keyCLI commandapiKeyAuth.jsmiddlewarebuildApolloContextto check for API key@authdirective to accept API key authenticationPhase 2: Management Commands
lamassu-revoke-api-keyCLI commandlamassu-list-api-keysCLI commandPhase 3: Testing
Phase 4: Optional Enhancements
Security Considerations
Related Issues
References
api-key-auth-plan.mdin lamassu-stuff repo