Skip to content

Hash password#5

Open
jwidess wants to merge 6 commits intoYuWan-030:masterfrom
jwidess:hash-password
Open

Hash password#5
jwidess wants to merge 6 commits intoYuWan-030:masterfrom
jwidess:hash-password

Conversation

@jwidess
Copy link

@jwidess jwidess commented Jan 1, 2026

Added password hashing using PBKDF2. Handles migrating from old non-hashed passwords in auth.json to the new hashed format in auth_hash.json. Updated README and README_zh-CN to reflect these changes.


AI Overview Below:

This pull request introduces secure password storage using salted PBKDF2 hashing, migrates existing plaintext credentials to the new format, and improves error logging throughout the authentication module. It also updates the mod version and refines initialization logic.

Security and Data Storage Improvements

  • Passwords are now stored as salted PBKDF2 hashes rather than plaintext, with new hashPassword and verifyPassword methods implemented in JsonAuthStorage. All registration, authentication, and password change operations now use these secure hashes.
  • Migration logic is added: On first run, if only the old plaintext auth.json exists, its credentials are automatically converted to hashed format and saved in auth_hash.json; the old file is renamed after migration.
  • The credentials file name changes from auth.json to auth_hash.json to reflect the new storage format.

Error Handling and Logging

  • Replaces e.printStackTrace() with structured logging using SLF4J in JsonAuthStorage and OfflineAuthHandler, improving error visibility for file operations and password verification. [1] [2] [3] [4]

Other Updates

  • The mod version is incremented from 1.0.1 to 1.0.3 in gradle.properties.
  • Initialization in OfflineAuthHandler now explicitly loads the config at static initialization, and an unnecessary call to AuthConfig().save() is removed from the main mod class. [1] [2]

Fixed overwriting existing config file on every start of the mod. Now changes to the config will actually persist.
trueuuid library from 1.0.2 to 1.0.5 in build.gradle and changed mod_version to 1.0.3 in gradle.properties.
Passwords are now more securely stored using PBKDF2WithHmacSHA256 with a random salt. Added migration system to convert existing plaintext passwords from the old auth.json file to hashed format in auth_hash.json
Replaced all e.printStackTrace() with proper logger error calls
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