Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mautic.corals.io/app/bundles/UserBundle/Security/SAML/User/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mautic.corals.io/app/bundles/UserBundle/Security/SAML/User/UserMapper.php
<?php

namespace Mautic\UserBundle\Security\SAML\User;

use LightSaml\Model\Assertion\Assertion;
use LightSaml\Model\Protocol\Response;
use LightSaml\SpBundle\Security\User\UsernameMapperInterface;
use Mautic\UserBundle\Entity\User;

class UserMapper implements UsernameMapperInterface
{
    /**
     * @param array<string, mixed> $attributes
     */
    public function __construct(
        private array $attributes
    ) {
    }

    public function getUser(Response $response): User
    {
        $user = new User();

        foreach ($response->getAllAssertions() as $assertion) {
            $this->setValuesFromAssertion($assertion, $user);
        }

        return $user;
    }

    public function getUsername(Response $response): ?string
    {
        $user = $this->getUser($response);

        return $user->getUserIdentifier();
    }

    private function setValuesFromAssertion(Assertion $assertion, User $user): void
    {
        $attributes = $this->extractAttributes($assertion);

        // use email as the user by default
        if (isset($attributes['email'])) {
            $user->setEmail($attributes['email']);
            $user->setUsername($attributes['email']);
        }

        if (isset($attributes['username']) && !empty($attributes['username'])) {
            $user->setUsername($attributes['username']);
        }

        if (isset($attributes['firstname'])) {
            $user->setFirstname($attributes['firstname']);
        }

        if (isset($attributes['lastname'])) {
            $user->setLastName($attributes['lastname']);
        }
    }

    private function extractAttributes(Assertion $assertion): array
    {
        $attributes = [];

        foreach ($this->attributes as $key => $attributeName) {
            if (!$attributeName) {
                continue;
            }

            foreach ($assertion->getAllAttributeStatements() as $attributeStatement) {
                $attribute = $attributeStatement->getFirstAttributeByName($attributeName);
                if ($attribute && $attribute->getFirstAttributeValue()) {
                    $attributes[$key] = $attribute->getFirstAttributeValue();
                }
            }
        }

        return $attributes;
    }
}

Spamworldpro Mini