How to set different auth guard in laravel with auth0Why is my implementation of SSO using Ember-Simple-Auth with Auth0 getting stuck in a redirect loop?Angular2 auth guard with http request and observablesHow to enrich/extend Auth class/data in Laravel 5?Angular2 auth guard keeps track of current user with observableAuth0, Laravel 5.4 - after logout user is logged againLaravel session and auth issue in MacOSLaravel Multi Auth - Admin Guardcustom auth guard not logging in laravelAuth::user() is not working for Guard authentication in laravel 5.6Auth Laravel check authentication of user not working in custom controller
USA: Can a witness take the 5th to avoid perjury?
What to do when you reach a conclusion and find out later on that someone else already did?
How do I stop my characters falling in love?
Inadvertently nuked my disk permission structure - why?
How acidic does a mixture have to be for milk to curdle?
How do we explain the E major chord in this progression?
What is the effect and/or good reasons of changing a paper bill to a coin?
Heisenberg uncertainty principle in daily life
What is the lowest-speed bogey a jet fighter can intercept/escort?
What does "see" in "the Holy See" mean?
What do teaching faculty do during semester breaks?
Marrying a second woman behind your wife's back: is it wrong and can Quran/Hadith prove this?
A planet illuminated by a black hole?
This message is flooding my syslog, how to find where it comes from?
How do campaign rallies gain candidates votes?
Character is called by their first initial. How do I write it?
Why was Sauron preparing for war instead of trying to find the ring?
Singapore to Sydney to Canberra: where do we clear customs
How can I stop myself from micromanaging other PCs' actions?
Can two figures have the same area, perimeter, and same number of segments have different shape?
Why isn't there a serious attempt at creating a third mass-appeal party in the US?
Does the Intel 8086 CPU have user mode and kernel mode?
Explain why watch 'jobs' does not work but watch 'ps' work?
Is there a reason why I should not use the HaveIBeenPwned API to warn users about exposed passwords?
How to set different auth guard in laravel with auth0
Why is my implementation of SSO using Ember-Simple-Auth with Auth0 getting stuck in a redirect loop?Angular2 auth guard with http request and observablesHow to enrich/extend Auth class/data in Laravel 5?Angular2 auth guard keeps track of current user with observableAuth0, Laravel 5.4 - after logout user is logged againLaravel session and auth issue in MacOSLaravel Multi Auth - Admin Guardcustom auth guard not logging in laravelAuth::user() is not working for Guard authentication in laravel 5.6Auth Laravel check authentication of user not working in custom controller
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am work on laravel with auth0 project (package is auth0/login).
My project has local auth users.
I am going to add auth method with auth0, so I have set auth config for auth0.
This is my /config/auth.php code
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'auth0web'=>[
'driver' => 'session',
'provider' => 'auth0_users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppUser::class,
],
'auth0_users'=>[
'driver' => 'auth0'
],
],
this is my callback route's controller function.
public function auth0SigninCallback()
//return response()->json(Auth:: guard('auth0web)->user());
$service = App::make('auth0');
// Try to get the user information
$profile = $service->getUser();
$userRepo = new Auth0UserRepository();
$auth0User = $userRepo->getUserByUserInfo($profile);
return response()->json($auth0User);
Auth::guard('auth0web)->user();
At this code I am getting null for auth user.
$profile is correctly getting for now.
how can I get different guard(Auth::guard('auth0web')->user()) for auth
Thanks for your advance.
PS
This is my session data maybe that is correctly
"_token": "OAmhhYKWeO0tK6E5FN3DHaRvVYx6PP7z0YPMAPrz",
"_previous":
"url": "http://xxxxx.dev/login"
,
"_flash":
"old": [],
"new": []
,
"auth0__user": xxxxxxxxxxx",
"nickname": "xxxxxxxx",
"name": "xxxxx@xxxxx.com",
"picture": "https://s.gravatar.com/avatar/xxxx.png",
"updated_at": "2019-03-26T17:28:53.981Z",
"email": "xxxxxx@ixxx.com",
"email_verified": true
I have try override callback route controller
this is code
// Get a handle of the Auth0 service (we don't know if it has an alias)
$service = App::make('auth0');
// Try to get the user information
$profile = $service->getUser();
// Get the user related to the profile
$auth0User = $this->userRepository->getUserByUserInfo($profile);
if ($auth0User)
// If we have a user, we are going to log them in, but if
// there is an onLogin defined we need to allow the Laravel developer
// to implement the user as they want an also let them store it.
if ($service->hasOnLogin())
$user = $service->callOnLogin($auth0User);
else
// If not, the user will be fine
$user = $auth0User;
Auth::guard('auth0web')->login($user, $service->rememberUser());
// dd(auth());
// Log::info(auth()->user());
return Redirect::intended('/home');
}
at this time auth() is correctly working
but while redirecting to home Auth is initialized
this is my custom middleware.
public function handle($request, Closure $next)
// Log::info('------------here---------');
// dd(auth());
$auth = Auth::user() ?? Auth::guard('ldap')->user();
// dd(auth());
// Log::info(auth()->user());
if (!isset($auth->id))
return redirect('login');
else
return $next($request);
At this part I'm getting null from auth()->user()
laravel authentication auth0
add a comment |
I am work on laravel with auth0 project (package is auth0/login).
My project has local auth users.
I am going to add auth method with auth0, so I have set auth config for auth0.
This is my /config/auth.php code
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'auth0web'=>[
'driver' => 'session',
'provider' => 'auth0_users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppUser::class,
],
'auth0_users'=>[
'driver' => 'auth0'
],
],
this is my callback route's controller function.
public function auth0SigninCallback()
//return response()->json(Auth:: guard('auth0web)->user());
$service = App::make('auth0');
// Try to get the user information
$profile = $service->getUser();
$userRepo = new Auth0UserRepository();
$auth0User = $userRepo->getUserByUserInfo($profile);
return response()->json($auth0User);
Auth::guard('auth0web)->user();
At this code I am getting null for auth user.
$profile is correctly getting for now.
how can I get different guard(Auth::guard('auth0web')->user()) for auth
Thanks for your advance.
PS
This is my session data maybe that is correctly
"_token": "OAmhhYKWeO0tK6E5FN3DHaRvVYx6PP7z0YPMAPrz",
"_previous":
"url": "http://xxxxx.dev/login"
,
"_flash":
"old": [],
"new": []
,
"auth0__user": xxxxxxxxxxx",
"nickname": "xxxxxxxx",
"name": "xxxxx@xxxxx.com",
"picture": "https://s.gravatar.com/avatar/xxxx.png",
"updated_at": "2019-03-26T17:28:53.981Z",
"email": "xxxxxx@ixxx.com",
"email_verified": true
I have try override callback route controller
this is code
// Get a handle of the Auth0 service (we don't know if it has an alias)
$service = App::make('auth0');
// Try to get the user information
$profile = $service->getUser();
// Get the user related to the profile
$auth0User = $this->userRepository->getUserByUserInfo($profile);
if ($auth0User)
// If we have a user, we are going to log them in, but if
// there is an onLogin defined we need to allow the Laravel developer
// to implement the user as they want an also let them store it.
if ($service->hasOnLogin())
$user = $service->callOnLogin($auth0User);
else
// If not, the user will be fine
$user = $auth0User;
Auth::guard('auth0web')->login($user, $service->rememberUser());
// dd(auth());
// Log::info(auth()->user());
return Redirect::intended('/home');
}
at this time auth() is correctly working
but while redirecting to home Auth is initialized
this is my custom middleware.
public function handle($request, Closure $next)
// Log::info('------------here---------');
// dd(auth());
$auth = Auth::user() ?? Auth::guard('ldap')->user();
// dd(auth());
// Log::info(auth()->user());
if (!isset($auth->id))
return redirect('login');
else
return $next($request);
At this part I'm getting null from auth()->user()
laravel authentication auth0
SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶
– Loveun CG
Mar 27 at 0:51
This is result ofdd(Auth::guard('auth0web'));
– Loveun CG
Mar 27 at 0:52
add a comment |
I am work on laravel with auth0 project (package is auth0/login).
My project has local auth users.
I am going to add auth method with auth0, so I have set auth config for auth0.
This is my /config/auth.php code
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'auth0web'=>[
'driver' => 'session',
'provider' => 'auth0_users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppUser::class,
],
'auth0_users'=>[
'driver' => 'auth0'
],
],
this is my callback route's controller function.
public function auth0SigninCallback()
//return response()->json(Auth:: guard('auth0web)->user());
$service = App::make('auth0');
// Try to get the user information
$profile = $service->getUser();
$userRepo = new Auth0UserRepository();
$auth0User = $userRepo->getUserByUserInfo($profile);
return response()->json($auth0User);
Auth::guard('auth0web)->user();
At this code I am getting null for auth user.
$profile is correctly getting for now.
how can I get different guard(Auth::guard('auth0web')->user()) for auth
Thanks for your advance.
PS
This is my session data maybe that is correctly
"_token": "OAmhhYKWeO0tK6E5FN3DHaRvVYx6PP7z0YPMAPrz",
"_previous":
"url": "http://xxxxx.dev/login"
,
"_flash":
"old": [],
"new": []
,
"auth0__user": xxxxxxxxxxx",
"nickname": "xxxxxxxx",
"name": "xxxxx@xxxxx.com",
"picture": "https://s.gravatar.com/avatar/xxxx.png",
"updated_at": "2019-03-26T17:28:53.981Z",
"email": "xxxxxx@ixxx.com",
"email_verified": true
I have try override callback route controller
this is code
// Get a handle of the Auth0 service (we don't know if it has an alias)
$service = App::make('auth0');
// Try to get the user information
$profile = $service->getUser();
// Get the user related to the profile
$auth0User = $this->userRepository->getUserByUserInfo($profile);
if ($auth0User)
// If we have a user, we are going to log them in, but if
// there is an onLogin defined we need to allow the Laravel developer
// to implement the user as they want an also let them store it.
if ($service->hasOnLogin())
$user = $service->callOnLogin($auth0User);
else
// If not, the user will be fine
$user = $auth0User;
Auth::guard('auth0web')->login($user, $service->rememberUser());
// dd(auth());
// Log::info(auth()->user());
return Redirect::intended('/home');
}
at this time auth() is correctly working
but while redirecting to home Auth is initialized
this is my custom middleware.
public function handle($request, Closure $next)
// Log::info('------------here---------');
// dd(auth());
$auth = Auth::user() ?? Auth::guard('ldap')->user();
// dd(auth());
// Log::info(auth()->user());
if (!isset($auth->id))
return redirect('login');
else
return $next($request);
At this part I'm getting null from auth()->user()
laravel authentication auth0
I am work on laravel with auth0 project (package is auth0/login).
My project has local auth users.
I am going to add auth method with auth0, so I have set auth config for auth0.
This is my /config/auth.php code
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'auth0web'=>[
'driver' => 'session',
'provider' => 'auth0_users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppUser::class,
],
'auth0_users'=>[
'driver' => 'auth0'
],
],
this is my callback route's controller function.
public function auth0SigninCallback()
//return response()->json(Auth:: guard('auth0web)->user());
$service = App::make('auth0');
// Try to get the user information
$profile = $service->getUser();
$userRepo = new Auth0UserRepository();
$auth0User = $userRepo->getUserByUserInfo($profile);
return response()->json($auth0User);
Auth::guard('auth0web)->user();
At this code I am getting null for auth user.
$profile is correctly getting for now.
how can I get different guard(Auth::guard('auth0web')->user()) for auth
Thanks for your advance.
PS
This is my session data maybe that is correctly
"_token": "OAmhhYKWeO0tK6E5FN3DHaRvVYx6PP7z0YPMAPrz",
"_previous":
"url": "http://xxxxx.dev/login"
,
"_flash":
"old": [],
"new": []
,
"auth0__user": xxxxxxxxxxx",
"nickname": "xxxxxxxx",
"name": "xxxxx@xxxxx.com",
"picture": "https://s.gravatar.com/avatar/xxxx.png",
"updated_at": "2019-03-26T17:28:53.981Z",
"email": "xxxxxx@ixxx.com",
"email_verified": true
I have try override callback route controller
this is code
// Get a handle of the Auth0 service (we don't know if it has an alias)
$service = App::make('auth0');
// Try to get the user information
$profile = $service->getUser();
// Get the user related to the profile
$auth0User = $this->userRepository->getUserByUserInfo($profile);
if ($auth0User)
// If we have a user, we are going to log them in, but if
// there is an onLogin defined we need to allow the Laravel developer
// to implement the user as they want an also let them store it.
if ($service->hasOnLogin())
$user = $service->callOnLogin($auth0User);
else
// If not, the user will be fine
$user = $auth0User;
Auth::guard('auth0web')->login($user, $service->rememberUser());
// dd(auth());
// Log::info(auth()->user());
return Redirect::intended('/home');
}
at this time auth() is correctly working
but while redirecting to home Auth is initialized
this is my custom middleware.
public function handle($request, Closure $next)
// Log::info('------------here---------');
// dd(auth());
$auth = Auth::user() ?? Auth::guard('ldap')->user();
// dd(auth());
// Log::info(auth()->user());
if (!isset($auth->id))
return redirect('login');
else
return $next($request);
At this part I'm getting null from auth()->user()
laravel authentication auth0
laravel authentication auth0
edited Mar 27 at 2:41
Loveun CG
asked Mar 26 at 17:14
Loveun CGLoveun CG
61 silver badge7 bronze badges
61 silver badge7 bronze badges
SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶
– Loveun CG
Mar 27 at 0:51
This is result ofdd(Auth::guard('auth0web'));
– Loveun CG
Mar 27 at 0:52
add a comment |
SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶
– Loveun CG
Mar 27 at 0:51
This is result ofdd(Auth::guard('auth0web'));
– Loveun CG
Mar 27 at 0:52
SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶
– Loveun CG
Mar 27 at 0:51
SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶
– Loveun CG
Mar 27 at 0:51
This is result of
dd(Auth::guard('auth0web'));– Loveun CG
Mar 27 at 0:52
This is result of
dd(Auth::guard('auth0web'));– Loveun CG
Mar 27 at 0:52
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55362769%2fhow-to-set-different-auth-guard-in-laravel-with-auth0%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55362769%2fhow-to-set-different-auth-guard-in-laravel-with-auth0%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶
– Loveun CG
Mar 27 at 0:51
This is result of
dd(Auth::guard('auth0web'));– Loveun CG
Mar 27 at 0:52