Support Basic Authentication

Created on 28 April 2025, about 1 month ago

Problem/Motivation

We use Drupal as headless system. We also want to use session_limit functionality, but when "authenticate" with basic auth, it does not seem to trigger the session_limit functionality.

Steps to reproduce

We habe "HTTP Basic Authentication" enabled - so we use Basic Auth to "trigger a login".
This is how we auth from the frontend:

async login(email, password) {
        try {
            const loginData = Buffer.from(`${email}:${password}`).toString("base64");
            const response = await fetch(this.baseUrl + `/jwt/token?_format=json`, {
                method: "GET",
                headers: {
                    "Content-Type": "application/json",
                    Authorization: `Basic ${loginData}`,
                },
            });

            if (response.ok) {
                const data = await response.json();
                this.storeUserDetails(data.token, { email });

                // Fetch additional user details
                const userDetails = await this.fetchUserDetails(data.token);
                this.storeUserDetails(data.token, userDetails); // Store all user details

                return true;
            } else {
                throw new Error("Unknown username or bad password");
            }
        } catch (e) {
            throw new Error(e.message);
        }
    }
Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇨🇭Switzerland lukas.fischer

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

Comments & Activities

Production build 0.71.5 2024