Control if Authentication is Used

Created on 25 July 2023, over 1 year ago
Updated 9 March 2024, 9 months ago

Problem/Motivation

When creating an instance of the class, specify if authentication should be used. Auth will be used by default if an authentication option is provided. (Note: This has already been implemented)

On a per method basis, it should be possible to override this in order to specify if authentication should or should not be used.

Steps to reproduce

* Create an instance of the JsonApiClient with an authentication method configured.
* All subsequent fetch requests will use this authentication method with no way to override and make an anonymous request.

Proposed resolution

* The JsonApiClient GetOptions interface should accept a new disableAuthentication option.
* If disableAuthentication is true, the fetch request should not use authentication headers (this is likely controlled by the fetch method on the base class)

Remaining tasks

* Implement changes.
* Update docs.
* Add test coverage.

API changes

* JsonApiClient GetOptions interface will accept a new disableAuthentication option.

Feature request
Status

Fixed

Component

Code

Created by

🇺🇸United States brianperry

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Pipeline finished with Skipped
    over 1 year ago
    #12680
  • Issue created by @brianperry
  • Status changed to Postponed about 1 year ago
  • 🇺🇸United States brianperry

    Marking this as postponed as we focus on the vertical slice POC.

  • Status changed to Active about 1 year ago
  • Pipeline finished with Skipped
    12 months ago
    #55441
  • 🇮🇳India pratik_kamble Pune, India

    Do we need option disable authentication for methods like Patch, Post, Delete? By default Drupal will require some authentication for these methods. Can you help understand what is expected out of this issue.

  • 🇺🇸United States brianperry

    @pratik_kamble good question. I can't imagine many cases where it would be a good idea to do this, but it is possible in the admin UI to do things like grant anonymous users permission to delete articles. In that case, would it be possible to use the DELETE method anonymously with JSON:API? If so, I think we should provide an option to disable authentication for all JavaScript methods regardless of http method used. If it is literally impossible to configure Drupal to allow JSON:API CRUD operations anonymously, then it seems like it would make sense to limit this to GET.

    Does that help clarify?

  • Assigned to brianperry
  • Merge request !46Control if Authentication is Used → (Merged) created by brianperry
  • Pipeline finished with Success
    10 months ago
    Total: 183s
    #90869
  • Pipeline finished with Success
    9 months ago
    Total: 150s
    #94349
  • Pipeline finished with Success
    9 months ago
    Total: 211s
    #94999
  • Pipeline finished with Success
    9 months ago
    Total: 149s
    #95074
  • Pipeline finished with Failed
    9 months ago
    Total: 229s
    #95271
  • Pipeline finished with Success
    9 months ago
    Total: 184s
    #95300
  • Pipeline finished with Success
    9 months ago
    Total: 148s
    #95871
  • Pipeline finished with Success
    9 months ago
    Total: 149s
    #95885
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • 🇺🇸United States brianperry

    This will conflict a bit with the changes in https://www.drupal.org/project/api_client/issues/3418939 Might be easier to merge that one first if that works out. The types there are an improvement.

  • Pipeline finished with Success
    9 months ago
    Total: 181s
    #97654
  • Pipeline finished with Success
    9 months ago
    Total: 148s
    #97664
  • Pipeline finished with Success
    9 months ago
    Total: 148s
    #97670
  • Pipeline finished with Success
    9 months ago
    Total: 148s
    #97673
  • Pipeline finished with Success
    9 months ago
    Total: 147s
    #97698
  • Pipeline finished with Success
    9 months ago
    Total: 180s
    #97699
  • Pipeline finished with Success
    9 months ago
    Total: 150s
    #97700
  • Pipeline finished with Success
    9 months ago
    Total: 151s
    #97705
  • Pipeline finished with Success
    9 months ago
    Total: 180s
    #97707
  • Status changed to Needs work 9 months ago
  • 🇺🇸United States brianperry

    Setting to needs work to integrate changes recently merged to canary.

  • Pipeline finished with Success
    9 months ago
    Total: 149s
    #98702
  • Pipeline finished with Success
    9 months ago
    Total: 181s
    #98712
  • Status changed to Needs review 9 months ago
  • Pipeline finished with Success
    9 months ago
    Total: 155s
    #98798
  • Pipeline finished with Success
    9 months ago
    Total: 183s
    #98805
  • Status changed to RTBC 9 months ago
  • 🇺🇸United States brianperry

    Let's hold off on merging this one for now. Being able to stage a few releases will make it easier to test our publishing workflow.

  • Pipeline finished with Running
    9 months ago
    #100058
  • Pipeline finished with Success
    9 months ago
    Total: 276s
    #103066
  • Status changed to Fixed 9 months ago
  • 🇺🇸United States brianperry

    Merging now that we have automation in place.

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

  • Pipeline finished with Skipped
    8 months ago
    #121750
  • Pipeline finished with Failed
    8 months ago
    Total: 161s
    #124407
  • Pipeline finished with Failed
    8 months ago
    Total: 273s
    #124431
  • Pipeline finished with Failed
    8 months ago
    #124444
  • Pipeline finished with Success
    8 months ago
    Total: 163s
    #125452
  • Pipeline finished with Failed
    8 months ago
    Total: 149s
    #126247
  • Pipeline finished with Failed
    8 months ago
    Total: 237s
    #127448
  • Pipeline finished with Success
    8 months ago
    Total: 39s
    #131684
  • Pipeline finished with Success
    8 months ago
    Total: 40s
    #132018
  • Pipeline finished with Success
    8 months ago
    Total: 40s
    #132812
  • Pipeline finished with Success
    8 months ago
    Total: 40s
    #132815
  • Pipeline finished with Success
    8 months ago
    Total: 40s
    #132920
  • Pipeline finished with Success
    8 months ago
    Total: 200s
    #134542
  • Pipeline finished with Failed
    8 months ago
    Total: 322s
    #134553
  • Pipeline finished with Failed
    8 months ago
    Total: 523s
    #134566
  • Pipeline finished with Success
    8 months ago
    Total: 172s
    #134574
  • Pipeline finished with Success
    8 months ago
    Total: 40s
    #134671
Production build 0.71.5 2024