comparison mod_http_oauth2/mod_http_oauth2.lua @ 4259:721b528c01e1

mod_http_oauth2: Remove unnecessary redirect uri check
author Kim Alvefur <zash@zash.se>
date Sat, 21 Nov 2020 23:03:47 +0100
parents cc712899becd
children c539334dd01a
comparison
equal deleted inserted replaced
4258:cc712899becd 4259:721b528c01e1
89 89
90 function grant_type_handlers.authorization_code(params) 90 function grant_type_handlers.authorization_code(params)
91 if not params.client_id then return oauth_error("invalid_request", "missing 'client_id'"); end 91 if not params.client_id then return oauth_error("invalid_request", "missing 'client_id'"); end
92 if not params.client_secret then return oauth_error("invalid_request", "missing 'client_secret'"); end 92 if not params.client_secret then return oauth_error("invalid_request", "missing 'client_secret'"); end
93 if not params.code then return oauth_error("invalid_request", "missing 'code'"); end 93 if not params.code then return oauth_error("invalid_request", "missing 'code'"); end
94 --if not params.redirect_uri then return oauth_error("invalid_request", "missing 'redirect_uri'"); end
95 if params.scope and params.scope ~= "" then 94 if params.scope and params.scope ~= "" then
96 return oauth_error("invalid_scope", "unknown scope requested"); 95 return oauth_error("invalid_scope", "unknown scope requested");
97 end 96 end
98 97
99 local client, err = clients:get(params.client_id); 98 local client, err = clients:get(params.client_id);
106 if not code or type(code) ~= "table" or os.difftime(os.time(), code.issued) > 900 then 105 if not code or type(code) ~= "table" or os.difftime(os.time(), code.issued) > 900 then
107 return oauth_error("invalid_client", "incorrect credentials"); 106 return oauth_error("invalid_client", "incorrect credentials");
108 end 107 end
109 assert(codes:set(params.client_id, params.code, nil)); 108 assert(codes:set(params.client_id, params.code, nil));
110 109
111 if client.redirect_uri and client.redirect_uri ~= params.redirect_uri then
112 return oauth_error("invalid_client", "incorrect 'redirect_uri'");
113 end
114 110
115 return json.encode(new_access_token(code.granted_jid, nil, nil)); 111 return json.encode(new_access_token(code.granted_jid, nil, nil));
116 end 112 end
117 113
118 local function check_credentials(request) 114 local function check_credentials(request)