openresty 几个插件使用

时间:2017-06-18 21:12:42   收藏:0   阅读:1076
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. }
 

原文:http://www.cnblogs.com/rongfengliang/p/7045366.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!