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. }
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM