Example #1
1
 public function injectContainer()
 {
     $container = $this->slim->getContainer();
     // Register component on container
     // inject config
     $container["config_folder"] = $this->configFolder;
     $container["config"] = function (ContainerInterface $container) {
         $files = scandir($container["config_folder"]);
         $configs = [];
         foreach ($files as $item) {
             $path = $container["config_folder"] . "/" . $item;
             if (is_file($path)) {
                 $name = basename($path, ".php");
                 $configs[$name] = (include $path);
             }
         }
         return $configs;
     };
     // injection aura/session
     $container["session"] = function (ContainerInterface $container) {
         $session_factory = new SessionFactory();
         return $session_factory->newInstance($_COOKIE);
     };
     // injection twig-view template engine
     $container["view"] = function (ContainerInterface $container) {
         // get aura session add global to twig-view
         $session = $container["session"];
         $segment = $session->getSegment("login");
         // new instance twig-view
         $view = new \Slim\Views\Twig($container["config"]["twig"]["templates"], []);
         $view->getEnvironment()->addGlobal('login', $segment);
         // add extension slim
         $view->addExtension(new \Slim\Views\TwigExtension($container["router"], $container["request"]->getUri()));
         $view->addExtension(new \Twig_Extension_Debug());
         return $view;
     };
     // injection medoo database libary
     $container["medoo"] = function (ContainerInterface $container) {
         return new \medoo($container["config"]["medoo"]);
     };
     // ser xml resourcePath
     XMLService::setResourcePath($container->config["config"]["resource_path"] . "/resource/");
 }
Example #2
0
 /**
  * Execute the middleware.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface      $response
  * @param callable               $next
  *
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $session = $this->factory->newInstance($request->getCookieParams());
     if ($this->name !== null) {
         $session->setName($this->name);
     }
     $request = Middleware::setAttribute($request, self::KEY, $session);
     return $next($request, $response);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function invoke(MethodInvocation $invocation)
 {
     $session = $this->factory->newInstance($_COOKIE);
     $csrfToken = $session->getCsrfToken();
     if (!$csrfToken->isValid($this->getActualToken())) {
         throw new InvalidCsrfException();
     }
     $csrfToken->regenerateValue();
     return $invocation->proceed();
 }
 /**
  * Execute the middleware.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface      $response
  * @param callable               $next
  *
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $session = $this->factory->newInstance($request->getCookieParams());
     if ($this->name !== null) {
         $session->setName($this->name);
     }
     $fragment = $session->getSegment(self::STORAGE_KEY);
     $request = self::setAttribute($request, self::KEY, $session);
     $request = self::startStorage($request, $fragment->get(self::STORAGE_KEY) ?: []);
     $response = $next($request, $response);
     $fragment->set(self::STORAGE_KEY, self::stopStorage($request));
     return $response;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     @session_start();
     $sessionFactory = new SessionFactory();
     $session = $sessionFactory->newInstance([]);
     $this->object = new AuraSessionStorage($session->getSegment('LosRateLimit'));
 }
 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Container|ContainerInterface $pimple A container instance
  *
  * @return PhpRenderer
  */
 public function register(Container $pimple)
 {
     $sessionFactory = new SessionFactory();
     $session = $sessionFactory->newInstance($_COOKIE);
     $pimple[Session::class] = $session;
     $pimple[Segment::class] = $session->getSegment('App');
 }
Example #7
0
 /**
  * Singleton für Session-Klasse
  * @return Session
  */
 public static function getSession()
 {
     //Singleton
     if (self::$Session instanceof Session) {
         return self::$Session;
     }
     $sessfactory = new SessionFactory();
     self::$Session = $sessfactory->newInstance($_COOKIE);
     return self::$Session;
 }
 /**
  * Register session manager.
  *
  * @param  \Pimple\Container $container
  * @return \Aura\Session\Session
  */
 protected function registerSessionManager($container)
 {
     $container['sessionManager'] = function () use($container) {
         $sessionFactory = new SessionFactory();
         $session = $sessionFactory->newInstance($_COOKIE);
         $config = $container['config'];
         $session->setCookieParams(['lifetime' => $config['session.lifetime'] * 60, 'path' => $config['session.path'], 'domain' => $config['session.domain'], 'secure' => $config['session.secure']]);
         return $session;
     };
 }
 public function register()
 {
     /** @var Forge $forge */
     $forge = $this->forge;
     if ($forge->has('session')) {
         return;
     }
     # configure the session
     $session_factory = new SessionFactory();
     $session = $session_factory->newInstance($_COOKIE);
     $session->setName($forge->get('config')->get('kernel.session_name'));
     # fail if the session start fails
     if ($session->isStarted()) {
         throw new \LogicException('Cannot continue: unable to start a new session.');
     }
     # remember the session
     $forge->singleton(['session', Session::class], $session);
     $this->provides += [Session::class];
 }
 public function get()
 {
     $factory = new SessionFactory();
     return $factory->newInstance($_COOKIE);
 }
Example #11
0
 /**
  * Create a new session from request
  *
  * @param Request $request PSR7 request
  *
  * @return Session
  *
  * @access protected
  */
 protected function newSession(Request $request)
 {
     return $this->sessionFactory->newInstance($request->getCookieParams());
 }
Example #12
0
<?php

// Import the necessary classes
use Aura\Session\SessionFactory;
use Illuminate\Database\Capsule\Manager as Capsule;
use Philo\Blade\Blade;
use RandomLib\Factory as PasswordFactory;
//database
$capsule = new Capsule();
$capsule->addConnection(['driver' => 'mysql', 'host' => 'localhost', 'database' => 'ovalinfo', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
//manage session
$session_factory = new SessionFactory();
$session = $session_factory->newInstance($_COOKIE);
$session->setCookieParams(array('lifetime' => '1800'));
//30 seconds
$segment = $session->getSegment('oval/signup');
//manage password generation
$factory = new PasswordFactory();
$generator = $factory->getGenerator(new SecurityLib\Strength(SecurityLib\Strength::MEDIUM));
$pasword_characters = 'abcdefghijklmnopqrstuvwxyz';
//hashing IDs
$hashids = new Hashids\Hashids('REyUxDUiTEjlSqUBCRMXidLbuCLITJMoaehUoHmKrrZfeiXvaicKHBuUJjngTYzq', 10, 'abcdefghij1234567890');
//front-end view
$views = __DIR__ . '../../views';
$cache = __DIR__ . '../../cache';
$blade = new Blade($views, $cache);
//load env file
$dotenv = new Dotenv\Dotenv(__DIR__ . '../../');
$dotenv->load();
Example #13
0
 public function __invoke($services)
 {
     $factory = new SessionFactory();
     return $factory->newInstance($_COOKIE);
 }
Example #14
0
 private function initSession()
 {
     $sessionFactory = new SessionFactory();
     $this->session = $sessionFactory->newInstance($_COOKIE);
     $this->sessionSegment = $this->session->getSegment(Config::$SESSION_SEGEMENT);
 }
Example #15
0
 public function __invoke() : AuraSession
 {
     $factory = new SessionFactory();
     return $factory->newInstance($_COOKIE);
 }
 function it_should_valid_csrf_value(MethodInvocation $invocation)
 {
     $factory = new SessionFactory();
     $_POST['__csrf_value'] = $factory->newInstance($_COOKIE)->getCsrfToken()->getValue();
     $this->invoke($this->getInvocation())->shouldHaveType('spec\\Hum2\\TwigFormModule\\FakeResource');
 }