PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 18, 2022

[FIXED] Trying to set up CAS with my Laravel project

 January 18, 2022     cas, laravel, laravel-5     No comments   

Issue

I am using subfission/cas for my application. I have followed all installation steps. I am using windows, if that matters. More precisely, I have configured the following:

I ran the following in my terminal

composer require "subfission/cas" "dev-master"

I configured my Kernel.php accordingly, adding the following:

'cas.auth'  => 'Subfission\Cas\Middleware\CASAuth',
'cas.guest' => 'Subfission\Cas\Middleware\RedirectCASAuthenticated',

I ran the following command:

php artisan vendor:publish

I also set up my cas server in my cas.php config file:

'cas_hostname'        => env('CAS_HOSTNAME', 'cas.myserver.me'),
'cas_real_hosts'      => env('CAS_REAL_HOSTS', 'cas.myserver.me'),

What I want is a middleware for all my routes, so I added the following route rule in my routes:

Route::middleware(['cas.auth'])->group(function ()
{
    Route::get('/', function ()
    {
        return view('welcome');
    });
});

Basically, I want to redirect everyone who is not logged in to the login page whenever I access the main page (for now, I will add more routes in the future). What happens is that the users are redirected to the login page when they are not logged in, but after the login I receive the following error:

ErrorException (E_WARNING) DOMDocument::loadXML(): Opening and ending tag mismatch: hr line 1 and body in Entity, line: 1

No matter what view I'm redirecting the user to. I tried the default welcome page as well as an empty view, but I still get the same error.

EDIT: I have used the dev-master branch from subfission/cas for the above error and after switching to 2.1.1, I get a different error:

session_name(): Cannot change session name when headers already sent

EDIT 2: I did some more digging and I enabled internal errors in my cas client class with:

libxml_use_internal_errors(true);

And now I get the following:

Authentication failure: SA not validated Reason: bad response from the CAS server

And the cas response is: Cas error The thing is that I use the same cas server for another 2 projects and it works well for those (but those aren't laravel projects.


Solution

I managed to solve the issue by disabling the SAML in the cas configure file:

'cas_enable_saml'     => env('CAS_ENABLE_SAML', true),

change to

'cas_enable_saml'     => env('CAS_ENABLE_SAML', false),


Answered By - Bogdan
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing