This repository contains the easiest token handler for PHP implementations.
pixelmelody\phpwebtoken
With composer to manage your dependencies:
composer require pixelmelody/phpwebtoken
- JWT Token implementation as the current spec
- Possible future formats, others than JSON.
- Easy integration on a PHP Project
<?php
$token = new WebToken($token_received);
echo "Header Schema Algorithm: ",$token->getAlgorithm();
echo "Token digest method: ", $token->getDigestMethod();
echo "Header: ", $token->getHeader();
echo "Payload: ", $token->getPayload();
if($token->verify($key)){
echo 'Token Valid';
} else {
echo 'Token not Valid';
}
?>
<?php
$token = new WebToken(); // <= new token RS256 Algorithm default
$token->setClaim('test', 'content for the paylod claim test');
echo "Header Schema Algorithm: ",$token->getAlgorithm();
echo "Token digest method: ", $token->getDigestMethod();
echo "Header: ", $token->getHeader();
echo "Payload: ", $token->getPayload();
$tokenvalue = $token->encode($key);
if($tokenvalue){
echo "Token: ",$tokenvalue;
} else {
echo "Token error on creation";
}
?>
**Please always upgrade to latest stable version from master branch and beaware that on dev branch changes will ocurr. All issues will **
- PHP 5.4 or above
- Composer is not required however you will not have a direct implementation.
If you have encountered a potential security vulnerability in this library, please report it at pixelmelody.com contact form. We will work with you to verify the vulnerability and patch it.
We request that you contact us via the email address to give the project contributors a chance to resolve the vulnerability and issue a new release prior to any public exposure. This helps protect users and provides them with a chance to upgrade and/or update in order to protect their applications.
The merit on finding it will be added to you and we will mention it on the library repository.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.