Page MenuHomePhabricator

🧱 Respond with a blocked user message for globally blocked users
Closed, ResolvedPublic

Description

Currently, the Wikibase REST API responds with a blocked user message only for locally blocked users. In case a user is blocked globally, a generic permission error will be returned:

{
  "error": "rest-write-denied",
  "httpCode": 403,
  "httpReason": "Forbidden"
}

To improve signalling to API users, we would like to respond with the same error message both for locally and globally blocked users:

{
  "code": "permission-denied",
  "message": "Access to resource is denied",
  "context": {
    "denial_reason": "blocked-user"
  }
}

Acceptance Criteria

  • Both locally and globally blocked users recieve the error message described above

Event Timeline

ItamarWMDE renamed this task from Respond with a blocked user for globally blocked users to Respond with a blocked user message for globally blocked users.Mon, Dec 1, 11:39 AM
ItamarWMDE renamed this task from Respond with a blocked user message for globally blocked users to 🧱 Respond with a blocked user message for globally blocked users.Mon, Dec 1, 12:41 PM
ItamarWMDE moved this task from To Do to Doing on the Wikibase Reuse Team (Sprint 58) board.

Change #1213551 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):

[mediawiki/extensions/Wikibase@master] CRUD: Improve error message for globally blocked users

https://gerrit.wikimedia.org/r/1213551

Change #1213551 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] CRUD: Improve error message for globally blocked users

https://gerrit.wikimedia.org/r/1213551

Test wiki created on Patch demo by ItamarWMDE using patch(es) linked to this task:
https://cc0837c127.catalyst.wmcloud.org/w/

Test wiki on Patch demo by ItamarWMDE using patch(es) linked to this task was deleted:

https://cc0837c127.catalyst.wmcloud.org/w/

Test wiki created on Patch demo by ItamarWMDE using patch(es) linked to this task:
https://e70b5ea7b9.catalyst.wmcloud.org/w/

Test wiki created on Patch demo by ItamarWMDE using patch(es) linked to this task:
https://e70b5ea7b9.catalyst.wmcloud.org/w/

@Ifrahkhanyaree_WMDE I created the patch demo and globally blocked the user Mallory. you can now try to log in as that user and create an Item through the api with the following snippet (thanks @Jakob_WMDE) through the dev tools console in your browser:

$.ajax({
    url: 'https://e70b5ea7b9.catalyst.wmcloud.org/w/rest.php/wikibase/v1/entities/items', 
    type: 'POST',
    contentType: 'application/json',
    data: JSON.stringify({ item: { labels: { en: 'potato' } } })
});

Happy verifying.

how do I pretend to be Mallory haha, do they have a username and password that y'all can share?

Got this as a response so we're good!

{
    "code": "permission-denied",
    "message": "Access to resource is denied",
    "context": {
        "denial_reason": "blocked-user"
    }
}

Change #1215678 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):

[mediawiki/extensions/Wikibase@master] CRUD: Remove unneeded setup step for integration test

https://gerrit.wikimedia.org/r/1215678

Change #1215678 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] CRUD: Remove unneeded setup step for integration test

https://gerrit.wikimedia.org/r/1215678