api-platform / admin

A beautiful and fully-featured administration interface builder for hypermedia APIs
https://api-platform.com/docs/admin/
MIT License
480 stars 130 forks source link

Login the first time redirect to React-admin welcome page #511

Open adguernier opened 10 months ago

adguernier commented 10 months ago

API Platform version(s) affected: 3.2.2 @api-platform/admin: 3.4.4

Description
My context: I have a JWT protected API, and a protected Hydra-admin with a custom authProvider and the requireAuth set to true.

<HydraAdmin
      requireAuth
      entrypoint={window.origin}
      dataProvider={dataProvider}
      authProvider={authProvider}
/>

The first time I go to my admin app (https://localhost/admin), I'm redirected to the login page (https://localhost/admin#/login). No problem here. I log in and I'm redirected to the welcome React-admin page instead of the resources view.

How to reproduce
You can clone this repository https://github.com/adguernier/api-platform-auth-provider and follow the README.md

Possible Solution
It seems the adminDataProvider introspect() method does not check the authProvider checkAuth() method.

Additional Context
The first time the login page is render, an error occurred in the console: image

The dataProvider I've written uses the Bearer token as described in your example

An example is worth a thousand words

https://github.com/api-platform/admin/assets/7949510/153e9e78-4632-4712-80c5-540d5bdd3331

fzaninotto commented 1 month ago

@adguernier is it still a problem in API Platform admin v4?