getgrav / getgrav/grav-plugin-admin
onUserLogout Event redirect is not considered
- Dominant language
- PHP
- Stars
- 377
- Forks
- 225
- Avg merge
- 11h 51m
- Merged PRs (30d)
- 4
Description
Currently a logout from admin always redirect to the baseurl of the admin (`/admin` as default).
For a site logout, there is a possibility to hook into the onUserLogout event and alter the redirect property of the `UserLoginEvent`.
This event property will be considered for the redirect after logout. See here:
https://github.com/getgrav/grav-plugin-login/blob/3.6.2/classes/Controller.php#L328-L331
We use this to call the logout callback of our auth service (keycloak).
As a _workaround_ we hook with a custom plugin into the `onTask.logout` and do the redirect there:
```php
public static function getSubscribedEvents()
{
return [
'onTask.logout' => ['onLogoutTask']
];
}
public function onLogoutTask()
{
$login = $this->grav['login'];
$login->logout(['admin' => true]);
$provider = \Grav\Plugin\Login\OAuth2\ProviderFactory::create('keycloak');
$this->grav->redirect($provider->getLogoutUrl());
}
```
Would you consider a change within the admin logout method to support the redirect property of the event as meaningful? I could provide a PR.
Contributor guide
Research direction
Start by comparing the admin logout method with grav-plugin-login/classes/Controller.php lines 328-331, which shows how the onUserLogout event's redirect property is handled for site logout. Trace the admin logout entry point and determine where that event property is discarded; done means an admin logout can honor the event-provided redirect, with any existing logout coverage updated if found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100