Problem/Motivation

Suggested in a UX meeting:

A simple status report message about JSON:API's access being enabled, especially when write access is enabled. This was requested by a couple UX team members who audit the site status reports for many sites.

Proposed resolution

Add status report entry, with language closely matching that at /admin/config/services/jsonapi as added by #3039568: Add a read-only mode to JSON:API and reviewed in detail there.

Remaining tasks

Review

User interface changes

Before
After (with read-only mode OFF)
status report with full CRUD mode
After (with read-only mode ON)
Status report with read-only mode

API changes

None.

Data model changes

None.

Release notes snippet

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

If we do #3039687: Add an API read-only mode to Drupal core, then this would need to be moved along.

Wim Leers’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.08 KB
127.51 KB
170.08 KB
Wim Leers’s picture

Issue summary: View changes
FileSize
166.93 KB
shimpy’s picture

The patch is working perfectly. Thanks

Wim Leers’s picture

@shimpy Why did you post screenshots? I already provided screenshots…

Gnanasampandan Velmurgan’s picture

Status: Needs review » Needs work

#3 patch

Wim Leers’s picture

Status: Needs work » Needs review

???!

Please don't mark issues Needs work without saying anything at all, @Gnanasampandan Velmurgan.

Gnanasampandan Velmurgan’s picture

Site administrators easily configured both read and all Json api operations . Also I have reviewed and tested. #3patch worked for me.

gabesullice’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Looks good, Wim. Thanks!

xjm’s picture

I think this is reusing text from our previous UX reviews when we were working to add the module to core. Can someone confirm? If so we don't need UX review a second time.

Wim Leers’s picture

Almost.

/admin/config/services/jsonapi contains the following text:

Warning: Only enable all operations if the site requires it. <a href=":docs">Learn more about securing your site with JSON:API.</a>

This patch is using the text:

It is recommended to only enable all operations if the site requires it. <a href=":docs">Learn more about securing your site with JSON:API.</a>

The intent was indeed to make these strings as similar as possible.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/jsonapi/jsonapi.install
@@ -58,7 +58,14 @@ function jsonapi_requirements($phase) {
+      'description' => t('It is recommended to only enable all operations if the site requires it. <a href=":docs">Learn more about securing your site with JSON:API.</a>', [
+        ':docs' => 'https://www.drupal.org/docs/8/modules/jsonapi/security-considerations'
+      ]),

One possible UX concern for me is that unlike the field on the form you don't know if the description applies to your current setting on not. If you have it set to "Read only operations" you are not able see that the other possibility is "All operations..." but you'll set the description. I think we should only display the description if we're not in read only mode. Also I think that maybe the description probably should also contain a link to the config page where the user can change this. Otherwise the user has to navigate a tortuous route via d.o if they think "oh I'd like to change this".

Wim Leers’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
133.63 KB
1.93 KB
1.34 KB

Great observations, thanks! Done. ✅

gabesullice’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Nice change.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/jsonapi/jsonapi.install
@@ -58,7 +60,17 @@ function jsonapi_requirements($phase) {
+        'value' => t('All operations (create, read, update, delete) are allowed'),

Supernitpick: I think this is missing a final period, since it's a sentence rather than a single phrase/label.

Also, saving issue credit.

shimpy’s picture

Status: Needs work » Needs review
FileSize
981 bytes
1.23 KB

#16 I have rebuild the phrase.

Wim Leers’s picture

Status: Needs review » Needs work

@shimpy Why did you change the wording much more significantly than @xjm asked for? Please just add the trailing period 🙂

shimpy’s picture

@Wim Leers
I changed the phrase because as @xjm mentioned in#16 it is a sentence not a label or phrase so we require final period after that.

As per my understanding, if we will mention like below then no trailing period is required as itself completes the label and will maintain symmetry with other JSON API labels

+ 'value' => t('Allows all (create, read, update, delete)operations')

Please check. I might be wrong as well

shimpy’s picture

Status: Needs work » Needs review

Review

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
1.06 KB
1.34 KB

AFAICT this is what she meant :)

shimpy’s picture

FileSize
73.81 KB

Sorry @Wim leers
I think I am misleading you. What I meant is if we put period in sentence then it will not act as label and will loose its symmetry with other labels. Attaching screenshot for reference. This was what I meant. May be I am not understanding the concern.

alexpott’s picture

@shimpy is correct the value part of a requirement shouldn't have a full stop - see screenshot of existing sentence in a value...

Screenshot of requirement showing no fullstop on value value

Re-uploading #14 as that's the correct patch as far as I can see.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
91.92 KB

Lol... context... so the Drupal core update status warning does not have a full stop but the experimental module warning does ... /shrug we are inconsistent. But the fullstop is much rarer. See screenshot:

Screenshot showing value both with and without a fullstop

I think there's a better way. One sec and I'll post a patch.

alexpott’s picture

Title: Follow-up for #3039568: add status report message about JSON:API's read-only mode » Add status report message about JSON:API's read-only mode
Issue summary: View changes
Status: Needs work » Needs review
FileSize
159.32 KB
55.77 KB
1.83 KB
1.31 KB

I think the attached patch is more inline with what value is expected to be. It also means that if you change to read-only the information is still there and hasn't suddenly gone missing.

I've updated the screenshots in the issue summary.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

/shrug we are inconsistent

This is why I was quietly complying without complaining 😇

This works for me too.

shimpy’s picture

@alexpott and @wim leers #25 seems more consistent. Works for me as well.

  • webchick committed 1c299c6 on 8.8.x
    Issue #3068275 by Wim Leers, alexpott, shimpy, gabesullice, xjm: Add...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesomesauce!

Committed and pushed to 8.8.x. Thanks!

Wim and I debated backporting this to 8.7.x (it cherry-picks cleanly), since it's a security improvement, but also a string addition. Thoughts?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

shimpy’s picture