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中 ...
随机推荐
- 深入浅出 Java Concurrency (25): 并发容器 part 10 双向并发阻塞队列 BlockingDeque[转]
这个小节介绍Queue的最后一个工具,也是最强大的一个工具.从名称上就可以看到此工具的特点:双向并发阻塞队列.所谓双向是指可以从队列的头和尾同时操作,并发只是线程安全的实现,阻塞允许在入队出队不满足条 ...
- PAT甲级——A1095 Cars on Campus
Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out time ...
- 一个四五年的Java开发程序员,该准备哪些去面试?
上周面试了一周,感触颇深,总结一下. 面试了公司大概有阿里,携程,爱奇艺,唯品会,途牛,bilibili,大众点评,阿里和爱奇艺是电话面试,其他现场面试. 首先,五年左右,应该算高级开发工程师,大部分 ...
- sqlmap:wins系统+python3上安装
python2和python3互不兼容,SqlMap是基于python2的,所以SqlMap不支持python3,这里使用virtualenvwrapper切换python版本: 一.sqlmap的安 ...
- <数据链接>常用网站收集
1.互联网数据指数 百度指数:http://index.baidu.com/ 阿里指数:http://index.1688.com/ TBI腾讯浏览指数:http://tbi.tencent.com/ ...
- Leetcode 242.有效的字母异位词(Python3)
题目: 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词. 示例 1: 输入: s = "anagram", t = "nagaram& ...
- [转]WPF中的动画
WPF中的动画 周银辉 动画无疑是WP ...
- HZOI20190902模拟35题解
题面: A:公园 DAG上想拓扑dp 然而博主记忆化搜索了一下 设f[i][j]表示从i节点走j个点出公园所用的最小时间 则$f[u][i]=min(f[v][j-1]+dis_{u,v})$; 然后 ...
- [转]Sql Server Alter语句
原文链接:http://www.cnblogs.com/yoolonet/archive/2010/12/10/1884782.html 在修改Sql Server表结构时,常用到Alter语句,把一 ...
- Maven实战07_依赖
1:依赖声明 <project> ... <dependencies> <dependency> <groupId>...</groupId> ...