Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Notifier] Updated the NTFY notifier to run without a user parameter #53594

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

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

lostfocus
Copy link
Contributor

@lostfocus lostfocus commented Jan 20, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
License MIT

The ntfy integration of the notifier component was missing the option to run without set username.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@smnandre
Copy link
Member

Hi @lostfocus!

With your implementation, we store two exclusive ways of authorization, that cannot be used together.

The NTFY documentation makes an interesting point: the ntfy uses/accepts access token as "user-less" Basic authorization.

Alternatively, you can use Basic Auth to send the access token. When sending an empty username, the basic auth password is treated by the ntfy server as an access token. This is primarily useful to make curl calls easier, e.g. curl -u:tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2 ...:

This would be smaller to implement while beeing easier to maintain .. what do you think ?

Something similar is done in the Telegram Bridge:

private function getToken(Dsn $dsn): string
{
    if (null === $dsn->getUser() && null === $dsn->getPassword()) {
        throw new IncompleteDsnException('Missing token.', 'telegram://'.$dsn->getHost());
    }
    if (null === $dsn->getPassword()) {
        throw new IncompleteDsnException('Malformed token.', 'telegram://'.$dsn->getHost());
    }
    return sprintf('%s:%s', $dsn->getUser(), $dsn->getPassword());
}

@@ -41,6 +42,13 @@ public function getTopic(): string
return $this->topic;
}

public function setToken(?string $token): self
Copy link
Member

Choose a reason for hiding this comment

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

public function(#[\SensitiveParameter] ?string $token): self

(Probably useless as you may remove the method :) )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is #[\SensitiveParameter] already in the 6.4 branch? setPassword has it in 7.0 but not in 6.4.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry forgot you targetted 6.4.

But as i'm not sure it will be considered a bug ... you may have to target 7.1 (let's wait to see what admins say)

@lostfocus
Copy link
Contributor Author

@smnandre yeah, I was looking into that. But if we have something like NTFY_DSN=ntfy://:[:PASSWORD]@default/TOPIC we're already losing the password when parsing the string into a Symfony\Component\Notifier\Transport\Dsn in Symfony\Component\Notifier\Transport. And I didn't want to open the can of worms of fiddling around in that one, too.

@smnandre
Copy link
Member

@smnandre yeah, I was looking into that. But if we have something like NTFY_DSN=ntfy://:[:PASSWORD]@default/TOPIC we're already losing the password when parsing the string into a Symfony\Component\Notifier\Transport\Dsn in Symfony\Component\Notifier\Transport. And I didn't want to open the can of worms of fiddling around in that one, too.

I'm not sure to understand, were are you losing the password ?

i think the "unified" sugegstion would be easier to develop, passing by user:password to the Basic or Bearer header with (almost) no manipulation.

And it would be easier for users to switch from Token to user/password :)

@lostfocus
Copy link
Contributor Author

I'm not sure to understand, were are you losing the password ?

Okay, yeah, that was a brainfart. For some reason I thought parse_url couldn't handle that. I'll reshuffle things tomorrow. (And maybe (just maybe) it could even be considered a bugfix then.)

lostfocus added a commit to lostfocus/symfony that referenced this pull request Jan 21, 2024
@lostfocus lostfocus changed the title [Notifier] Added the possibility to add a bearer access token for the ntfy api [Notifier] Updated the NTFY notifier to run without a user parameter Jan 21, 2024
@nicolas-grekas
Copy link
Member

Thank you @lostfocus.

@nicolas-grekas nicolas-grekas merged commit 30810dd into symfony:6.4 Jan 29, 2024
This was referenced Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.