Skip to content

feat(auth): add key-pair authentication support#774

Draft
everpcpc wants to merge 1 commit into
databendlabs:mainfrom
everpcpc:feat/key-pair-auth
Draft

feat(auth): add key-pair authentication support#774
everpcpc wants to merge 1 commit into
databendlabs:mainfrom
everpcpc:feat/key-pair-auth

Conversation

@everpcpc
Copy link
Copy Markdown
Member

@everpcpc everpcpc commented May 7, 2026

Summary

Implement JWT-based key-pair authentication as per the key-pair-auth RFC.

Changes

  • Add KeyPairAuth struct supporting RSA, ECDSA (ES256), and Ed25519 private keys
  • Support encrypted PKCS#8 private keys with passphrase file
  • Handle PKCS#1 (BEGIN RSA PRIVATE KEY), SEC1 (BEGIN EC PRIVATE KEY), and PKCS#8 (BEGIN PRIVATE KEY) key formats
  • Rebuild EC PKCS#8 with named curve OID for Ring compatibility (openssl genpkey generates explicit curve params by default)
  • Add --private-key-file and --private-key-passphrase-file CLI flags
  • Support private_key_file and private_key_passphrase_file DSN query parameters
  • Send X-DATABEND-AUTH-METHOD: keypair header alongside Bearer token

Dependencies

  • jsonwebtoken = "9" — JWT encoding/signing
  • pem = "3" — PEM parsing
  • pkcs8 = { version = "0.11", features = ["encryption", "pem"] } — PKCS#8 decryption and DER parsing

Testing

  • Unit tests for RSA, EC (P-256), Ed25519, and encrypted RSA key-pair auth
  • All tests pass locally

@everpcpc everpcpc force-pushed the feat/key-pair-auth branch 2 times, most recently from cf8a0cf to 6ccd6ad Compare May 7, 2026 07:03
Implement JWT-based key-pair authentication as per the key-pair-auth RFC.

- Support RSA, ECDSA (ES256), and Ed25519 private keys
- Support encrypted PKCS#8 private keys with passphrase
- Handle PKCS#1, SEC1, and PKCS#8 key formats
- Rebuild EC PKCS#8 with named curve for Ring compatibility
- Extract PKCS#1 DER from PKCS#8 for RSA Ring compatibility
- Add --private-key-file and --private-key-passphrase-file CLI flags
- Send X-DATABEND-AUTH-METHOD: keypair header with Bearer token
@everpcpc everpcpc force-pushed the feat/key-pair-auth branch from 6ccd6ad to a5fa36e Compare May 7, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant