-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Ntfy: support auth tokens #25856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Ntfy: support auth tokens #25856
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- The
authTokenfield on theNtfystruct is currently unused after initialization; consider removing it or wiring it into behavior (e.g., for future re-auth or debugging) to avoid carrying sensitive data around unnecessarily. - When constructing the auth query parameter, you currently unconditionally
Set("auth", encoded)on the parsed URL; if users already provide anauthquery param manually, you might want to either detect and error or document/handle the precedence explicitly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `authToken` field on the `Ntfy` struct is currently unused after initialization; consider removing it or wiring it into behavior (e.g., for future re-auth or debugging) to avoid carrying sensitive data around unnecessarily.
- When constructing the auth query parameter, you currently unconditionally `Set("auth", encoded)` on the parsed URL; if users already provide an `auth` query param manually, you might want to either detect and error or document/handle the precedence explicitly.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if cc.AuthToken != "" { | ||
| bearer := "Bearer " + cc.AuthToken | ||
| encoded := base64.StdEncoding.EncodeToString([]byte(bearer)) | ||
| encoded = strings.TrimRight(encoded, "=") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be RawStdEncoding instead to omit the =?
| encoded := base64.StdEncoding.EncodeToString([]byte(bearer)) | ||
| encoded = strings.TrimRight(encoded, "=") | ||
|
|
||
| q := u.Query() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
u.Query().Get("auth") != ""
|
|
||
| cc.URI = u.String() | ||
|
|
||
| log = log.Redact(cc.AuthToken, bearer, encoded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is bearer retracted? It's nowhere used?
| # uri: smtp://<user>:<password>@<host>:<port>/?fromAddress=<from>&toAddresses=<to> | ||
| # - type: ntfy | ||
| # uri: https://<host>/<topics> | ||
| # auth_token: <auth_token> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # auth_token: <auth_token> | |
| # authtoken: <auth_token> |
| # uri: smtp://<user>:<password>@<host>:<port>/?fromAddress=<from>&toAddresses=<to> | ||
| #- type: ntfy | ||
| # uri: https://<host>/<topics> | ||
| # auth_token: <auth_token> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # auth_token: <auth_token> | |
| # authtoken: <auth_token> |
Added optional auth_token support for ntfy notifications:
once this is accepted i could make a PR for the docs