Build a Simple Laravel App with Authentication

pratik kumar

Hey, I am already having a Laravel application and want to enable Single sign-on for it. I do not understand this programming part. Is there any way I can set up SSO easily without the need to understand the programming?

Automica Canonical

Matt Raible any advice on being able to get past this:
URL is
<br>{{url}}/oauth2/default/v1/logout?id_token_hint=$idToken<br>
“errorSummary”:"Invalid value for ‘client_id’ parameter."

I’m using the token from Auth::user()->token

how would i use client_id ?
thanks

Citen Lovomon

Hi, you can easily enable Single Sign-on for your Laravel application using the miniorange/laravel package. It has an easy to use GUI through which you can setup without bothering to know the actual code and enable SSO quickly. I found it to be very useful for my Laravel app.

Kevin Burkhart

Any chance you were able to figure out this one? I’m having the same issue trying to have a Laravel 8 app logout of Okta.

Matt Raible

You might try posting this question to our developer forums. More people will see it there. https://devforum.okta.com/

You can also contact developers@okta.com for support.

khan aqib

I Matt Raible.

i have an issue Laravel\Socialite\Two\InvalidStateException

vendor/socialiteproviders/manager/src/OAuth2/AbstractProvider.php:37

Adam

Is this guide up to date for Laravel’s latest version, 8.x, the latest stable version as of May 2021? I’m starting to notice that Laravel changes so much that it cancels out its supposed simplicity.

Rahul Sagar

Can you help with instructions on how to configure with SAML

Erik Olson

Reality has diverged from the info in this tutorial, for both Laravel and the Okta website. There are quite a few things that need to be done differently in order to make this work. I’m still tinkering but if I’m successful I’ll post about it here. I just had to vent my frustration. I know it can’t be helped, but I’m always disappointed when instructions posted by a service provider (in this case Okta) become outdated and are not updated. It’s a bad first impression and probably makes people go elsewhere

Matt Raible

Hello Erik,

You are correct that Okta’s website has changed since this tutorial was written. To create an application, you have to navigate to Admin > Applications > Create App Integration > OIDC > Web Application. Then, you can use the same instructions in this post, that is “http://localhost:8000/login/okta/callback” for the sign-in redirect URI. Then, everything should work.

Sam Rodriguez

Can you demonstrate how to logout and destroy the OKTA session using laravel and socialite?

This kind of goes over it but it isn’t completely clear how to set this up.

https://developer.okta.com/…

Sam Rodriguez

@Auto@automicacanonical did you figure this out? I am currently trying to get logout functionaluty to work as well in Laravel.

Sam Rodriguez

@kevinburkhart did you end up posting on the dev forum?
Did you find a proper way to logout of okta using laravel?

In your Socialite controller callback() method store the id_token in a session

session(['id_token' => $oktaUser->accessTokenResponseBody['id_token']]);

then assuming you’re using Fortify: In your LogoutResponse class add a redirect from the toResponse() method:

redirect(config('session.okta.end_session_endpoint') . '?id_token_hint=' . $request->id_token . '&post_logout_redirect_uri=' . config('app.url'));