openresty 几个插件使用,


1. jwt   
  1. opm get SkyLothar/lua-resty-jwt
  2. cookie  
  1. opm get p0pr0ck5/lua-resty-cookie
  3. http  
  1. opm get agentzh/lua-resty-http
  4. template  
  1. bungle/lua-resty-template
  5. 一个简单例子   集合jwt   cookie 可以做安全认证处理,以及动态token 生成 jwt、cookie
  1. location / {
  2. access_by_lua_block {
  3. local ck = require("resty.cookie");
  4. local cookie, err = ck:new();
  5. local jwt = require "resty.jwt"
  6. local jwt_token = jwt:sign(
  7. "lua-resty-jwt",
  8. {
  9. header={typ="JWT", alg="HS256"},
  10. payload={foo="bar"}
  11. }
  12. )
  13. -- ngx.say(ngx.header)
  14. ngx.header.token_name = "dalong demo app";
  15. cookie:set({key= "dalongapp",value = jwt_token})
  16. }
  17. proxy_pass http://XXXXXXXX;
  18. }
 

相关内容

    暂无相关文章