auth0-samples / laravel Goto Github PK
View Code? Open in Web Editor NEWLaravel 9 application demonstrating Auth0 integration, using the Auth0 Laravel SDK.
Home Page: https://github.com/auth0/laravel-auth0
License: MIT License
Laravel 9 application demonstrating Auth0 integration, using the Auth0 Laravel SDK.
Home Page: https://github.com/auth0/laravel-auth0
License: MIT License
Hello everyone,
I followed this guide: https://auth0.com/docs/quickstart/webapp/laravel/01-login
But Auth::user() returns null all the time. Why is that so?
How can I configure the lock theme or set the initial screen with this setup?
Auth0::getUser()
doesn't work and Auth0::jwtUser()
doesn't have a name property.
I am creating a new project in Laravel8.
I installed the Auth0 SDK into Laravel with the following command.
$ composer require auth0/login
Then I set the "Allowed Callback URLs" of Auth0 as follows.
http://localhost:8080/auth0/callback
I wrote the code for the login part of Laravel as follows.
public function login()
{
$authorize_params = [
'scope' => 'openid email email_verified',
// Use the key below to get an Access Token for your API.
// 'audience' => config('laravel-auth0.api_identifier'),
];
return app()->make('auth0')->login(null, null, $authorize_params);
}
When this code is executed, the parameter of "redirect_url" will be "http://localhost/auth0/callback".
The port number will be erased by itself.
Why is this?
Sample using lock v10.2 when up-to-date version is 10.10 and dependencies like laravel/framework
and auth0/login
are outdated. (AUTH-3772)
We have clients that use Spotfire on their machines (separate credentials from Auth0) and what happens when they login to Auth0 is that they get signed in to Spotfire via Auth0 credentials. But when they Sign Out from Auth0, they’re not signed out from Spotfire license/credentials – is there a way to ensure they get signed out from Spotfire/Auth0?
"auth0/login": "^5.0"
Laravel Framework
public function logout()
{
Auth::logout();
$logoutUrl = sprintf(
'https://%s/v2/logout?federated&client_id=%s&returnTo=%s',
config('laravel-auth0.domain'),
config('laravel-auth0.client_id'),
config('app.url')
);
return Redirect::intended($logoutUrl);
return redirect()->route('home');
}
Hey All,
I was following the tutorial here to integrate Auth0 into my Laravel app and I was running into this Exception on using the callback URL.
http://localhost:3000/auth0/callback
is supposed to redirect to the home page but I get this error instead.
I then downloaded this sample application and ran into the same problem. Seems like login and logout still works however, so this URL test from the tutorial doesn't really matter. Can you please update the tutorial since it appears you do not need that callback URL to work? Or, fix the Auth0 controller to handle a null
user? It was really confusing and I lost a lot of time trying to see what was wrong in my app.
Exception from 01-Login
App:
TypeError:
Argument 1 passed to Auth0\Login\Repository\Auth0UserRepository::getUserByUserInfo() must be of the type array, null given, called in /home/app/vendor/auth0/login/src/controllers/Auth0Controller.php on line 37
at /home/app/vendor/auth0/login/src/Auth0/Login/Repository/Auth0UserRepository.php:27
at Auth0\Login\Repository\Auth0UserRepository->getUserByUserInfo(null)
(/home/app/vendor/auth0/login/src/controllers/Auth0Controller.php:37)
at Auth0\Login\Auth0Controller->callback()
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54)
at Illuminate\Routing\Controller->callAction('callback', array())
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45)
at Illuminate\Routing\ControllerDispatcher->dispatch(object(Route), object(Auth0Controller), 'callback')
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php:254)
at Illuminate\Routing\Route->runController()
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php:197)
at Illuminate\Routing\Route->run()
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:692)
at Illuminate\Routing\Router->Illuminate\Routing\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41)
at Illuminate\Routing\Middleware\SubstituteBindings->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:77)
at Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49)
at Illuminate\View\Middleware\ShareErrorsFromSession->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:121)
at Illuminate\Session\Middleware\StartSession->handleStatefulRequest(object(Request), object(Store), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:63)
at Illuminate\Session\Middleware\StartSession->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37)
at Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:67)
at Illuminate\Cookie\Middleware\EncryptCookies->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103)
at Illuminate\Pipeline\Pipeline->then(object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:694)
at Illuminate\Routing\Router->runRouteWithinStack(object(Route), object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:669)
at Illuminate\Routing\Router->runRoute(object(Request), object(Route))
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:635)
at Illuminate\Routing\Router->dispatchToRoute(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:624)
at Illuminate\Routing\Router->dispatch(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:166)
at Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/fideloper/proxy/src/TrustProxies.php:57)
at Fideloper\Proxy\TrustProxies->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21)
at Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21)
at Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27)
at Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php:87)
at Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(object(Request), object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167)
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103)
at Illuminate\Pipeline\Pipeline->then(object(Closure))
(/home/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:141)
at Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(object(Request))
(/home/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:110)
at Illuminate\Foundation\Http\Kernel->handle(object(Request))
(/home/app/public/index.php:55)
at require_once('/home/app/public/index.php')
(/home/app/server.php:21)
In the composer.json file, Laravel version is 5.3, the latest version is 5.4.
AUTH-3374
Currently, 00-Started-Seed readme.md is invalid, need to replace that readme.md with this instructions.
Hi, I tried to integrate Auth0 into my laravel app according to Auth0 Laravel Quickstart,
made all the steps,
wallter
Oops!, something went wrong
nvalid_request: The redirect_uri parameter is not valid: "local.accounts.wallter/auth0/callback" If url looks fine, check that you are not including non printable chars
I tried to google yet found nothing.
Any Idea? Can you please help?
Thanks,
Sincerely,
Avraham
how to implement passwordless login using Twilio SMS & Laravel?
when enabling the Passwordless SMS from the Auth0 dashboard, i'm getting at the login screen:
Something went wrong. Please contact Technical support
what changes should I do in Laravel to use Passwordless sms login.
Sample using lock v10.2 when up-to-date version is 10.15
(AUTH-3774)
Thanks
Hi,
I first followed your guide on my own laravel project and got an invalid state error, then I just downloaded this sample and I still get the invalid state error.
I triple checked that I have these fields in my settings
http://localhost:3000/auth0/callback to the Allowed Callback URLs field
http://localhost:3000 to the Allowed Web Origins field
http://localhost:3000 to the Allowed Logout URLs field
The env is loaded properly
I can't figure out whats missing, and the docs for that issue seem to be no help at all.
Any insight would be appreciated.
Hi there,
I am facing this issue from tomorrow.
exception: "GuzzleHttp\Exception\ConnectException"
file: "/var/www/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php"
line: 210
message: "cURL error 6: Could not resolve host: dev-xco1z9fm.auth0.com (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://dev-xco1z9fm.auth0.com/.well-known/jwks.json"
earlier it was running perfectly. i have not done any changes in any file.
I am using laravel-8 as backend and ReactJs as frontend.
Please help me with that.
Hi there,
Because of my production environment I need to use the database as a session driver. You do this by setting the SESSION_DRIVER in the .env file to database. Unfortunately whenever I try to login the Authentication with Auth0 wil succeed, but the Authentication inside of Laravel is not working. l keep getting redirected to the login page. Works fine when using "file" as SESSION_DRIVER.
Both projects here (00-Starter-Seed and 01-Login) work flawlessly once downloaded and installed. However, upon running "composer update" to update dependencies, both projects throw the same error upon trying to login:
Auth0 \ SDK \ Exception \ CoreException
Cannot handle token prior to 2019-01-09T09:25:15+0000
Potentially stems the following dependency updates:
Updating auth0/auth0-php (5.1.0 => 5.3.2)
Updating auth0/login (5.0.2 => 5.1.0)
Googling around hasn't produced any fixes that work in this case. Would love to get this up and running again!
Hi,
I have tried this.Users are added to Auth0 users list but not inserted to my database. How can I fixed this?
I set up the SDK for Laravel using your help pages.
When the following code is executed, the I get the following error.
public function logout()
{
Auth::logout();
$logoutUrl = sprintf(
'https://%s/v2/logout?client_id=%s&returnTo=%s',
config('laravel-auth0.domain'),
config('laravel-auth0.client_id'),
config('app.url')
);
return Redirect::intended($logoutUrl);
}
There could be a misconfiguration in the system or a service outage. We track these errors automatically, but if the problem persists feel free to contact us.
Please try again.
Please tell me how to fix this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.