Unable to create new users from within the admin page #125

Closed
opened 2020-06-08 16:11:38 +02:00 by yrammos · 6 comments
yrammos commented 2020-06-08 16:11:38 +02:00 (Migrated from github.com)

Describe the issue
All attempts to create a new user from the admin page produce an error ("error while adding user").

To Reproduce

  1. Log in as admin.
  2. Open the "Users" pane.
  3. Click on the "plus" button to open the new user modal.
  4. Fill out all required details for the new user; select any scope or no scope (no difference).
  5. Click OK => "Error while adding user."

Expected behavior
New user should be created.

System (please complete the following information):

  • Ubuntu 18.04
  • Any browser
  • Latest glewlwyd commit from master branch
  • Built from source using the updated (not Ubuntu-shipped) Jansson and Libmicrohttpd 0.9.70.
  • Built with default compiler options.
**Describe the issue** All attempts to create a new user from the admin page produce an error ("error while adding user"). **To Reproduce** 1. Log in as admin. 2. Open the "Users" pane. 3. Click on the "plus" button to open the new user modal. 4. Fill out all required details for the new user; select any scope or no scope (no difference). 5. Click OK => "Error while adding user." **Expected behavior** New user should be created. **System (please complete the following information):** - Ubuntu 18.04 - Any browser - Latest glewlwyd commit from master branch - Built from source using the updated (not Ubuntu-shipped) Jansson and Libmicrohttpd 0.9.70. - Built with default compiler options.
babelouest commented 2020-06-08 16:20:02 +02:00 (Migrated from github.com)

Hello @yrammos ,

This might be a bug due to a forgotten check in the UI. I found that you can select a read-only backend when you add a new user. This will be fixed soon.

If that's not the problem for your case, can you open the javascript console (press on the glewlwyd admin page), then retry to add a new user, then get the error again.

In the network tab, you should see a POST /api/user with an error, probably 400, maybe another one. Can you send the http response status and body content?

Hello @yrammos , This might be a bug due to a forgotten check in the UI. I found that you can select a read-only backend when you add a new user. This will be fixed soon. If that's not the problem for your case, can you open the javascript console (press <F12> on the glewlwyd admin page), then retry to add a new user, then get the error again. In the network tab, you should see a POST /api/user with an error, probably 400, maybe another one. Can you send the http response status and body content?
yrammos commented 2020-06-08 16:54:20 +02:00 (Migrated from github.com)

@babelouest sure enough, the POST request to /api/user produces a 500 Internal Server Error. The Apache logs do not indicate any problems (not that one would expect them to), and the Glewlwyd logs are empty.

Request data

{"username":"testuser","password":"testtesttest","name":"Test User","email":"jsbach@music.org","picture":"","scope":["login"],"enabled":true}

Request

POST /api/user/ HTTP/1.1
Content-Type: application/json; charset=utf-8
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate, br
Host: login.domain.tld
Origin: https://login.domain.tld
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.2 Safari/605.1.15
Connection: keep-alive
Referer: https://login.domain.tld/?g_continue
Content-Length: 141
Cookie: DOMAIN_SESSION_ID=5Ow6t76eerA0SNkAzPOsp8tBcLQCr1O0WDHZbX2StBXYIsRefNA5OputDla5iLnoSG0U4GvA0SCAuf3FdCxx5gUhCRo7oY4N0LVSUhqF4zqU5oHeFVUlyrPLTEHIeRQW
X-Requested-With: XMLHttpRequest

Reponse

HTTP/1.1 500 Internal Server Error
Pragma: no-cache
Access-Control-Allow-Credentials: true
Cache-Control: no-store
Access-Control-Allow-Origin: *
Date: Mon, 08 Jun 2020 14:31:25 GMT
Referrer-Policy: no-referrer-when-downgrade
Content-Length: 0
Connection: close
Server: Apache/2.4.29 (Ubuntu)
Strict-Transport-Security: max-age=15552000; includeSubDomains
@babelouest sure enough, the POST request to `/api/user` produces a 500 Internal Server Error. The Apache logs do not indicate any problems (not that one would expect them to), and the Glewlwyd logs are empty. #### Request data ``` {"username":"testuser","password":"testtesttest","name":"Test User","email":"jsbach@music.org","picture":"","scope":["login"],"enabled":true} ``` #### Request ``` POST /api/user/ HTTP/1.1 Content-Type: application/json; charset=utf-8 Accept: */* Accept-Language: en-us Accept-Encoding: gzip, deflate, br Host: login.domain.tld Origin: https://login.domain.tld User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.2 Safari/605.1.15 Connection: keep-alive Referer: https://login.domain.tld/?g_continue Content-Length: 141 Cookie: DOMAIN_SESSION_ID=5Ow6t76eerA0SNkAzPOsp8tBcLQCr1O0WDHZbX2StBXYIsRefNA5OputDla5iLnoSG0U4GvA0SCAuf3FdCxx5gUhCRo7oY4N0LVSUhqF4zqU5oHeFVUlyrPLTEHIeRQW X-Requested-With: XMLHttpRequest ``` #### Reponse ``` HTTP/1.1 500 Internal Server Error Pragma: no-cache Access-Control-Allow-Credentials: true Cache-Control: no-store Access-Control-Allow-Origin: * Date: Mon, 08 Jun 2020 14:31:25 GMT Referrer-Policy: no-referrer-when-downgrade Content-Length: 0 Connection: close Server: Apache/2.4.29 (Ubuntu) Strict-Transport-Security: max-age=15552000; includeSubDomains ```
babelouest commented 2020-06-08 17:08:39 +02:00 (Migrated from github.com)

