1
0
Fork 0
forked from 0x2E/fusion
Commit graph

12 commits

Author SHA1 Message Date
Yuan
bc8109fe39
refactor: replace zap log with slog (#150)
* refactor: replace zap log with slog

* fix
2025-04-25 17:18:25 +08:00
Yuan
dd0d2e7d7d
feat: make the password optional (#128)
* feat: make the password optional

* fix: put the check outside HashPassword

* refactor: change PasswordHash to a pointer type for better checking
2025-04-05 20:14:31 +08:00
Michael Lynch
bfd4e8c66b Check passwords based on hashes rather than plaintext
fusion's current password mechanism is vulnerable to a timing attack:

https://en.wikipedia.org/wiki/Timing_attack

Because fusion checks passwords using simple character-by-character string comparison, a password attempt that begins with the correct characters will take longer to evaluate than one that starts with incorrect characters. For example, if the correct password is 'platypus123' then a password attempt of 'plates' will take longer to evaluate than 'spoons' because 'plates' and 'platypus' share a common prefix. An attacker who attempts the password 'plates' will know that they likely have the correct prefix.

To prevent the timing attack, this change hashes the user's password using PBKDF2 and compares hashes using subtle.ConstantTimeCompare, which is specifically designed to prevent timing attacks.
2025-01-12 11:31:01 -05:00
Michael Lynch
15caa9988b Get rid of global state for config 2025-01-04 20:00:25 -05:00
Michael Lynch
41784ec681 Make conf settings read-only
It feels a bit messy that the entire program has write access to the configuration as a shared global object. Shared globals make it more difficult to reason about a program's behavior.

This rewrite reduces the problem a bit by making the shared global state read-only after the client calls conf.Load.
2025-01-02 20:24:36 -05:00
Michael Lynch
c8bdbf9a1f Rename .env to .env.example
It caught me by surprise during development that fusion was reading environment variables from .env, as that's not really clear anywhere.

I think it's a bit of a gotcha, so I added logging to make the behavior clearer, and I renamed the default .env file to .env.example so that the user has to explicitly choose to use a .env file.

Keeping the real .env file out of source control also protects developers from accidentally committing their real password to source control and leaking it by mistake.
2024-12-23 21:02:15 -05:00
rook1e
a26c8e0bf7
feat: support hosting as a TLS server directly 2024-08-01 21:20:07 +08:00
rook1e
f047af03cb
fix: skip non-existent .env 2024-08-01 21:12:41 +08:00
linjiaqing
27eb100556 feat: add an env param "InSecure" to allow non-https deploy 2024-08-01 12:48:55 +08:00
rook1e
977a3fa28e
fix: add debug mode 2024-03-08 13:19:32 +08:00
rook1e
e1d4e4876e
chore: add dockerfile and doc 2024-03-06 20:48:55 +08:00
rook1e
e9b065e9fb
init 2024-03-06 16:54:13 +08:00