Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Notifier] Fixed authorization problems#58088

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
jirikmik wants to merge3 commits intosymfony:7.3fromjirikmik:7.2

Conversation

@jirikmik
Copy link

@jirikmikjirikmik commentedAug 26, 2024
edited by xabbuh
Loading

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#58085
LicenseMIT

Fixed creating authorization header for username and password auth and added DSN example for token auth to README.

@carsonbot
Copy link

Hey!

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

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 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

@carsonbot

This comment was marked as resolved.

@jirikmikjirikmik changed the base branch from7.2 to7.1August 26, 2024 07:18
@xabbuhxabbuh changed the base branch from7.1 to7.2August 26, 2024 07:34
@carsonbotcarsonbot changed the titleFixed authorization problems[Notifier] Fixed authorization problemsAug 26, 2024
@xabbuhxabbuh removed this from the7.2 milestoneAug 26, 2024
@xabbuhxabbuh added this to the6.4 milestoneAug 26, 2024

if (null !==$this->user &&null !==$this->password) {
$headers['Authorization'] ='Basic'.rtrim(base64_encode($this->user.':'.$this->password),'=');
$headers['Authorization'] ='Basic'.base64_encode($this->user.':'.$this->password);
Copy link
Member

Choose a reason for hiding this comment

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

@mikaelkael Would be great if you could have a look here as you contributed the initial code in#50131.

Copy link
Contributor

Choose a reason for hiding this comment

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

@xabbuh: as explain herehttps://docs.ntfy.sh/publish/#username-password, you don't have final sign equal and this modification breaks associated testhttps://github.com/symfony/symfony/actions/runs/10555314977/job/29238683518#step:8:1929. As all tests use mocks without direct access to a ntfy server, perhaps your modification is possible but you need to also change tests to be compliant

Copy link
Author

Choose a reason for hiding this comment

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

@xabbuh: as explain herehttps://docs.ntfy.sh/publish/#username-password, you don't have final sign equal and this modification breaks associated testhttps://github.com/symfony/symfony/actions/runs/10555314977/job/29238683518#step:8:1929. As all tests use mocks without direct access to a ntfy server, perhaps your modification is possible but you need to also change tests to be compliant

Suggested page not explain you don't have final equal sign. But in case you encodetestuser:fakepassword string from Ntfy docs base64 output is without equal sign(s).

Doing tests is totally out of my scope. I just only wanted report bug I have found. Somebody asks me for PR, I did ... sorry :-(

Copy link
Contributor

Choose a reason for hiding this comment

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

The fix looks correct to me, as Base64 encoded strings do not always end with an = character. The = character is used as padding to ensure that the length of the encoded string is a multiple of 4 characters, which is required by the Base64 encoding standard.

So yes, the tests should be adjusted

https://3v4l.org/BHa9R

Copy link
Contributor

@mikaelkaelmikaelkaelAug 26, 2024
edited
Loading

Choose a reason for hiding this comment

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

@jirikmik: you have the mention of no equal sign inhttps://docs.ntfy.sh/publish/#query-param, specifically for query param and as@OskarStark said, the case of the doc 'testuser:fakepassword' doesn't need padding. I will try to reproduce#58085 with a real server (not mocked)

xabbuh reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah it is:
image

Copy link
Author

Choose a reason for hiding this comment

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

I think screenshot from Ntfy.sh docs is related to "query param" auth, not Basic auth ...

derrabus reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

In none of the example in the doc, we can find padding equal (for any langage, not only PHP) but it's not a valid reason. During my dev, it didn't made problem. There is perhaps a change with recent version of ntfy. The only way is to have a reproductible test case. As I know in symfony, we didn't depend on external service in test. So I will try to write a failing test case in myhttps://github.com/mikaelkael/ntfy-notifier (the repository on which I work before integration in symfony).

OskarStark reacted with rocket emoji
Copy link
Member

Choose a reason for hiding this comment

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

If I read the linked documentation correctly, stripping the trailing= characters is documented for authenticating via the query parameter,but not for basic auth. This means the proposed change is correct.

OskarStark and jirikmik reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

I was able to reproduce the bugmikaelkael/ntfy-notifier@a9e19dd, I confirm that the correction is good and the only thing to change in test is:mikaelkael/ntfy-notifier@a9e19dd#diff-cfb9cdd160d285443c2bf73a6307b616ce74d3431a19d887ad290425606d2471L114

OskarStark reacted with rocket emoji

DSN example
-----------

Choose a reason for hiding this comment

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

let's keep this blank line

```
where:
-`URL` is the ntfy server which you are using
- if`default` is provided, this will default to the public ntfy server hosted on[ntfy.sh](https://ntfy.sh/).

Choose a reason for hiding this comment

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

Looking at README in other bridges, the example DSN uses@default directly. I think it'd be better to follow their lead as using something non-default is going to be the exception.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I understand. But text is talking aboutURL which is not in example DSN. With self-hosted Ntfy isdefault unclear

}

$options =$opts?$opts->toArray() : [];
$json_options =$opts?$opts->toArray() : [];
Copy link
Member

@fabpotfabpotAug 27, 2024
edited
Loading

Choose a reason for hiding this comment

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

Suggested change
$json_options =$opts?$opts->toArray() : [];
$jsonOptions =$opts?$opts->toArray() : [];

}

$headers = [];
$client_options = ['json' =>$json_options];
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
$client_options = ['json' =>$json_options];
$clientOptions = ['json' =>$json_options];

@OskarStark
Copy link
Contributor

Any plans to finish this PR@jirikmik ?

```
NTFY_DSN=ntfy://[USER:PASSWORD]@default[:PORT]/TOPIC?[secureHttp=[on]]
NTFY_DSN=ntfy://URL[:PORT]/TOPIC?[secureHttp=[on]]
```
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a whiteline after and before each code delimiter line?

@fabpot
Copy link
Member

Closing as there are no more activities. Feel free to reopen when you have time or if someone wants to take over.

@fabpotfabpot closed thisJan 5, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot requested changes

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@OskarStarkOskarStarkOskarStark left review comments

@derrabusderrabusderrabus left review comments

@xabbuhxabbuhxabbuh left review comments

+1 more reviewer

@mikaelkaelmikaelkaelmikaelkael left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

Ntfy Notifier - authorization

8 participants

@jirikmik@carsonbot@OskarStark@fabpot@mikaelkael@nicolas-grekas@derrabus@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp