Authentication using cookie without users table

Posted 11 months ago by DoubleR

Hello, I have what seems to be a simple requirement for authenticating with my laravel 5.5 app. In our intranet, users authenticate through a company-site, which when successfully authenticated, it sets an encrypted browser cookie with the user's ID, name, and additional items. Finally, it redirects the user back to the page that called it.

On my end, the cookie then gets decrypted through PHP. Once here, my app should authenticate using the decrypted user ID, saving the name and other info provided under Auth::User. However, I don't want to have a database with over 500k entries to look up the user, I just want any employee to be able to log in. So I believe what I want is Auth::User to use GenericUser where I set the user based on the decrypted cookie info. I've tried following instructions from the following pages:

But I can't get it to work. I can't figure out the proper way to create a custom authentication provider nor how to create a custom user provider.

I have a site which doesn't use Laravel and the way I authenticate is checking for the cookie to be set and not expired, then setting session variables such as REMOTE_USER.

If anyone has any ideas, I'm open to try them. I'm still a beginner with Laravel, so I may ask additional questions.

Thanks in advance

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.