在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):x25/luajwt开源软件地址(OpenSource Url):https://github.com/x25/luajwt开源编程语言(OpenSource Language):Lua 100.0%开源软件介绍(OpenSource Introduction):luajwtJSON Web Tokens for Lua $ sudo luarocks install --server=http://rocks.moonscript.org luajwt UsageBasic usage: local jwt = require "luajwt"
local key = "example_key"
local payload = {
iss = "12345678",
nbf = os.time(),
exp = os.time() + 3600,
}
-- encode
local alg = "HS256" -- (default)
local token, err = jwt.encode(payload, key, alg)
-- token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIx(cutted)...
-- decode and validate
local validate = true -- validate signature, exp and nbf (default: true)
local decoded, err = jwt.decode(token, key, validate)
-- decoded: { ["iss"] = 12345678, ["nbf"] = 1405108000, ["exp"] = 1405181916 }
-- only decode
local unsafe, err = jwt.decode(token)
-- unsafe: { ["iss"] = 12345678, ["nbf"] = 1405108000, ["exp"] = 1405181916 }
An openresty/nginx lua jwt auth example:
Generate token and try: $ curl your.server/auth?jwt=TOKEN AlgorithmsHMAC
LicenseMIT |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论