Download the PHP package yzh52521/webman-jwt without Composer

On this page you can find all versions of the php package yzh52521/webman-jwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package webman-jwt

说明:

webman-jwt 支持多应用单点登录、多应用多点登录、多应用支持注销 token(token会失效)、支持多应用刷新 token

多应用单点登录:在该应用配置下只会有一个 token 生效,一旦刷新 token ,前面生成的 token 都会失效,一般以用户 id 来做区分

多应用多点登录:在该配置应用下token 不做限制,一旦刷新 token ,则当前配置应用的 token 会失效

注意:使用多应用单点登录或者多应用多点登录时,必须要开启黑名单,并且使用 Webman 的缓存(建议使用 redis 缓存) 。如果不开启黑名单,无法使 token 失效,生成的 token 会在有效时间内都可以使用(未更换证书或者 secret )。

多应用单点登录原理:JWT 有七个默认字段供选择。单点登录主要用到 jti 默认字段,jti 字段的值默认为缓存到redis中的key( 该key的生成为场景值+存储的用户id(sso_key)) ,这个key的值会存一个签发时间,token检测会根据这个时间来跟token原有的签发时间对比,如果token原有时间小于等于redis存的时间,则认为无效

多应用多点登录原理:多点登录跟单点登录差不多,唯一不同的是jti的值不是场景值+用户id(sso_key) ,而是一个唯一字符串,每次调用 refreshToken 来刷新 token 或者调用 logout 注销 token 会默认把请求头中的 token 加入到黑名单,而不会影响到别的 token

token 不做限制原理:token 不做限制,在 token 有效的时间内都能使用,你只要把配置文件中的 blacklist_enabled 设置为 false 即可,即为关闭黑名单功能

使用:

jwt配置
全局路由验证
局部验证

config/route.php 文件中,想要验证的路由加入 jwt 验证中间件即可,例如:

7、模拟登录获取token,具体情况下面的例子文件
路由
鉴权

在需要鉴权的接口,请求该接口时在 HTTP 头部加入

结果
请求:http://0.0.0.0:8787/login,下面是返回的结果
请求:http://0.0.0.0:8787/v1/getToken
10、例子文件
获取解析后的 token 数据

提供了一个 getParserData 来获取解析后的 token 数据。 例如:JWTUtil::getParserData($this->request)

如何支持每个场景生成的token不能互相访问各个应用

具体你可以查看yzh52521\Jwt\Middleware\JWTAuthSceneDefaultMiddleware和yzh52521\Jwt\Middleware\JWTAuthSceneAppMiddleware这两个中间件,根据这两个中间件你可以编写自己的中间件来支持每个场景生成的token不能互相访问各个应用

建议

目前 jwt 抛出的异常目前有两种类型 yzh52521\Jwt\Exception\TokenValidException
yzh52521\Jwt\Exception\JWTException,TokenValidException
异常为 TokenValidException 验证失败的异常,会抛出 401 ,
JWTException 异常会抛出 400
最好你们自己在项目异常重新返回错误信息


All versions of webman-jwt with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.0
lcobucci/jwt Version ^4.2.1 || ^5.0
nesbot/carbon Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yzh52521/webman-jwt contains the following files

Loading the files please wait ....