RFC (Request For Comment): User-configurable authentication (add cookie + jwt_auth)

Created on 9 June 2022, over 3 years ago
Updated 17 September 2024, about 1 year ago

Problem/Motivation

In jsonrpc.routing.yml, this module allows only "basic_auth" and "oauth2" authentication. Cookie authentication is disabled. JWT auth is not available.

However, the JSON RPC 2.0 specification does not stipulate anything about the authentication method, and Drupal's JSON:API supports cookie-based authentication. In addition, JWT is a popular auth method for decoupled sites and should be supported.

Proposed resolution

Enable cookie-based and JWT authentication as user-configurable options.

Users should be able to select any combination of basic_auth, cookie, jwt_auth, and oauth2. Cookie auth should require a CSRF token.

Help test!

Try this out and let me know how it works by commenting on this issue.

MR 40 is for JSON-RPC 2.x (which is probably what you're using), and MR 30 is for JSON-RPC 3.x.

Original issue

I downloaded this module today and I attempted to create an endpoint for cancelling the logged-in user's account.

I am using partially decoupled Drupal with a Drupal frontend and Ionic iOS/Android mobile apps. To keep things simple, they all use cookie authentication.

So I created an account cancellation endpoint and attempted to cancel the account via RPC from my Ionic app, but I am getting the following error:

Path: /jsonrpc. Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: The used authentication method is not allowed on this route. in Drupal\Core\EventSubscriber\AuthenticationSubscriber->onExceptionAccessDenied() (line 135 of /app/web/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php).

Based on this error, and I am assuming that cookies can't be used for authentication with this module at the moment, and instead I need to use something like JWT. Could you please confirm if my understanding is correct?

Also, is there some way to override this restriction and use the module with cookie auth anyway?

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡―πŸ‡΅Japan ptmkenny

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024