Let’s build a simple Laravel app and add authentication with a custom identity provider.
Unfortunately coming across issues with Laravel 6… Once we’ve passed the main hurdles with Okta providers and array_get and fixed the URL we’re now getting:
Method App\Http\Controllers\Auth\LoginController::showLoginForm does not exist.
Indeed controller is no longer using Authenticates trait… Is this a known issue or has Laravel 6 been tested ?
This blog post is written for Laravel 5. We will hopefully be able to publish an updated tutorial for Laravel 6 in the future.
Would that be sooner rather than later? Just trying to figure out the amount of effort we shall put into it right now…
It’s not scheduled on our calendar yet so I would say you shouldn’t wait for us. If you do figure it out, please post any notes as a new comment here so others can find it too!
@disqus_ObMm9bHisQ I’ll have a look at it over the weekend and see if I can help you. It should be a simple fix since there aren’t huge differences between Laravel 6 and 5.8. In any case, I’ll let you know how difficult it would be to fix even if I can’t provide the solution.
We’ll see if we can have a quick fix and if not I’ll talk to dev team as to how much are they locked into Laravel 6…
@disqus_ObMm9bHisQ I bumped the framework version in composer.json to 6.* and ran composer update. It upgraded Laravel to 6.12.0.
After that, I got the array_get error and switched “socialiteproviders/okta” to “dev-master” in composer.json (this is the suggested solution until the official fix is released).
After that, I was able to login with Okta immediately and everything worked as expected (the Dashboard, the Personal Home Page link, etc).
I’m not sure what you mean by ‘fixed the URL’ but I didn’t have to do anything except these two changes in composer.json:
So it seems to me that you have a different problem which is not related to Laravel 6. Probably something’s misconfigured regarding your Okta account, or you missed a step in the tutorial. Can you start the tutorial in Laravel 5.8, as it was originally designed for that version, make sure it works and then upgrade to Laravel 6 as I did?
BTW, the Login controller doesn’t need the showLoginForm() method because it should never show a local login form. It only needs the methods that are implemented (redirectToProvider, handleProviderCallback, and Logout) to work with Okta as the authentication provider, so it doesn’t include the standard Laravel trait AuthenticatesUsers.
We have now done a fresh 5.8 deployment and its working! I’ll try upgrading to Laravel 6 as you suggest.
Unrelated issue - I was trying to include custom directory profile fields into a user information request by adding a claim for this field, but not sure if I’m using the right API and am not sure how to get this.
$token = Auth::user()->token;
$user = Socialite::driver(‘okta’)->userFromToken($token);
^^ does not seem to include my fields into either main array or as part of “user” element.
Interestingly if I do the token request sample from Okta UI it looks to be coming through.
Thanks for that!
How can you check the Okta org each time the page is loaded? We are having issues where users are signing out of Okta but they are still signed in to our Laravel application.
This is a good question, and I recommend you to look at this article which discusses this problem (local authentication vs remote authentication):
Hi @krasimirhristozov , thank you for the reference. Seems like the general idea I’m trying to implement. In fact, I added a middleware to my Laravel application to check the JWT token, but am getting an error that the “kid” is invalid. I had a similar issue a while ago when authenticating API request. See this GitHub issue. I also posted on Laracasts about it here. Feel free to chime in if you have any other thoughts. Thanks again!
Could you share what you did to overcome array_get issue?
Passing in the token I get from Auth::user->token into
$jwtVerifier = (new \Okta\JwtVerifier\JwtVerifierBuilder())
$jwt = $jwtVerifier->verify($token)
results in this error: “kid” invalid, unable to lookup correct key
What am I doing wrong?
I am having the same issue, but it seems the lack of real dev support will not resolve this.
Hi @disqus_nZHnj1qSyB ,
I don’t maintain the okta-jwt-verifier-php library, but I’ll have a look and try to help you.
Muhammad Razi Bin Mohd
Hi could I check if this package is using SAML or OAuth?