Code Monkey home page Code Monkey logo

secured-links's Issues

Method getCsrfToken doesn't work with object parameters

For obvious reasons I get this error:

Recoverable Error
Object of class ... could not be converted to string

For now I'm using this workaround:

    use SecuredLinksPresenterTrait {
        getCsrfToken as private traitGetCsrfToken;
    }

    public function getCsrfToken($control, $method, $params)
    {
        array_walk($params, function (&$value) {
            if (is_object($value)) {
                $value = spl_object_hash($value);
            }
        });
        return $this->traitGetCsrfToken($control, $method, $params);
    }

Should I send a PR with this change or are you against it?

Nette 3.0?

Hello, what about nette 3.0 supports?

Support parameters with object values

We currently use in are app ugly workaround

$params = array_map(
	function ($param) {
		return is_object($param) && method_exists($param, 'getId') ? $param->getId() : $param;
	},
	$params
);

Custom session expiration

I would like to set a custom expiration for session section. I can do it by myself, but it would by nice to have some handy function for this. Something like:

public function setExpiration($expiration)
{
    $section = $this->getSession('Nextras.Application.UI.SecuredLinksPresenterTrait');
    $section->setExpiration($expiration);
}

Exception in random_bytes

Function random_bytes from paragonie/random_compat library can throw an exception. It is very rare situation, but it really happens on our production server. I suggest to encapsulate this code:

$session->token = function_exists('random_bytes')
    ? random_bytes(16)
    : Nette\Utils\Random::generate(16, "\x00-\xFF");

to try/catch block. In catch will be Random::generate()

Invalidate token after usage

Another enhancement to consider: after signal is processed, it's token could by invalidated. This can be achieved by removing token stored in session.

Compatibility with PHP < 8.0

This library declares compatibility with PHP ^7.2 in composer.json. However, release 1.10.0 requires PHP 8.0. because it uses ReflectionClass::getAttributes() method.

Nette/Utils

Kde to pouziva Nette/Utils? Koukal jsem do src, ale bud jsem slepej a nebo jsem to v hlavicce nikde nenasel?
Pokud nejsem slepej, tak vyhodit z composer.json?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.