Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 2, 2024 via composer

namshi/jose 7.2.3

JSON Object Signing and Encryption library for PHP.
Package summary
Share
0
issues
1
license
2
MIT
Package created
3 Jun 2013
Version published
5 Dec 2016
Maintainers
2
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
namshi/jose@7.2.3
symfony/polyfill-php56@v1.20.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of namshi/jose 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
symfony/polyfill-php56v1.20.01.99 kBMIT
prod

Visualizations

Frequently Asked Questions

What does namshi/jose do?

The "namshi/jose" is a PHP library that provides a lightweight implementation of the JSON Web Signature (JWS) specification. It is used broadly for signing and verification procedures of JSON Web Tokens (JWT). These tokens securely transmit information between parties as a JSON object making it a key instrument in ensuring security and integrity of data in PHP applications.

How do you use namshi/jose?

The robust versatility of the "namshi/jose" library can be utilized by installing it through composer from packagist. To add the package, use the following line in your composer.json "namshi/jose": "7.0.*" and run composer update.

Take a look on how to use it in PHP. Below is an example of how to generate a JWS token after verifying login credentials:

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

And here's how to validate the token once a request is made:

<?php
use Namshi\JOSE\SimpleJWS;

$jws        = SimpleJWS::load($_COOKIE['identity']);
$public_key = openssl_pkey_get_public("/path/to/public.key");

if ($jws->isValid($public_key, 'RS256')) {
	$payload = $jws->getPayload();

	echo sprintf("Hey, my JS app just did an action authenticated as user #%s", $payload['uid']);
}

Alternatives for OpenSSL are also available, for instances where OpenSSL does not work or is not installed, PHPSECLIB may be used for RSA encryption and signing procedures.

Where are the namshi/jose docs?

Documentation for the "namshi/jose" library can be found directly on its GitHub repository at https://github.com/namshi/jose. Comprehensive guides with usage examples, and potential security precautions are available for users at all levels to understand the implementation details of JSON Web Signature specific pathways. Regular updates are also made to the repository for continued enhancement and reliability of the "namshi/jose" library.