Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow modification of sanctum permissions in tenantMiddleware() #346

Open
eelco2k opened this issue Mar 13, 2024 · 0 comments
Open

allow modification of sanctum permissions in tenantMiddleware() #346

eelco2k opened this issue Mar 13, 2024 · 0 comments

Comments

@eelco2k
Copy link

eelco2k commented Mar 13, 2024

At this moment you can only set the sanctum permissions on plugin initialization (by my knowledge).

In my case i have some middlewares for each tenant and there the abilities change of the users.

Is there any other way of setting the abilities later on? now i've done it like this in my tenantMiddleware() of a panel:

function array_values_recursive(array $array): array
{
    $flat = array();

    foreach ($array as $value) {
        if (is_array($value)) {
            $flat = array_merge($flat, array_values_recursive($value));
        } else {
            $flat[] = $value;
        }
    }
    return $flat;
}

$apiplugin = Filament::getCurrentPanel()->getPlugin('api-service');   // https://filamentphp.com/plugins/rupadana-api-service
$abilities = $apiplugin->getAbilities(Filament::getCurrentPanel()); // gets all resources with their abilities

$abilities = array_values_recursive($abilities);

$breezyplugin = Filament::getCurrentPanel()->getPlugin('filament-breezy');
$breezyplugin->enableSanctumTokens(true, $abilities);      

so getting the plugin and then enableSanctumTokens() function...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant