DoubleR
146
4
Laravel

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:

https://stackoverflow.com/questions/41912867/can-i-put-and-retrieve-the-user-information-to-and-from-session-into-a-laravel-c http://laravel-recipes.com/recipes/115/using-your-own-authentication-driver https://www.georgebuckingham.com/blog/laravel-52-auth-custom-user-providers-drivers/ https://laravel.com/docs/5.5/authentication

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

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.