Download the PHP package php-woox/webman-jwt without Composer

On this page you can find all versions of the php package php-woox/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

JSON Web Token (JWT) for webman plugin

Json web token (JWT), 是为了在网络应用环境间传递声明而执行的一种基于JSON的开放标准((RFC 7519),该token被设计为紧凑且安全的,特别适用于分布式站点的单点登录(SSO)场景。

JWT的声明一般被用来在身份提供者和服务提供者间传递被认证的用户身份信息,以便于从资源服务器获取资源,也可以增加一些额外的其它业务逻辑所必须的声明信息,该token也可直接被用于认证,也可被加密。

认证&授权流程

image

签名流程

  1. 用户使用用户名和口令到认证服务器上请求认证。
  2. 认证服务器验证用户名和口令后,以服务器端生成JWT Token,这个token的生成过程如下:
    • 认证服务器还会生成一个 Secret Key(密钥)
    • 对JWT Header和JWT Payload分别求Base64。在Payload可能包括了用户的抽象ID和的过期时间。
    • 用密钥对JWT签名 HMAC-SHA256(SecretKey, Base64UrlEncode(JWT-Header)+'.'+Base64UrlEncode(JWT-Payload))
  3. 然后把 base64(header).base64(payload).signature 作为 JWT token返回客户端。
  4. 客户端使用JWT Token向应用服务器发送相关的请求。这个JWT Token就像一个临时用户权证一样。

安装

使用

生成令牌

输出(json格式)

响应参数

参数 类型 描述 示例值
token_type string Token 类型 Bearer
expires_in int 凭证有效时间,单位:秒 36000
access_token string 访问凭证 XXXXXXXXXXXXXXXXXXXX
refresh_token string 刷新凭证(访问凭证过期使用 ) XXXXXXXXXXXXXXXXXXXX

支持函数列表

1、获取当前id

2、获取所有字段

3、获取自定义字段

4、刷新令牌(通过刷新令牌获取访问令牌)

5、获令牌有效期剩余时长

6、单设备登录。默认是关闭,开启请修改配置文件config/plugin/woox/webman-jwt

单设备登录支持定义客户端 client 字段,自定义客户端单点登录(默认为WEB,即网页端),如:MOBILEAPPWECHATWEBADMINAPIOTHER等等

7、获取当前用户信息(模型)

该配置项目'user_model'为一个匿名函数,默认返回空数组,可以根据自己项目ORM定制化自己的返回模型

LaravelORM 配置

8、令牌清理

只有配置项 is_single_devicetrue 才会生效。可选参数:MOBILEAPPWECHATWEBADMINAPIOTHER等等

9、自定义终端client

默认是WEB

10、自定义访问令牌和刷新令牌过期时间

签名算法

JWT 最常见的几种签名算法(JWA):HS256(HMAC-SHA256)RS256(RSA-SHA256) 还有 ES256(ECDSA-SHA256)

JWT 算法列表如下

可以看到被标记为 Recommended 的只有 RS256 和 ES256。

对称加密算法

插件安装默认使用HS256对称加密算法。

HS256 使用同一个「secret_key」进行签名与验证。一旦 secret_key泄漏,就毫无安全性可言了。因此 HS256 只适合集中式认证,签名和验证都必须由可信方进行。

非对称加密算法

RS256 系列是使用 RSA 私钥进行签名,使用 RSA 公钥进行验证。

公钥即使泄漏也毫无影响,只要确保私钥安全就行。RS256 可以将验证委托给其他应用,只要将公钥给他们就行。

以下为RS系列算法生成命令,仅供参考

RS512

RS512

RS256

🚀 视频地址

不懂的同学可以了解一下视频,会有详细的说明哦

安全性

https://www.w3cschool.cn/fastapi/fastapi-cmia3lcw.html

概念

有许多方法可以处理安全性、身份认证和授权等问题。而且这通常是一个复杂而「困难」的话题。在许多框架和系统中,仅处理安全性和身份认证就会花费大量的精力和代码(在许多情况下,可能占编写的所有代码的 50% 或更多)。

Jwt 可帮助你以标准的方式轻松、快速地处理安全性,而无需研究和学习所有的安全规范。

场景

假设您在某个域中拥有后端API。并且您在另一个域或同一域的不同路径(或移动应用程序)中有一个前端。并且您希望有一种方法让前端使用用户名和密码与后端进行身份验证。我们可以使用OAuth2通过JWT来构建它。

认证流程


All versions of webman-jwt with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
workerman/webman-framework Version ^1.5
firebase/php-jwt Version ^6.10
ext-json Version *
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 php-woox/webman-jwt contains the following files

Loading the files please wait ....