Compare commits

..

No commits in common. "919e5812f9bf7edfe7bdca7038a2367fc21bf2d4" and "3dd877c8379e6b8ef1deaa5e1e19eb863eec04bb" have entirely different histories.

7 changed files with 18 additions and 38 deletions

View File

@ -13,7 +13,7 @@ http {
client_max_body_size 1024M; #允许最大100k的请求体
client_body_buffer_size 1024M; #设置缓冲区大小
lua_code_cache on; #代码缓存
#lua_code_cache off; #关闭代码缓存修改lua脚本不需要重启
lua_package_path '$prefix/src/?/?.lua;$prefix/src/?.lua;/home/frankly/work/AuthPlatform/src/?/?.lua;/home/frankly/work/AuthPlatform/src/?.lua;;';
lua_package_cpath '$prefix/src/share/lib/?.so;/home/frankly/work/AuthPlatform/src/share/lib/?.so;;';
@ -52,13 +52,17 @@ http {
## 应用路径 todo 路径问题
set $APP_PATH '/home/frankly/work/AuthPlatform';
# 全局 CORS 配置 访问时允许跨域处理
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
#访问时允许跨域处理
access_by_lua_block {
ngx.header["Access-Control-Allow-Origin"] = "*";
ngx.header["Access-Control-Allow-Methods"] = "GET, POST, DELETE, PUT";
ngx.header["Access-Control-Allow-Headers"] = "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization";
ngx.header["Access-Control-Max-Age"] = 1728000;
ngx.header["Access-Control-Expose-Headers"] = "Content-Length,Content-Range";
if ngx.var.request_method == "OPTIONS" then
ngx.status = 204
ngx.exit(ngx.OK)
end
}
#OP端点配置

View File

@ -2,8 +2,6 @@ local jwt = require "resty.jwt"
local cjson = require("cjson.safe")
local jsonschema = require("jsonschema")
local conf = require("config")
local status = require("util.status")
local resp = require("util.response")
-- 定义一个JSON Schema
local schema = {

View File

@ -105,7 +105,7 @@ local function authorizatePassword(args)
-- 2.验证用户名和密码应用程序id和应用程序密钥
local code, res = oauthDao.authenticateUserPasswd(args.username, args.password)
if code ~= 0 or res == nil then
resp:response(status.USER_LOGIN_ERROR)
resp:response(status.ACCOUNT_NOT_EXIST)
return
end
print("验证用户名和密码: ", args.username)
@ -139,10 +139,9 @@ local function authorizateCode(args)
-- 1.校验必填参数验证数据是否符合json
local ok = validator.validateToken(args)
if not ok then
resp:response(status.PARAM_IS_INVALID)
resp:response(status.TOKEN_INVALID)
return
end
print("consume code:", args.code)
-- 2.校验 code 有效性
local code_data, err = authcode.consume(args.code)--, args.client_id)
if not code_data then
@ -235,9 +234,6 @@ end
function _M:token()
-- 1. 解析请求参数(支持 form-data 和 json
local args = getUriArgs()
if args == nil then
ngx.exit(ngx.HTTP_BAD_REQUEST)
end
local grant_type = args.grant_type
--print("grant_type类型: ", grant_type)
if grant_type == "password" then

View File

@ -22,9 +22,7 @@ function _M.getSystemDepartments()
ngx.exit(ngx.HTTP_FORBIDDEN)
end
local code, ret = departmentDao.getSystemDepartments()
local state = status.SUCCESS
if code ~= 0 then state = status.DATA_IS_WRONG end
resp: response(state, ret)
resp:response(code, ret)
end
--根据组织id获取组织架构信息

View File

@ -20,18 +20,6 @@ local id = snow:generateUniqueId()-- 生成ID
--max =a and b or c--a?b:c
local STATUS_CODE = {
-- 成功状态码
SUCCESS = { code = 200, message = "操作成功" },
UNKNOWN_ERROR = { code = 9999, message = "未知错误" }
}
local val = STATUS_CODE.SUCCESS
local status = val or STATUS_CODE.UNKNOWN_ERROR
local msg = status.message
ngx.say("message:"..msg)
--local openssl = require("openssl")
--
---- 生成RSA密钥对

View File

@ -13,7 +13,6 @@ function _M:json(state, message, data, http_status)
msg = status.message
end
local response = { code = code, msg = msg, result = data, timestamp = ngx.time() }
print("response:", cjson.encode(response))
return {
code = response_status,
headers = { content_type = 'application/json; charset=UTF-8' },
@ -28,7 +27,6 @@ function _M:json(state, data, http_status)
local msg = status.message
local response_status = http_status or ngx.HTTP_OK
local response = { code = code, msg = msg, result = data,timestamp = ngx.time() }
--print("response:", cjson.encode(response))
return {
code = response_status,
headers = { content_type = 'application/json; charset=UTF-8' },
@ -61,16 +59,14 @@ function _M:send(response)
ngx.header[name] = value
end
end
--print("send data:", response.body)
if response.body ~= nil then
--print("send data:", response.body)
ngx.say(response.body)
end
end
function _M:response(state, result)
local resp = self:json(state, result)
self:send(resp)
local response = self:json(state, result)
self:send(response)
end
return _M