the POST request to /api/user produces a 500 Internal Server Error. The Apache logs do not indicate any problems (not that one would expect them to), and the Glewlwyd logs are empty.

That's very weird, every error 500 sent by Gewlwyd should log at least one error message, usually more:
https://github.com/babelouest/glewlwyd/blob/master/src/webservice.c#L1506

Can you access the glewlwyd instance directly and try again to add the user, i.e. without the apache proxy in between, to make sure the problem doesn't come from the the apache proxy?

btw, what data source are you using to add the new user to? is it Database or LDAP?

> the POST request to /api/user produces a 500 Internal Server Error. The Apache logs do not indicate any problems (not that one would expect them to), and the Glewlwyd logs are empty. That's very weird, every error 500 sent by Gewlwyd should log at least one error message, usually more: https://github.com/babelouest/glewlwyd/blob/master/src/webservice.c#L1506 Can you access the glewlwyd instance directly and try again to add the user, i.e. without the apache proxy in between, to make sure the problem doesn't come from the the apache proxy? btw, what data source are you using to add the new user to? is it Database or LDAP?
yrammos commented 2020-06-08 18:07:33 +02:00 (Migrated from github.com)

Issue tracked down, I think. The log, to begin with, was set to "CONSOLE" in non-writable directory: two reasons why it wasn't produced.

The issue boils down to MySQL:

2020-06-08T16:03:07 - Glewlwyd DEBUG: Error message: "Your password does not satisfy the current policy requirements"
2020-06-08T16:03:07 - Glewlwyd DEBUG: Query: "INSERT INTO g_user (gu_username,gu_password,gu_name,gu_email,gu_enabled) VALUES ('test user',PASSWORD('testtesttest'),'test user','jsbach@music.org',1)"
2020-06-08T16:03:07 - Glewlwyd DEBUG: Hoel/h_insert - Error executing query (1)
2020-06-08T16:03:07 - Glewlwyd ERROR: user_module_add database - Error executing j_query insert
2020-06-08T16:03:07 - Glewlwyd ERROR: add_user - Error user_module_add
2020-06-08T16:03:07 - Glewlwyd ERROR: callback_glewlwyd_add_user - Error add_user

This means I should relax or remove the MySQL password policy plugin. Apologies for the false alarm, @babelouest!

Issue tracked down, I think. The log, to begin with, was set to "CONSOLE" in non-writable directory: two reasons why it wasn't produced. The issue boils down to MySQL: ``` 2020-06-08T16:03:07 - Glewlwyd DEBUG: Error message: "Your password does not satisfy the current policy requirements" 2020-06-08T16:03:07 - Glewlwyd DEBUG: Query: "INSERT INTO g_user (gu_username,gu_password,gu_name,gu_email,gu_enabled) VALUES ('test user',PASSWORD('testtesttest'),'test user','jsbach@music.org',1)" 2020-06-08T16:03:07 - Glewlwyd DEBUG: Hoel/h_insert - Error executing query (1) 2020-06-08T16:03:07 - Glewlwyd ERROR: user_module_add database - Error executing j_query insert 2020-06-08T16:03:07 - Glewlwyd ERROR: add_user - Error user_module_add 2020-06-08T16:03:07 - Glewlwyd ERROR: callback_glewlwyd_add_user - Error add_user ``` This means I should relax or remove the MySQL password policy plugin. Apologies for the false alarm, @babelouest!
babelouest commented 2020-06-08 18:24:11 +02:00 (Migrated from github.com)

I didn't know there were such a thing as MySQL password policy plugin :)

I'll close this bug when I'll push the fix related to readonly backends then, thanks.

Also, you can check the install documentation for the logs settings

I didn't know there were such a thing as `MySQL password policy plugin` :) I'll close this bug when I'll push the fix related to readonly backends then, thanks. Also, you can check the install documentation for the [logs settings](https://github.com/babelouest/glewlwyd/blob/master/docs/INSTALL.md#logs)
babelouest commented 2020-06-08 19:01:35 +02:00 (Migrated from github.com)

The readonly bug has been fixed in github.com/babelouest/glewlwyd@2001de95e8

The readonly bug has been fixed in https://github.com/babelouest/glewlwyd/commit/2001de95e81a77a68cc3c2d704a24ba661abb124
This discussion has been locked. Commenting is limited to contributors.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
KittenSquad/glewlwyd#125
No description provided.