Error local.ERROR: DOMDocument::loadXML():
DendyInsan opened this issue · 1 comments
Hi I'm new in Laravel saml2,and I have problem when try this library. I always got error below:
local.ERROR: DOMDocument::loadXML(): Couldn't find end of Start Tag Subj line 1 in Entity, line: 1 {"exception":"[object] (ErrorException(code: 0): DOMDocument::loadXML(): Couldn't find end of Start Tag Subj line 1 in Entity, line: 1 at C:\inetpub\wwwroot\comex\vendor\onelogin\php-saml\src\Saml2\Utils.php:90)
fyi I have succeed get the Information from the IDP when I dd in the EventServiceProvider. But Always error when I want to Auth:login.
Here is My EventServiceProvider.php:
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Aacotroneo\Saml2\Events\Saml2LoginEvent;
use App\models\users;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
Event::listen('Aacotroneo\Saml2\Events\Saml2LoginEvent', function (Saml2LoginEvent $event) {
$messageId = $event->getSaml2Auth()->getLastMessageId();
// Add your own code preventing reuse of a $messageId to stop replay attacks
$user = $event->getSaml2User();
$userData = [
'id' => $user->getUserId(),
'attributes' => $user->getAttributes(),
'assertion' => $user->getRawSamlAssertion()
];
$email=$user->getAttributes()['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'][0];
$json = json_encode($email);
$array = json_decode($json,TRUE);
$user = users::where('email',$array)->first();
if(!$user){
return redirect('/login');
}else{
Auth::loginUsingId($user->id);
}
});
}
}
I Really do not have any idea to solved this error. If you have same experience, I really appreciate if you want to share. Thanks in advance.
Finally I found the way to fix the problem. The cause problem of local.ERROR: DOMDocument::loadXML(): is the app cannot found the url in the Route List. You have really pay attention to the url in the saml2 setting especially if you use the middleware.