Problem saving info to external_services_logs table

Bug #1826940 reported by Robert Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Robert Lyon
19.04
Fix Released
Medium
Unassigned
19.10
Fix Released
Medium
Robert Lyon

Bug Description

The 'auth' column is only 10 chars (as it expects one of OTHER, OAUTH, TOKEN, TOKEN_USER, USER) and fails when it tries to save the wstoken value string instead:

[DBG] bb (webservice/lib.php:1512) executing: mahara_user_external/update_users
[WAR] bb (lib/errors.php:858) Failed to get a recordset: postgres8 error: [-1: ERROR: value too long for type character varying(10)] in EXECUTE("INSERT INTO "external_services_logs" ("id", "timelogged", "userid", "externalserviceid", "institution", "protocol", "auth", "functionname", "timetaken", "uri", "info", "ip") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")Command was: INSERT INTO "external_services_logs" ("id", "timelogged", "userid", "externalserviceid", "institution", "protocol", "auth", "functionname", "timetaken", "uri", "info", "ip") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and values was (id:16877,timelogged:1556571027,userid:8,externalserviceid:3,institution:wdhb,protocol:REST,auth:1234a2fcc061b24432191a1295958600,functionname:mahara_user_update_users,timetaken:0.26598191261292,uri:/webservice/rest/server.php?wstoken=1234a2fcc061b24432191a1295958600,info:exception:WebserviceInvalidParameterExceptionmessage:Invalidparametervaluedetected;executioncannotcontinue.:update_users|in...
 Call stack (most recent first):
   * insert_record(string(size 22), object(stdClass), string(size 2), true) at /XXXX/webservice/lib.php:1441
   * webservice_base_server->exception_handler(object(WebserviceInvalidParameterException)) at Unknown:

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/9907

Revision history for this message
Robert Lyon (robertl-9) wrote :

Ok it looks like the problem is based around this:

In webservice_base_server::run() there is the following:

        // init all properties from the request data
        $this->parse_request();

        // authenticate user, this has to be done after the request parsing
        // this also sets up $USER and $SESSION
        $this->authenticate_user();

The authenticate_user() method sets $this->auth to be a string like 'TOKEN'

But there is also the webservice_rest_client that set an 'auth' variable for it's own use

So if using REST auth and the parse_request() fails then we have the wrong $this->auth value set by the looks of things

Robert Lyon (robertl-9)
Changed in mahara:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Robert Lyon (robertl-9)
milestone: none → 19.04.1
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/9907
Committed: https://git.mahara.org/mahara/mahara/commit/31fbdf0b99896508ddab8b5e35821c31f056402b
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 31fbdf0b99896508ddab8b5e35821c31f056402b
Author: Robert Lyon <email address hidden>
Date: Tue Apr 30 09:48:12 2019 +1200

Bug 1826940: Allow saving to external services log a valid auth value

@TODO: Find out why it's trying to save the wstoken authentication token rather
than the value 'TOKEN'

behatnotneeded

Change-Id: Iecad50d41ef439b195ebf4ecd22e486092e4593e
Signed-off-by: Robert Lyon <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "19.04_STABLE" branch: https://reviews.mahara.org/10165

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/10165
Committed: https://git.mahara.org/mahara/mahara/commit/9f004185b193559986919cdc1664ee8ebb1f31e3
Submitter: Robert Lyon (<email address hidden>)
Branch: 19.04_STABLE

commit 9f004185b193559986919cdc1664ee8ebb1f31e3
Author: Robert Lyon <email address hidden>
Date: Tue Apr 30 09:48:12 2019 +1200

Bug 1826940: Allow saving to external services log a valid auth value

@TODO: Find out why it's trying to save the wstoken authentication token rather
than the value 'TOKEN'

behatnotneeded

Change-Id: Iecad50d41ef439b195ebf4ecd22e486092e4593e
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit 31fbdf0b99896508ddab8b5e35821c31f056402b)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.