Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleJWS App #104

Open
PB314 opened this issue Sep 20, 2016 · 0 comments
Open

SimpleJWS App #104

PB314 opened this issue Sep 20, 2016 · 0 comments

Comments

@PB314
Copy link

PB314 commented Sep 20, 2016

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());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant