概要
以下の記事を参考に、JWT認証を試してみます。
JWT Authentication
The Drupal API Authentication module works by sending a JWT token along with your API requests for authentication. This module uses JSON Web Token (JWT), an open standard for securely representing user identity during two-party interactions. In this step, essentially, a username and password of your Drupal site are used to first get a JWT token. Once the username and password are verified, the Drupal REST API Authentication module will create a signed JSON Web Token. Then, the API will return that token back to the client application.
ただ試してみた結果、JWT認証を行うには、有料プランに加入する必要がありそうで、そこで調査が止まりました。
前提条件: ダウンロードとインストール
以下の2つのモジュールをインストールして有効化します。
REST & JSON API Authentication for Drupal
Drupal API Authentication module restricts and secures unauthorized access to your Drupal site APIs using different authentication methods. The module supports authentication for all REST, JSON, GraphQL, and custom APIs
REST UI
A user interface for configuring Drupal REST module.
composer.phar require 'drupal/rest_api_authentication:^2.0'
composer.phar require 'drupal/restui:^1.21'
vendor/bin/drush en rest_api_authentication
JWT ベースの API 認証を構成する手順
以下の説明に従って、APIを有効化して、JWTベースのAPI認証をセットアップします。
JWT Authentication
The Drupal API Authentication module works by sending a JWT token along with your API requests for authentication. This module uses JSON Web Token (JWT), an open standard for securely representing user identity during two-party interactions. In this step, essentially, a username and password of your Drupal site are used to first get a JWT token. Once the username and password are verified, the Drupal REST API Authentication module will create a signed JSON Web Token. Then, the API will return that token back to the client application.
しかし、メソッドを選択する場面で、以下に示すように、JWTを選択するには、プレミアムという有料プランに加入する必要がありそうでした。

まとめ
現在調査中のため、情報が不正確かもしれませんが、JWT認証を行うモジュールとして、以下があるようです。
JSON Web Token Authentication (JWT)
The JSON Web Token (JWT) Authentication module provides a Drupal authentication provider that uses JWTs as the primary factor of authentication. What is a JSON Web Token?
また、OAuth2を使用するモジュールとして、以下があるようです。
Simple OAuth (OAuth2) & OpenID Connect
Simple OAuth is an implementation of the OAuth 2.0 Authorization Framework RFC.
次は、上記の2つのモジュールの使用方法について調査します。
動画版(生成AIによる自動生成): この記事の内容をずんだもん×四国めたんの掛け合いで解説しています。自動生成のため、内容に誤りがある可能性があります。正確な情報は記事本文をご参照ください。



コメント
…