1

I wondering if it’s possible to use the SPA login(from Vue) using Laravel Sanctum to also authorise for Laravel Horizon?

I’ve done much googling and can’t find an answer to this. So far I’ve just had to make do with creating a custom middleware for Horizon that uses Auth.basic, which isn’t as user friendly as it would be to login via Sanctum and use the abilities to determine who can view Horizon dashboard.

Thank you.

1 Answer 1

3

According to this GitHub Issue Comment: https://github.com/laravel/horizon/issues/65#issuecomment-412128134

Author: @francislavoie

So this is kinda hilarious. I found out that Horizon has an undocumented feature to solve this.

https://github.com/laravel/horizon/blob/1.0/src/HorizonServiceProvider.php#L54

Horizon does try to grab its list of middlewares from config. This isn't documented anywhere unfortunately.

You can simply add 'middleware' => ['web', 'auth'], to your config/horizon.php.

So in my case, this became:

'middleware' => ['web','assign.guard:web','auth:sanctum'],

assign.guard is my own middleware because I have multiple auth guards going on.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.