Skip to content

Comments

fix/security/key-hash#3

Open
khuranarohan20 wants to merge 3 commits intocode100x:mainfrom
khuranarohan20:fix/security/key-hash
Open

fix/security/key-hash#3
khuranarohan20 wants to merge 3 commits intocode100x:mainfrom
khuranarohan20:fix/security/key-hash

Conversation

@khuranarohan20
Copy link

Implement one-way SHA-256 hashing for API keys

Previously, API keys were stored in plain text, exposing a significant security
risk if the database were compromised. This change implements a one-way hashing
mechanism so only the SHA-256 hash of each key is stored.

Changes:

  • Database: Renamed apiKey column to apiKeyHash (migration invalidates existing keys)
  • Service: Keys now generated using crypto.getRandomValues() with 32-byte entropy
  • Service: Added hashApiKey() and validateApiKey() methods for key validation
  • API Backend: Hash incoming keys before database lookup
  • Frontend: Removed key display/copy/reveal functionality (keys can't be retrieved)

  Previously, API keys were stored in plain text, exposing a significant security
  risk if the database were compromised. This change implements a one-way hashing
  mechanism so only the SHA-256 hash of each key is stored.

  Changes:
  - Database: Renamed apiKey column to apiKeyHash (migration invalidates existing keys)
  - Service: Keys now generated using crypto.getRandomValues() with 32-byte entropy
  - Service: Added hashApiKey() and validateApiKey() methods for key validation
  - API Backend: Hash incoming keys before database lookup
  - Frontend: Removed key display/copy/reveal functionality (keys can't be retrieved)
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