Skip to content

Conversation

@griefie
Copy link
Contributor

@griefie griefie commented Dec 6, 2025

Added optional auth_token support for ntfy notifications:

  • the ntfy messenger now accepts an auth token in the config, encodes it as the ntfy auth query parameter, and redacts it from logs so private ntfy servers can be used securely.
  • Config templates (evcc.dist.yaml, assets/js/components/Config/defaultYaml/messaging.yaml) were extended to include the new authToken field

once this is accepted i could make a PR for the docs

@andig andig added enhancement New feature or request needs documentation Triggers issue creation in evcc-io/docs labels Dec 6, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@griefie griefie changed the title Handle an optional authToken parameter for ntfy messaging Messaging: Handle an optional authToken parameter for ntfy messaging Dec 6, 2025
@github-actions github-actions bot added the stale Outdated and ready to close label Dec 13, 2025
if cc.AuthToken != "" {
bearer := "Bearer " + cc.AuthToken
encoded := base64.StdEncoding.EncodeToString([]byte(bearer))
encoded = strings.TrimRight(encoded, "=")
Copy link
Member

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()
Copy link
Member

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)
Copy link
Member

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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# auth_token: <auth_token>
# authtoken: <auth_token>

@andig andig changed the title Messaging: Handle an optional authToken parameter for ntfy messaging Ntfy: support auth tokens Dec 14, 2025
@github-actions github-actions bot removed the stale Outdated and ready to close label Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs documentation Triggers issue creation in evcc-io/docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants