登录 注册

lua-resty-session

去点 Star
其他
343
Stars
125
Forks
21
Watchers
29
Open Issues
BSD-2-Clause
许可证
Lua
语言
2014-06-05
创建时间
2026-11-09
最近更新

项目能做什么

面向 OpenResty 的 Session 库,具备灵活且安全的特性。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# lua-resty-session

**lua-resty-session** is a secure, and flexible session library for OpenResty.

## TL;DR;

- Sessions are immutable (each save generates a new session), and lockless.
- Session data is AES-256-GCM encrypted with a key derived using HKDF-SHA256
  (on FIPS-mode it uses PBKDF2 with SHA-256 instead.
- Session has a fixed size header that is protected with HMAC-SHA256 MAC with
  a key derived using HKDF-SHA256 (on FIPS-mode it uses PBKDF2 with SHA-256 instead).
- Session data can be stored in a stateless cookie or in various backend storages.
- A single session cookie can maintain multiple sessions across different audiences.

*Note:* Version 4.0.0 was a rewrite of this library with a lot of lessons learned
during the years. If you still use older version, please refer
[old documentation](https://github.com/bungle/lua-resty-session/tree/v3.10).


## Status

This library is considered production ready.


## Synopsis

```nginx
worker_processes  1;

events {
  worker_connections 1024;
}

http {
  init_by_lua_block {
    require "resty.session".init({
      remember = true,
      audience = "demo",
      secret   = "RaJKp8UQW1",
      storage  = "cookie",
    })
  }

  server {
    listen       8080;
    server_name  localhost;
    default_type text/html;

    location / {
      content_by_lua_block {
        ngx.say([[
          <html>
          <body>
            <a href=/start>Start the test</a>
          </body>
          </html>
        ]])
      }
    }

    location /start {
      content_by_lua_block {
        local session = require "resty.session".new()
        session:set_subject("OpenResty Fan")
        session:set("quote", "The quick brown fox jumps over the lazy dog")
        local ok, err = session:save()

        ngx.say(string.format([[
          <html>
          <body>
            <p>Session started (%s)</p>
            <p><a href=/started>Check if it really was</a></p>
          </body>
          </html>
        ]], err or "no error"))
      }
    }

    location /started {
      content_by_lua_block {
        local session, err = require "resty.session".start()

        ngx.say(string.format([[
          <html>
          <body>
            <p>Session was started by %s (%s)</p>
            <p><blockquote>%s</blockquote></p>
            <p><a href=/modify>Modify the session</a></p>
          </body>
          </html>
        ]],
          session:get_subject() or "Anonymous",
          err or "no error",
          session:get("quote") or "no quote"
        ))
      }
    }

    location /modify {
      content_by_lua_block {
        local session, err = require "resty.session".start()
        session:set_subject("Lua Fan")
        session:set("quote", "Lorem ipsum dolor sit amet")
        local _, err_save = session:save()

        ngx.say(string.format([[
          <html>
          <body>
            <p>Session was modified (%s)</p>
            <p><a href=/modified>Check if it is modified</a></p>
          </body>
 
阅读完整原文

项目深度分析 AI 生成

基于 OpenResty 的前置身份认证与 SSO 网关中间件 (商业发行版)

产品构想基于 lua-resty-session 封装开箱即用的 Auth Proxy / SSO 接入网关,支持 OIDC、OAuth2、SAML 等协议,将后端无状态服务快速包装为具备企业级安全 Session 的服务。
核心功能开箱即用的 Web 管理后台、主流 IdP 一键接入、基于 Cookie/Redis 的 Session 自动生命周期维护、RBAC 简易鉴权拦截。
目标用户中小型企业研发团队、缺乏网关安全自研能力的技术主管。
难度/周期中等 · 1 - 2 个月 · 成本:轻量云服务器与测试环境域名,月度开销 < $50
收费模式按实例/网关节点收取月度授权订阅费,或提供 Open-Core 商业增强版。
竞争风险市面上有 OAuth2-Proxy、Authelia 等成熟开源替代品,需在性能和特定场景轻量化上建立差异。
依据 AI推测

企业安全合规与定制化支持服务

产品构想针对使用 OpenResty 构建核心网关的金融、出海企业,提供基于 lua-resty-session 的 FIPS 模式适配、审计加固、高并发 Redis 存储集群集成咨询与 SLA 保障。
核心功能FIPS-140 合规集成指导、性能调优排障、分布式 Session 灾备方案、定制化存储驱动编写与代码审查。
目标用户有金融合规要求、高并发流量接入需求的中大型科技企业架构团队。
难度/周期低 · 按需提供,单次咨询周期 1 - 2 周 · 成本:人力时间成本为主,几乎无现金成本
收费模式按咨询人天或年度企业 SLA 支持协议($3,000 - $15,000/年)收费。
竞争风险客户群较为垂直,获客链路较长,依赖口碑和行业人脉。
依据 已验证事实

Kong / APISIX 商业化安全增强插件包

产品构想将现代化 Session 管理(v4.0 架构特性)封装为无缝兼容 Kong Gateway 或 Apache APISIX 的高阶安全插件,解决官方/开源插件中 Session 处理简陋、多应用 Audience 隔离困难的问题。
核心功能多租户/多 Audience Session 隔离支持、无感迁移旧版 Session 转换器、分布式集群防重放与主动撤销(Revocation)管理 API。
目标用户使用 Kong/APISIX 的微服务企业架构师、DevOps 团队。
难度/周期中等 · 3 - 4 周 · 成本:开发测试机器成本,月度 < $30
收费模式在网关生态市场中作为付费插件销售,或按年订阅提供插件升级与维护。
竞争风险主流网关自带官方基础 Session 插件,付费买单意愿需强依赖高阶安全场景(如跨域、多受众隔离)。
依据 尚需验证的假设
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
brg-liuwei/lua-resty-redis-session 中文介绍暂未生成
openresty session module, use redis to save session data
8 Lua
LuaDist-testing/lua-resty-session 中文介绍暂未生成
1 Lua
archoncap/lua-resty-session-1 中文介绍暂未生成
1 Lua
bjne/lua-resty-session 中文介绍暂未生成
encrypted and signed cookie session using aes256gcm and JWS
0 Lua
agui888/lua-resty-session-1 中文介绍暂未生成
0 Lua
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 2014-06-05,近 30 天仍在推送,发布过 60 个 Release
社区活跃Star 343 / Fork 125 / Issue 29(数据支持,可自行核实)
许可证BSD-2-Clause
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。