Adding basic files · lcobucci/jwt@aad22ed · GitHub
Adding basic files
| @@ -0,0 +1,5 @@ | ||
| +.buildpath | ||
| +.project | ||
| +.settings/ | ||
| +vendor | ||
| +build |
| @@ -1,4 +1,47 @@ | ||
| -jwt | ||
| -=== | ||
| +# JWT | ||
| -A simple library to work with JSON Web Token and JSON Web Signature | ||
| +master [](http://travis-ci.org/#!/lcobucci/jwt) | ||
| +develop [](http://travis-ci.org/#!/lcobucci/jwt) | ||
| + | ||
| +[](https://packagist.org/packages/lcobucci/jwt) | ||
| +[](https://packagist.org/packages/lcobucci/jwt) | ||
| + | ||
| +A simple library to work with JSON Web Token and JSON Web Signature (requires PHP 5.5+) | ||
| + | ||
| +## Instalation | ||
| + | ||
| +Just add to your composer.json: ```"lcobucci/jwt": "1.x"``` | ||
| + | ||
| +## Basic usage | ||
| + | ||
| +### Creating | ||
| + | ||
| +Just use the builder to create a new JWT/JWS tokens: | ||
| + | ||
| +```php | ||
| +<?php | ||
| +use Lcobucci\JWT\Builder; | ||
| +use Lcobucci\JWT\Signer\Sha256; | ||
| + | ||
| +$token = (new Builder())->setIssuer('http://example.com') // Configures the issuer (iss claim) | ||
| + ->setAudience('http://example.org') // Configures the audience (aud claim) | ||
| + ->setId('4f1g23a12aa', true) // Configures the id (jti claim), replicating as a header item | ||
| + ->set('uid', 1) // Configures a new claim, called "uid" | ||
| + ->sign(new Sha256(), 'my key') // Signs the token with HS256 using "my key" as key | ||
| + ->getToken(); // Retrieves the generated token | ||
| + | ||
| +echo $token; // The string representation of the object is a JWT string (pretty easy, right?) | ||
| +``` | ||
| +### Parsing from strings | ||
| + | ||
| +Use the parser to create a new token from a JWT string: | ||
| + | ||
| +```php | ||
| +<?php | ||
| +use Lcobucci\JWT\Parser; | ||
| + | ||
| +$token = (new Parser())->parse('...'); // Parses from a string | ||
| +$token->getHeader(); // Retrieves the token header | ||
| +$token->getClaims(); // Retrieves the token claims | ||
| +$token->verify('my key'); // Verifies if the signature was created with given key (if token is signed) | ||
| +``` |
| @@ -0,0 +1,27 @@ | ||
| +{ | ||
| + "name" : "lcobucci/jwt", | ||
| + "description" : "A simple library to work with JSON Web Token and JSON Web Signature", | ||
| + "type" : "library", | ||
| + "authors" : [{ | ||
| + "name" : "Luís Otávio Cobucci Oblonczyk", | ||
| + "email" : "lcobucci@gmail.com", | ||
| + "role": "Developer" | ||
| + } | ||
| + ], | ||
| + "keywords" : ["JWT", "JWS"], | ||
| + "license" : ["BSD-3-Clause"], | ||
| + "require" : { | ||
| + "php" : ">=5.5" | ||
| + }, | ||
| + "require-dev" : { | ||
| + "phpunit/phpunit" : "4.0.x", | ||
| + "squizlabs/php_codesniffer" : "*", | ||
| + "phpmd/phpmd" : "*" | ||
| + }, | ||
| + "autoload" : { | ||
| + "psr-4" : { | ||
| + "Lcobucci\\JWT\\" : "src", | ||
| + "Lcobucci\\JWT\\Test\\" : "test" | ||
| + } | ||
| + } | ||
| +} |
Large diffs are not rendered by default.
| @@ -0,0 +1,23 @@ | ||
| +<?xml version="1.0" encoding="UTF-8"?> | ||
| +<phpunit | ||
| + colors="true" | ||
| + backupGlobals="false" | ||
| + backupStaticAttributes="false" | ||
| + bootstrap="vendor/autoload.php" | ||
| + strict="true"> | ||
| + <testsuites> | ||
| + <testsuite name="JWT Test Suite"> | ||
| + <directory>test</directory> | ||
| + </testsuite> | ||
| + </testsuites> | ||
| + | ||
| + <filter> | ||
| + <whitelist processUncoveredFilesFromWhitelist="true"> | ||
| + <directory suffix=".php">src</directory> | ||
| + </whitelist> | ||
| + | ||
| + <blacklist> | ||
| + <directory suffix=".php">vendor</directory> | ||
| + </blacklist> | ||
| + </filter> | ||
| +</phpunit> |
Adding basic files · lcobucci/jwt@aad22ed · GitHub的更多相关文章
- Adding Swap Files
Adding Swap Files If you do not have free disk space to create a swap partition and you do need to a ...
- springboot成神之——basic auth和JWT验证结合
本文介绍basic auth和JWT验证结合 目录结构 依赖 config配置文件WebSecurityConfig filter过滤器JWTLoginFilter filter过滤器JWTAuthe ...
- lcobucci/jwt的安装和使用
安装 composer require lcobucci/jwt 3.3 封装 <?php namespace tools\jwt; use Lcobucci\JWT\Builder; use ...
- GitHub - firebase/php-jwt: PEAR package for JWT
PHP-JWT A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to RFC 75 ...
- git配置ssh(github)
[参考官方文档] SSH keys are a way to identify trusted computers, without involving passwords. The steps be ...
- JWT(Json Web Token)初探与实践
前言什么是JWT?为什么使用JWT?什么时候使用JWT?JWT的基本结构HeaderPayloadSignature将他们放在一起项目实践JWT后端前端关于安全性总结参考 协议标准:https://t ...
- JWT在PHP使用及问题处理
官网 https://jwt.io/ 3.0版本 https://github.com/lcobucci/jwt 安装 composer require lcobucci/jwt 依赖 PHP 5.5 ...
- API安全验证之JWT(JSON WEB TOKEN) OLCMS
假如www.olcms.com/getUserInfo获取用户信息,你怎么知道当前用户是谁?有人说登陆时候我把他UID写入session了,如果是API接口,没有session怎么办,那么就需要把UI ...
- 基于JWT的Token登录认证(一)
1.JWT简介 JSON Web Token(缩写 JWT),是目前最流行的跨域认证解决方案. session登录认证方案:用户从客户端传递用户名.密码等信息,服务端认证后将信息存储在session中 ...
随机推荐
- Android基础控件EditText
1.常用属性 <!--selectAllOnFocus 获得焦点后全选组件内所有文本内容--> <!--inputType 限制输入方式--> <!--singleLin ...
- Jeecg-Boot 2.0 版本发布,基于Springboot+Vue 前后端分离快速开发平台
目录 Jeecg-Boot项目简介 源码下载 升级日志 Issues解决 v1.1升级到v2.0不兼容地方 系统截图 Jeecg-Boot项目简介 Jeecg-boot 是一款基于代码生成器的智能开发 ...
- java-学习网站推荐
技术博客: http://c.biancheng.net/view/1390.html (设计模式等等应有尽有,最全教程,强烈推荐!!!) hutool:http://hutool.mydoc.io/ ...
- python 中的 is 方法 总结
isidentifier: 判断变量名是否合法 iskeyword:是否为内置关键字
- Nginx是什么?
Nginx是什么? Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器.一直纳闷这个X是怎么来 ...
- 高德地图(AMap)JavaScript API的使用
申请JSAPI的开发者key 申请地址:http://lbs.amap.com/dev/key 引入高德地图JavaScript API文件: <script type="text/j ...
- mysql系统变量与状态变量
一.系统变量分为全局系统变量和会话系统变量:有些变量既是全局系统变量,有些变量只有全局的,有些变量只有会话的. .变量的查询: show global variables like 'log' \G; ...
- LUOGU P2962 [USACO09NOV]灯Lights
题目描述 Bessie and the cows were playing games in the barn, but the power was reset and the lights were ...
- linux学习(三)-----linux用户管理、实用指令
用户管理 基本介绍 说明: 1.Linux 系统是一个多用户多任务的操作系统,任何一个要使用系统资源的用户,都必须首先向 系统管理员申请一个账号,然后以这个账号的身份进入系统. 2.Linux 的用户 ...
- 关于JVM调优
JVM调优主要是针对内存管理方面的调优,包括控制各个代的大小,GC策略.由于GC开始垃圾回收时会挂起应用线程,严重影响了性能,调优的目是为了尽量降低GC所导致的应用线程暂停时间. 减少Full GC次 ...