Skip to content
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

Unable to login #9

Closed
nicofrand opened this issue Mar 28, 2020 · 9 comments
Closed

Unable to login #9

nicofrand opened this issue Mar 28, 2020 · 9 comments

Comments

@nicofrand
Copy link
Contributor

Hi,

this is similar to #5 but my config files already have 127.0.0.1 instead of localhost set.

I get a 401 response to the POST request. How can I debug that?

Thanks in advance for your help, and for your work on this package!

@nicofrand
Copy link
Contributor Author

I also tried restarting the service, did not help

@plopoyop
Copy link
Member

Hi,
I don't see any debug logs.
You can check access logs using the command : journalctl -xefu gotify
I am not sure it is going to help.
You can check there is no typo for your username / password into the config file : /opt/yunohost/gotify/config.yml
Remember, the application is not using ynh SSO.

@nicofrand
Copy link
Contributor Author

Thanks!

Here is what I found from journalctl -xefu gotify, I am afraid it is not helping much.

Mar 29 11:42:40 nicofrand.eu gotify-linux-amd64[25463]: [GIN] 2020/03/29 - 11:42:40 | 401 |  504.828088ms |       127.0.0.1 | POST     /client
Mar 29 11:42:40 nicofrand.eu gotify-linux-amd64[25463]: Error #01: you need to provide a valid access token or user credentials to access this api

I checked /opt/yunohost/gotify/config.yml and my credentials are correct indeed.
I checked the POST request in Firefox, nothing is sent in parameters so I guess the Authorization header is bearing the credentials but I don't know how to check that. Its value is Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

@nicofrand
Copy link
Contributor Author

nicofrand commented Mar 29, 2020

OK, I tried adding this token directly in the nginx config like this:

proxy_set_header Authorization "Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

and it works, so it comes from the nginx config as far as I can say. I'll try and find why the header is not passed correctly.

proxy_set_header Authorization $http_authorization;

does not work though.

@nicofrand
Copy link
Contributor Author

I tried logging the $http_authorization variable by sending it back through add_header X-debug $http_authorization always; and it is not the same as the one sent:

image

@plopoyop
Copy link
Member

The POST request contains the client name as data and basic auth headers
In firefox I right clicked on the request and copy as cURL :

curl 'https://gotify.domain.tld/client' -H 'User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3' --compressed -H 'Content-Type: application/json;charset=utf-8' -H 'Authorization: Basic TOKEN' -H 'Origin: https://gotify.domain.tld' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: https://gotify.domain.tld/' -H 'TE: Trailers' --data '{"name":"firefox 74.0.0"}'

@plopoyop
Copy link
Member

any error in firefox console ?

@nicofrand
Copy link
Contributor Author

No, nothing in Firefox.
I believe the issue is in the nginx config since it works if I set the token in hard in it.

@nicofrand
Copy link
Contributor Author

Got it, I'll open a MR.

plopoyop added a commit that referenced this issue Mar 29, 2020
Fix authorization header not passed to proxy (fix #9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants