Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

johnw65's avatar

Passing Session Variable and Remove Login

Somewhat new to Laravel and need to perform the following:

  1. Currently using Laravel's User ID and Password to login to the application. Need to disable the User ID and password. How can this be accomplished.

  2. Instead of requesting for User ID and Password, I currently have Apache set up so it will request for a CAC Card instead. In the Laravel/public/index.php need to write a script which would grab the CAC information and pass it to Laravel. I can grab the CAC information, but how can one pass the information into a Laravel session variable . For the middleware, I will be incorporating ingria / laravel-x509-auth .

Thanks in advance.

0 likes
5 replies
martinbean's avatar

@johnw65 What do you mean, you need to “disable the User ID and password”? And what’s a CAC card?

bobbybouwmann's avatar
Level 88

Well, turning off regular authentication is simply turning off the Authenticate middleware. After that, you should be able to use the new middleware provided by the package.

Another solution is simply removing the register/login routes. You can keep the code there, but as long as there is no route there shouldn't be any issues with that ;)

johnw65's avatar

Bobby,

Thanks...let me try that.

I just installed ingria/Laravel (auth.x509) and according to their documentation, I can perform the following:

Route::get('/', 'YourController@method')->middleware('auth.x509');

So instead of using User ID and Password for authentication, I'm in the processing of replacing this with the CAC authentication which is a new requirement.

So maybe I can use the remove the userid and password from the login screen and just use it to display a popup message letting the user know to insert the CAC card. Then grab the CAC information from an user and if it's authenticated let the user into the application.

John

bobbybouwmann's avatar

As far as I understand it, the browser should have the correct certificate loaded. This certificate is sent along on the request. The middleware simply checks if the certificate is valid for the key that is created for the application.

If the CAC card is converted to a certificate that is sent along in the request you should be good to go ;)

I never worked with a CAC-card integration, so not sure how that converts to a request.

johnw65's avatar

Bobby, So I turned off the Authenticate middleware. So in Laravel, I currently have a login screen which provides a popup alerting the user of some important information. Previously, the user would then enter the user id and password for authentication

I know I'm asking a very basic question.

Now, how would I set up Laravel or which file would I need to create/use grab the CAC information and pass it to Laravel session so my middle ware can see the session information. So would it be public/index.php file that I need to modify?

Thanks!

Please or to participate in this conversation.