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/cartforge.co/vendor/magento/module-admin-adobe-ims/Plugin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/vendor/magento/module-admin-adobe-ims/Plugin/BackendAuthSessionPlugin.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

namespace Magento\AdminAdobeIms\Plugin;

use Magento\AdminAdobeIms\Model\ImsConnection;
use Magento\AdminAdobeIms\Service\ImsConfig;
use Magento\Backend\Model\Auth\Session;
use Magento\Framework\Stdlib\DateTime\DateTime;

class BackendAuthSessionPlugin
{
    /**
     * How often access_token has to be validated
     */
    public const ACCESS_TOKEN_INTERVAL_CHECK = 600;

    /**
     * @var ImsConnection
     */
    private ImsConnection $adminImsConnection;

    /**
     * @var DateTime
     */
    private DateTime $dateTime;

    /**
     * @var ImsConfig
     */
    private ImsConfig $adminImsConfig;

    /**
     * @param ImsConnection $adminImsConnection
     * @param DateTime $dateTime
     * @param ImsConfig $adminImsConfig
     */
    public function __construct(
        ImsConnection $adminImsConnection,
        DateTime $dateTime,
        ImsConfig $adminImsConfig
    ) {
        $this->adminImsConnection = $adminImsConnection;
        $this->dateTime = $dateTime;
        $this->adminImsConfig = $adminImsConfig;
    }

    /**
     * Check if access token still valid
     *
     * @param Session $subject
     * @param callable $proceed
     * @return void
     * @throws \Magento\Framework\Exception\AuthorizationException
     */
    public function aroundProlong(Session $subject, callable $proceed): void
    {
        if ($this->adminImsConfig->enabled()) {
            $lastCheckTime = $subject->getTokenLastCheckTime();
            if ($lastCheckTime + self::ACCESS_TOKEN_INTERVAL_CHECK <= $this->dateTime->gmtTimestamp()) {
                $accessToken = $subject->getAdobeAccessToken();
                if ($this->adminImsConnection->validateToken($accessToken)) {
                    $subject->setTokenLastCheckTime($this->dateTime->gmtTimestamp());
                } else {
                    $subject->destroy();
                    return;
                }
            }
        }

        $proceed();
    }
}

Spamworldpro Mini