mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 14:53:00 +03:00
🚀 Feature: Add ability to create log files #231
Reference in New Issue
Block a user
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 @gtensolr on GitHub.
Feature description
The proposed feature if for Pocket ID to generate log files, so they could be parsed by other tools. It would be important to have the option of
log level,file_locationandformat. This could be set on environmental variables or even within the GUIPitch
On several containers that are related to Authentication, they can be configured to generate log files, that can be parsed by tools such as Fail2ban and Crowdsec. Although the attack vector for Pocket ID is quite small, there's still a possibility for a malicious actor to attempt to brute force the
Login Code. Even if there are no codes configured (thus no real attack vector), it's an important source of info for firewall and blocking malicious IPs.@ItalyPaleAle commented on GitHub:
I agree that we should look into logs, and ideally implement structured logging (with log/slog which is now in the standard library).
I do not support the idea of implementing direct log-to-file. Pocket ID is meant to run as a container, and the more we can keep the app stateless, the better. The orchestrator (Docker or whatnot) can get the logs from stdout and redirect them to a file as needed, and will also take care of rotating log files, compressing them, and/or forwarding them to some other service.
However, once we do switch to structured logs, it'd be great if we could also support OTel for logs. We already have OTel for traces and metrics, and adding logs would complete the picture. That should allow forwarding logs too any receiver.
@rossdargan commented on GitHub:
I've installed it on proxmox in an LXC so log-to-file for crowdsec would be really helpful.
@gtensolr commented on GitHub:
Hi @kmendell
I think that this can potentially work, but it would be a convoluted process. I would need to have an utility that can, both receive the logs from docker and export that as a log file.
What I tried and worked with success was to replace the built in Caddy with my prior nginx instance, which in turn, generate a lot of detailed “access” logs that I was able to parse.
@kmendell commented on GitHub:
You Can export the logs from docker it self using the logging section:
This would send all of that to your log server of choice.
Would that work for your use case?
@stonith404 commented on GitHub:
Like I explained in this comment brute force attacks are practically impossible due to the rate limiting.
Nevertheless, I think file-based logging makes sense. I don't have much experience with the logger of Go so I wouldn't prioritize this issue but if someone wants to create a PR, feel free :)
@ItalyPaleAle commented on GitHub:
Yup, that's why I'm saying - it wouldn't be possible within a docker container since there's only 1 process.
Inside the LXC container, you probably have a process manager of sort that's running pocket-id, right? (Systemd or something else) that may allow you to pipe logs to some other file
@ItalyPaleAle commented on GitHub:
@rossdargan if you're running inside LXC, isn't there a way to redirect stdout to a file?
@rossdargan commented on GitHub:
I'm using pangolin but hopefully that will work. I think the biggest issue was most were 400 - but I'd love to see what you used!
I don't think so - it's not like docker where you have a single "app" running, but I might be wrong!
@stonith404 commented on GitHub:
Since Pocket ID now runs in a single process it should be pretty easy to redirect stdout to a file as @ItalyPaleAle mentioned. Additionally @ItalyPaleAle has added support for sending logs to a collector like OTEL.
Because of that I'm closing this issue.
@gtensolr commented on GitHub:
@rossdargan
I was able to get Crowdsec to parse the nginx logs for failed auths from Pocket-ID and created a scenario that can ban the IPs. If you have nginx, I can share that