Code Monkey home page Code Monkey logo

Comments (3)

sniper00 avatar sniper00 commented on August 16, 2024

Moon不直接支持https, HTTPS需要用代理,可以看下wiki

https://github.com/sniper00/moon/wiki/Http#httpclient-http%E8%BD%AChttps%E6%AD%A3%E5%90%91%E4%BB%A3%E7%90%86%E9%85%8D%E7%BD%AE

示例

--httpsGoogle登录令牌认证
local function GoogleTokenVerify(token, userId)
    
    local url = string.format("https://oauth2.googleapis.com")
    local response = httpc.get(url, {
        path = string.format("/tokeninfo?id_token=%s", token),
        proxy = "http://127.0.0.1:8443"  -- 这里设置nginx http->https 正向代理
    })
    if response == nil or response.status_code ~= 200 or response.content == nil then 
        return 1
    end

    local jsonStr = json.decode(response.content)
    if jsonStr == nil then 
        return 2
    end

    if jsonStr["sub"] == nil or jsonStr["sub"] ~= userId then 
        return 3
    end

    return 0
end

from moon.

lonag avatar lonag commented on August 16, 2024

好吧

from moon.

sniper00 avatar sniper00 commented on August 16, 2024

好吧

主要原因是带上 OpenSSL 编译,会增加编译复杂度,使用nginx更加简洁高效, 并且线上环境一般都会依赖nginx。开发环境一般在内网部署一个,可以项目组共用。

from moon.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.