mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-09 16:35:53 +02:00
[GH-ISSUE #1419] declarative users are unable to login-in, subscribe #999
Labels
No labels
ai-generated
android-app
android-app
android-app
🪲 bug
build
build
dependencies
docs
enhancement
enhancement
🔥 HOT
in-progress 🏃
ios
prio:low
prio:low
pull-request
question
🔒 security
server
server
unified-push
web-app
website
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ntfy#999
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jkummerow on GitHub (Aug 8, 2025).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1419
🐞 Describe the bug
Declaratively created users are unable to log-in or subscribe to protected topics.
Definition via env variables in docker compose according to example in the docs, see https://docs.ntfy.sh/config/#example-config
Login fails with
Login failed: Invalid username or password💻 Components impacted
ntfy server 2.14.0 on docker compose
running on linux 6.12 for arm64
💡 Screenshots and/or logs
log entry:
ntfy access:
@binwiederhier commented on GitHub (Aug 8, 2025):
Can you share your config?
My gut tells me that your configuration somehow evaluates the
$2aand$....in the bcrypt hash, or that you don't actually put a bcrypt hash in the config.@Oxidela commented on GitHub (Aug 8, 2025):
Short answer: Try leaving in the trailing equals in the basic auth header when making api requests.
Long answer:
I was running into something similar "Authentication failed" error when making calls with users with only "write-only" access to their topics.
Below solved the "Authentication failed" error when using api/fetch requests:
I found the formatting for making requests through curl/javascript from trial and error that works with the current v2.14.0:
curl -i -H 'Accept:application/json' -u '<declared username in server.yml>:<raw password>' -d "<message body>" <server>/<my_topic>With javascript fetch, the two changes was add "Accept: application/json" (prior version worked without this header), and including the trailing equals of the B64 hash:
Notes:
User/Passwords are valid when attempting to login to the web UI
bcrypt hashes were generated by "ntfy user hash" and verified by third party bcrypt hasher
api/fetch calls were working in the prior 2.13 release (i.e. B64URL encoded user:pass) and "application/json" header being omitted
@jkummerow commented on GitHub (Aug 8, 2025):
For testing purposes, I used the exact same config from the docs:
Trying to log into the web UI with some made up password, which is obviously incorrect. But given the trace
hashedSecret too shortI think there is an issue parsing the bcrypt hash.Ofc I already tested with a user and hash created with
ntfy user hashso that the entered user/password is indeed valid. Same error.@binwiederhier commented on GitHub (Aug 8, 2025):
This exact same hash works for me; the password matching this hash is "phil":
I also checked with the bcrypt online thingy and with the web app
If you join Discord, it's easier to debug back and forth.
@jkummerow commented on GitHub (Aug 9, 2025):
After some digging and testing, I found the reason.
Somehow, the $-sign in the bcrypt hash was the issue. When you double it, everything works.
'phil:$2a$10$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:admin'->'phil:$$2a$10$$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:admin'Single/double quote doesn't make a difference.
This is the config:
@binwiederhier commented on GitHub (Aug 9, 2025):
https://chatgpt.com/s/t_68971702196c8191a3b6839e9db4edd5
Oh my, that's fun. Turns out that docker compose does variable substitution, just like I initially suspected. The fact that it didn't fail at start-up is probably because
$2ais not a valid variable in docker compose, so it didn't replace that one, but only the second$....I will
Thanks for investigating.
@binwiederhier commented on GitHub (Aug 9, 2025):
Fixed in main, and in the docs. Thanks 🙏