Add API keys, CI workflow, Paystack key hygiene, and fix webhook_events scope - #1003
Open
brite-side0 wants to merge 1 commit into
Open
Conversation
…ts scope Closes kellymusk#973, kellymusk#974, kellymusk#975, kellymusk#976. - Add .github/workflows/ci.yml running fmt, clippy, and cargo test against a Postgres 16 service container, with TEST_DATABASE_URL always set so the silent-skip integration-test gap can't produce a false-green run in CI. - Wrap the Paystack secret key in SecretString and give PaystackProvider a redacting Debug impl, so the key cannot reach a log through {:?} or a tracing field. Document the one path that still can (reqwest's own unscoped debug/trace logging) in .env.example and README. - Implement the api_keys table: POST/GET /api-keys and DELETE /api-keys/{id}, Argon2-hashed secrets, an sk_<env>_<prefix><secret> format, and extractor support so either a JWT or an API key authenticates a request. Key creation is session-only so a leaked key can't mint its own replacement. - Make webhook_events.merchant_id nullable (migration 0007): Paystack events are platform-level and must be recorded for the UNIQUE(provider, external_id) dedup constraint to work before a merchant can be attributed.
|
@brite-side0 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #973
closes #974
closes #975
closes #976
cargo testandcargo clippyon every PR #973 —.github/workflows/ci.yml: runscargo fmt --check,cargo clippy, andcargo testagainst a Postgres 16 service container on every push/PR, withTEST_DATABASE_URLalways set so the documented silent-skip gap can't produce a green run that tested nothing.SecretString;PaystackProviderhas a hand-writtenDebugthat redacts it. Documented the one path that still can leak it (RUST_LOG=debug/reqwest=debugprints outgoing headers) in.env.exampleand a new README "Secrets and logging" section, and explicitly disabledconnection_verbose.api_keystable usage —POST /api-keysendpoint for programmatic access #975 —POST /api-keys,GET /api-keys,DELETE /api-keys/{id}. Keys aresk_<env>_<prefix><secret>, Argon2-hashed like passwords, session-JWT-only to create (an API key can't mint another API key).AuthUserextractor now accepts either credential type on the sameAuthorization: Bearerheader, disambiguated by thesk_prefix.webhook_eventstable exists in schema but is never populated — Paystack webhook deduplication is broken #976 —webhook_events.merchant_idis now nullable (migration0007), since Paystack events arrive platform-level and must be inserted for theUNIQUE(provider, external_id)dedup constraint to work before attribution to a merchant is even possible. Documentedexternal_idas the provider's event id, notdata.reference.Docs (
README.md,API.md,openapi.yaml) updated for all four.Test plan
cargo checkpasses (lib compiles clean, only pre-existing warnings).