diff --git a/Server/Application.cpp b/Server/Application.cpp index dc59ef8..5235865 100644 --- a/Server/Application.cpp +++ b/Server/Application.cpp @@ -138,11 +138,6 @@ Application::Application(const std::string &path) session.reply(std::move(s)); }); - m_router->insert("/trigger-ci.hook", [this](HttpSession &session, const Request &request, const boost::urls::matches &matches) { - LOG(info) << "webhook: " << request; - session.reply(ServiceLogic::make_200(request, "Main page\n", "text/html")); - }); - m_router->insert("/notify", [this](HttpSession &session, const Request &request, const boost::urls::matches &matches) { auto corp = Amass::Singleton::instance(); corp->notify(request); diff --git a/Server/conf/server.conf b/Server/conf/server.conf index 729cc1c..a5b91be 100644 --- a/Server/conf/server.conf +++ b/Server/conf/server.conf @@ -20,21 +20,26 @@ location /日常随笔 { access_by_lua_file lua/authentication.lua; } -location = /blog/profile { - content_by_lua_file lua/profile.lua; -} - -location ^~ /api/v1/login { - # 应用限流规则,使用名称为 one 的限流区域,允许突发请求数为 5,不延迟处理 - limit_req zone=one burst=5 nodelay; - default_type 'application/json; charset=utf-8'; - content_by_lua_file lua/login.lua; -} - location ^~ /api/v1/search/ { proxy_pass http://meilisearch/; } +location ^~ /api/v1/auth { + # 应用限流规则,使用名称为 one 的限流区域,允许突发请求数为 5,不延迟处理 + limit_req zone=one burst=5 nodelay; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header x-wiz-real-ip $remote_addr; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Port $server_port; + proxy_pass http://wt; +} + location ~ ^/api/v1/.*$ { proxy_pass http://local; } @@ -84,10 +89,6 @@ location = /search/website_collections { content_by_lua_file lua/request_website_collections.lua; } -location ~ /trigger-ci.+$ { - proxy_pass http://local; -} - location ~ /notify.*$ { proxy_pass http://local; } diff --git a/Server/lua/initialize.lua b/Server/lua/initialize.lua index d7e4ac3..d0dc028 100644 --- a/Server/lua/initialize.lua +++ b/Server/lua/initialize.lua @@ -1,18 +1,3 @@ -require "resty.session".init({ - cookie_http_only=true, - remember = true, - storage = "cookie", - remember_rolling_timeout = 7200, -}) - app_version="0.0.1" private_folder = {"个人笔记"}; - -user_infomation = { - name = "Amass", - qq = "168062547", - phone = "15217052880", - user = user -}; -user_password = "luo19961030"; diff --git a/Server/lua/login.lua b/Server/lua/login.lua deleted file mode 100644 index cedd556..0000000 --- a/Server/lua/login.lua +++ /dev/null @@ -1,60 +0,0 @@ -local cjson = require "cjson" - -local function add_domain(cookies, key, domain) - if type(cookies) == "string" then -- 确保 set_cookies 是一个表 - cookies = { cookies } - end - - local new_cookies = {} -- 查找并修改名为 'remember' 的 Cookie - for _, cookie in ipairs(cookies) do - local cookie_key, value = string.match(cookie, "^%s*(.-)%s*=%s*(.-)%s*;") - if cookie_key == key then - local new_cookie = value .. "; Domain=" .. domain .. "; Path=/; HttpOnly; SameSite=Lax" - table.insert(new_cookies, key.."=" .. new_cookie) - else - table.insert(new_cookies, cookie) - end - end - - return new_cookies; -end - -ngx.req.read_body() -local body = ngx.req.get_body_data() - -if not body then - ngx.status = ngx.HTTP_BAD_REQUEST - ngx.say("No body found") - return -end - -local ok, json_data = pcall(cjson.decode, body) -if not ok then - ngx.status = ngx.HTTP_BAD_REQUEST - ngx.say("Invalid JSON") - return -end - -local user_account = json_data.account -local user_password = json_data.password - -local reply = {} - -local session = require "resty.session".start() - -local accounts = require("lua/accounts") -local credentials = accounts.credentials() -if credentials and credentials[user_account] == user_password then - reply.status = 0 - reply.message = "登录成功" - session:set("account", user_account) - session:set("authenticated", true) - session:save() - - ngx.header["Set-Cookie"] = add_domain(ngx.header["Set-Cookie"], "remember", ".amass.fun"); -else - reply.status = -100 - reply.message = "登录失败" -end - -ngx.say(cjson.encode(reply)) diff --git a/Server/lua/profile.lua b/Server/lua/profile.lua deleted file mode 100755 index 92b9b3d..0000000 --- a/Server/lua/profile.lua +++ /dev/null @@ -1,20 +0,0 @@ -local cjson = require "cjson" -local session = require"resty.session".open() - -local response = {} -if (session == nil or session.data.identify == nil) then - response.code = 1 - response.message = "未登录,session is nil." - ngx.say(cjson.encode(response)); - return -else - if (session.data.identify ~= "myself") then - response.code = 1 - response.message = "未登录,identify:" .. session.data.identify - else - response.code = 0 - response.user = user_infomation - end - ngx.say(cjson.encode(response)); -end -