Member Since 1 Year Ago
2,930 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
Earned once your experience points ranks in the top 10 of all Laracasts users.
Replied to Problem With Sanctum Middleware
I stripped everything out of the routes so that my web route just has one entry
Route::middleware('auth:sanctum')->post('ponocms/app', '[email protected]');
I tried hitting that route like this with an invalid bearer token
$ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Authorization: Bearer IujhOVrfBnwz1fdaywtGJN5TXXkcxLb3Ou8Yd9HO', )); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, 'https://ponocms.com/ponocms/app'); $txtRes = curl_exec($ch); curl_close($ch); dd($txtRes);
But it's still letting me right through to the MobileappController. The bearer token is not valid, the user is also signed out of the website. I added some logging to the App\Http\Middleware\Authenticate middleware and I see that each request that comes in to the 'ponocms/app' route is hitting that. I'm not sure if that is intended or not?
I'm totally stuck, I read the Laravel docs from top to bottom, I tried using the api routes, I tried changing the config/sanctum file but I just can't get the Sanctum middleware to kick in. Thanks for any help you can give!
Replied to Problem With Sanctum Middleware
Thanks for your quick reply @martinbean
If I add the auth:sanctum middleware should it still be hitting the Authenticate middleware? My understanding is that it shouldn't, but maybe I'm misunderstand and the incoming request still goes through the Authenticate middleware?
But even after it passes this it should continue to Laravel\Sanctum\Guard. And it's not hitting that at all, I added info('log this') commands to the __construct and __invoke functions and it doesn't appear to be calling them. So unless I'm misunderstanding it looks as though it's not going through the Sanctum authorization?
Thanks again for your help :)
Started a new Conversation Problem With Sanctum Middleware
I've set up Sanctum to use with a mobile app. The first step (getting a token) is working fine, but the second step (passing the token as a bearer token and protecting routes via auth:sanctum middleware) is not.
Here's what the route looks like:
Route::middleware('auth:sanctum')->post('pono/app', '[email protected]');
When I hit the pono/app route it's loading the regular Authenticate middleware but it's letting everyone through, it's not checking for the bearer token. So if I change the route from post to get I'm able to just open it in the browser, Sanctum is not protecting it.
Really I need Sanctum to ignore the regular Authenticate middleware (as we have something in there to block anyone who is not signed in, and that will of course block anyone coming via the app) and just use the sanctum middleware. I could write a custom middleware that checks for the presence of the bearer token but I'm sure that's not what Laravel intends :)
Any idea what I'm missing?