jose icon indicating copy to clipboard operation
jose copied to clipboard

SimpleJWS App

Open PB314 opened this issue 8 years ago • 0 comments

Can someone please include a an implementation example of the "SimpleJWS" script that is not a unit test. All the unit tests work flawlessly, and arguably very often prove nothing. A simple test like the one below is far more useful however this simple test is difficult to configure if you are new to composer and namespaces. That is the code below will not work without refinement and ensuring that the autoloader is invoked.. It would be very helpful if someone could include a working version. `

<?php
use Namshi\JOSE\SimpleJWS;
if ($username == 'correctUsername' && $pass == 'ok') {
    $user = Db::loadUserByUsername($username);
    $jws  = new SimpleJWS(array(
        'alg' => 'RS256'
    ));
    $jws->setPayload(array(
        'uid' => $user->getid(),
    ));
    $privateKey = openssl_pkey_get_private("file://path/to/private.key", self::SSL_KEY_PASSPHRASE);
    $jws->sign($privateKey);
    setcookie('identity', $jws->getTokenString());
}

PB314 avatar Sep 20 '16 15:09 PB314