RTC Webservices PR-5.4-dev Pending

User tests: Successful: Unsuccessful:

avatar MarcelSchuermann
MarcelSchuermann
16 Oct 2025

Pull Request for Issue #45799

Summary of Changes

Correctly handle 401 Unauthorized errors when calling a webservice API with a wrong formed token instead of throwing a CRITICAL uncaught 500 server error.

Testing Instructions

  1. Enable the "API Authentication - Token" plugin in a Joomla 5 installation.
  2. Configure a user with an API token f.e. in Postman.
  3. Make an API request using an Authorization: Bearer header, but provide a token that is deliberately malformed. For example, a token where the algorithm part is invalid (e.g., not-an-algo:123:abc...).
  4. The token can be constructed by base64 encoding a string like [ALGO]:[USER_ID]:[HMAC]. An invalid request can be triggered by using an algorithm that is not sha256 or sha512.

Actual result BEFORE applying this Pull Request

The server responds with a 500 Internal Server Error. The PHP error log shows a CRITICAL error: Uncaught Throwable of type ValueError thrown with message "hash_hmac(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm".

Expected result AFTER applying this Pull Request

throw a correct error 401 response.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • [x ] No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar MarcelSchuermann MarcelSchuermann - open - 16 Oct 2025
avatar MarcelSchuermann MarcelSchuermann - change - 16 Oct 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 16 Oct 2025
Category Front End Plugins
avatar richard67 richard67 - change - 16 Oct 2025
Title
handle 401 Unauthorized error instead of throwing CRITICAL uncaught 500 server
[5.4] Handle 401 Unauthorized error instead of throwing CRITICAL uncaught 500 server
avatar richard67 richard67 - edited - 16 Oct 2025
avatar MarcelSchuermann MarcelSchuermann - change - 16 Oct 2025
Labels Added: PR-5.4-dev
avatar alikon alikon - test_item - 18 Oct 2025 - Tested successfully
avatar alikon
alikon - comment - 18 Oct 2025

I have tested this item ✅ successfully on c7ba4f6


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46305.

avatar muhme muhme - change - 20 Oct 2025
Labels Added: Webservices
avatar muhme muhme - test_item - 21 Oct 2025 - Tested successfully
avatar muhme
muhme - comment - 21 Oct 2025

I have tested this item ✅ successfully on 69203be

Tested JBT, PHP 8.4.13

  • Correct token – HTTP status 200 OK
    TOKEN=c2hhMjU2OjE4OTo0NjFiZjIyMDE2NDM4NjFlYWIyMTIwZmU3OTM1NGU5NzJlNzM2MTJmNDZhYmRhOTRlNzZlYmQyMGE4NzU0MjMx
    curl --header "X-Joomla-Token:$TOKEN" 'http://localhost:7054/api/index.php/v1/content/articles'
  • empty token – 401 Forbidden
  • non-base64 string – 401 Forbidden
    • hello
  • wrong algo – 500 Internal Server Error
    • echo $TOKEN | base64 --decode | sed s/sha256/sha257/ | base64
  • wrong user id – 401 Forbidden
    • echo $TOKEN | base64 --decode | sed s/189/123/ | base64
  • empty HMAC – 401 Forbidden
    • echo sha256:189: | base64
  • wrong HMAC – 401 Forbidden
    • echo sha256:189:4711 | base64
  • Applied PR with Patchtester
avatar muhme muhme - change - 21 Oct 2025
Status Pending Ready to Commit
avatar muhme
muhme - comment - 21 Oct 2025

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46305.

avatar muhme muhme - change - 23 Oct 2025
Labels Added: RTC
avatar richard67 richard67 - change - 23 Oct 2025
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2025-10-23 14:45:42
Closed_By richard67
avatar richard67 richard67 - close - 23 Oct 2025
avatar richard67 richard67 - merge - 23 Oct 2025
avatar richard67
richard67 - comment - 23 Oct 2025

Thanks @MarcelSchuermann for that fix, and @alikon and @muhme for testing.

Add a Comment

Login with GitHub to post a comment