Crivaledaz / Mattermost-LDAP

This module provides an external LDAP authentication in Mattermost for the Team Edition (free).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

http error 500 - help request

martin-lacika-artin opened this issue · comments

Hello,
I'm sorry to bother with something likely trivial. I suspect that my .env config incorrect.
I'm running a centos 7 VM with Mattermost Version: 5.25.0 and a postgresql database.
The dockerized version of Mattermost-LDAP is running right besides it.

I tried following the readme but when I click on the gitlab SSO or try linking an existing account as described,
I get stuck on the redirect where I get HTTP ERROR 500.

Mattermost runs on it's default port so I used the following uri:

# Redirect URI use by Oauth server to redirect user after authentifictaion process. Must be the same than as Mattermost give to Oauth server.
redirect_uri = "http://[hostname].[domain].lan:8065/signup/gitlab/complete"

Along this I've only generated the 32bit secret and id, changed the db password at

# Password for PostgreSQL administrator account
POSTGRES_PASSWORD = [newpass]

and

# Oauth password to connect the database
db_pass = [newpass]

Then I of course changed the default values for the LDAP config but I haven't got that far yet.

In mattermost's config.json I've used these values

"AuthEndpoint": "http://[hostname].[domain].lan/oauth/authorize.php",
"TokenEndpoint": "http://[hostname].[domain].lan/oauth/token.php",
"UserApiEndpoint": "http://[hostname].[domain].lan/oauth/resource.php"

I don't even know where to start looking so I'll appreciate any help.

You should look into your HTTP logs.

I've got the same problem.
I am using docker installation.
Ubuntu 20.04
Docker version 20.10.2, build 2291f61
docker-compose version 1.27.4, build 40524192

b4859b9c67b7   postgres:alpine   "docker-entrypoint.s…"   8 minutes ago   Up 8 minutes   5432/tcp                                   mattermost-ldap_db_1
a7435fe22014   mattermostldap    "docker-php-entrypoi…"   8 minutes ago   Up 8 minutes   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   mattermost-ldap_mattermost-ldap_1

There are some logs

docker logs --follow mattermost-ldap_mattermost-ldap_1
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.2. Set the 'ServerName' directive globally to suppress this message
[Thu Jan 14 10:20:16.472480 2021] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/8.0.1 configured -- resuming normal operations
[Thu Jan 14 10:20:16.472685 2021] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
[Thu Jan 14 10:21:19.046361 2021] [php:error] [pid 19] [client 192.168.31.1:12985] PHP Fatal error:  Uncaught PDOException: SQLSTATE[08006] [7] could not connect to server: Connection refused\n\tIs the server running on host "127.0.0.1" and accepting\n\tTCP/IP connections on port 5432? in /var/www/html/oauth/OAuth2/Storage/Pdo.php:67\nStack trace:\n#0 /var/www/html/oauth/OAuth2/Storage/Pdo.php(67): PDO->__construct()\n#1 /var/www/html/oauth/server.php(14): OAuth2\\Storage\\Pdo->__construct()\n#2 /var/www/html/oauth/authorize.php(11): require_once('...')\n#3 {main}\n  thrown in /var/www/html/oauth/OAuth2/Storage/Pdo.php on line 67
192.168.31.1 - - [14/Jan/2021:10:21:19 +0000] "GET /oauth/authorize.php?response_type=code&client_id=d82b1e92d3a000cd3f9e5020db1ad881317642dbc8848d970ac85e25e01a364b&redirect_uri=https%3A%2F%2Fmattermost.dom.com%2Fsignup%2Fgitlab%2Fcomplete&state=eyJhY3Rpb24iOiJsb2dpbiIsImlzTW9iaWxlIjoiZmFsc2UiLCJ0b2tlbiI6IjRoOGN3OW10bmVlczFzM3M0NWp4ZzF5b3pkZ21wenN4Ym1ic245NjNzdXN4ODhveHp4cGFrc2FqN2tweGNuajQifQ%3D%3D HTTP/1.1" 500 320 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"

DB log

PostgreSQL Database directory appears to contain a database; Skipping initialization

2021-01-14 10:20:15.063 UTC [1] LOG:  starting PostgreSQL 13.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.3.0) 9.3.0, 64-bit
2021-01-14 10:20:15.065 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2021-01-14 10:20:15.065 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2021-01-14 10:20:15.114 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-01-14 10:20:15.150 UTC [21] LOG:  database system was shut down at 2021-01-14 10:14:56 UTC
2021-01-14 10:20:15.271 UTC [1] LOG:  database system is ready to accept connections

I've added port section in docker compose.yaml and connected to DB manually.
At the first sight there is no problem.

                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges
-----------+----------+----------+------------+------------+-----------------------
 oauth_db  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =Tc/postgres         +
           |          |          |            |            | postgres=CTc/postgres+
           |          |          |            |            | oauth=CTc/postgres
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 |
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(4 rows)
oauth_db=# \d
                   List of relations
 Schema |           Name            |   Type   | Owner
--------+---------------------------+----------+-------
 public | oauth_access_tokens       | table    | oauth
 public | oauth_authorization_codes | table    | oauth
 public | oauth_clients             | table    | oauth
 public | oauth_refresh_tokens      | table    | oauth
 public | oauth_scopes              | table    | oauth
 public | users                     | table    | oauth
 public | users_id_seq              | sequence | oauth
(7 rows)
oauth_db=# SELECT * FROM oauth_clients;
 client_id | client_secret |                     redirect_uri                     |    grant_types     | scope | user_id
------------------------------------------------------------------+------------------------------------------------------------------+------------------------------------------------------+--------------------+-------+---------
 *** | *** | https://mattremost.dom.com/signup/gitlab/complete | authorization_code | api   |
(1 row)

After redirect I've got 500 error.
Any help will be appretiated.