gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
https://gotify.net
Other
10.43k stars 593 forks source link

Unable to Login with default credentials #640

Closed SanaRinomi closed 3 months ago

SanaRinomi commented 3 months ago

Can the issue be reproduced with the latest available release? (y/n) y

Which one is the environment gotify server is running in?

version: "3.8"
services:
  gotify:
    image: gotify/server-arm64
    restart: unless-stopped
    networks:
      database:
        ipv4_address: 172.30.0.20
      external:
        ipv4_address: 172.20.0.22
    environment:
      - GOTIFY_DATABASE_CONNECTION=host=[censor] port=5432 user=gotify
        sslmode=disable dbname=gotify password=[censor]
      - GOTIFY_SERVER_SSL_ENABLED=false
      - GOTIFY_DATABASE_DIALECT=postgres
      - GOTIFY_DEFAULTUSER_NAME=sana
      - GOTIFY_DEFAULTUSER_PASS=rinomi
networks:
  database:
    external: true
  external:
    external: true

Do you have an reverse proxy installed in front of gotify server? (Please select None if the problem can be reproduced without the presense of a reverse proxy)

server {
        listen 80;
        listen [::]:80;

        root [censor];

        server_name *.sanarinomi.com sanarinomi.com;

        return 301 https://$host$request_uri;
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;

        root [censor];

        server_name *.sanarinomi.com sanarinomi.com;

        ssl_certificate [censor];
        ssl_certificate_key [censor];
        include /etc/nginx/snippets/ssl-params.conf;

        location / {
                proxy_set_header   Upgrade $http_upgrade;
                proxy_set_header   Connection "upgrade";

                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto http;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header Host $http_host;
                proxy_redirect     http:// $scheme://;

                proxy_pass http://[censor]:8080;
                proxy_http_version 1.1;

                proxy_connect_timeout   1m;
                proxy_send_timeout      1m;
                proxy_read_timeout      1m;
        }

        location = /nginx-health {
            access_log off;
            add_header 'Content-Type' 'application/json';
            return 200 '{"status":"UP"}';
        }
}

On which client do you experience problems? (Select as many as you can see)

What did you do? Attempt to login using default credentials

What did you expect to see? Login successful

What did you see instead? (Include screenshots, android logcat/request dumps if possible) image

Despite proper database entry, and even trying different combinations of user and password

image

jmattheis commented 3 months ago

Try deleting all users and let gotify recreate them. Gotify only uses GOTIFY_DEFAULTUSER_PASS on first start, if it was changed afterwards it won't have an effect.

SanaRinomi commented 3 months ago

Same result:

image image

jmattheis commented 3 months ago

The 403 error is related to CORS. Do you have use another proxy besides nginx? I can reproduce the issue when I remove the line: proxy_set_header Host $http_host;.

So the issue is that the Host header isn't properly forwarded. You can either try find out why the nginx setting doesn't work propertly or configure your host as allowed origin like this:

    gotify:
        image: gotify/server:2.4.0
        environment:
          - GOTIFY_SERVER_CORS_ALLOWORIGINS=[example.org]
          - GOTIFY_SERVER_STREAM_ALLOWEDORIGINS=[example.org]
SanaRinomi commented 3 months ago

Ok, setting the CORS to the subdomain I want to run this on worked like a charm! Thank you so much for the help!

EDIT: Just for clarification, the proxy_set_header Host was being set to my specific subdomain, so upon adding that to the CORS, it worked a charm.