Comparison

plugins/mod_tokenauth.lua @ 12952:a668bc1aa39d

mod_tokenauth: Log error when token validation fails
author Matthew Wild <mwild1@gmail.com>
date Tue, 21 Mar 2023 14:04:39 +0000
parent 12938:055b03d3059b
child 12953:ebe3b2f96cad
comparison
equal deleted inserted replaced
12951:4cc0785f960e 12952:a668bc1aa39d
87 end 87 end
88 88
89 function get_token_info(token) 89 function get_token_info(token)
90 local token_id, token_user, token_host = parse_token(token); 90 local token_id, token_user, token_host = parse_token(token);
91 if not token_id then 91 if not token_id then
92 module:log("warn", "Failed to verify access token: %s", token_user);
92 return nil, "invalid-token-format"; 93 return nil, "invalid-token-format";
93 end 94 end
94 return _get_parsed_token_info(token_id, token_user, token_host); 95 return _get_parsed_token_info(token_id, token_user, token_host);
95 end 96 end
96 97
97 function get_token_session(token, resource) 98 function get_token_session(token, resource)
98 local token_id, token_user, token_host = parse_token(token); 99 local token_id, token_user, token_host = parse_token(token);
99 if not token_id then 100 if not token_id then
101 module:log("warn", "Failed to verify access token: %s", token_user);
100 return nil, "invalid-token-format"; 102 return nil, "invalid-token-format";
101 end 103 end
102 104
103 local token_info, err = _get_parsed_token_info(token_id, token_user, token_host); 105 local token_info, err = _get_parsed_token_info(token_id, token_user, token_host);
104 if not token_info then return nil, err; end 106 if not token_info then return nil, err; end
114 116
115 117
116 function revoke_token(token) 118 function revoke_token(token)
117 local token_id, token_user, token_host = parse_token(token); 119 local token_id, token_user, token_host = parse_token(token);
118 if not token_id then 120 if not token_id then
121 module:log("warn", "Failed to verify access token: %s", token_user);
119 return nil, "invalid-token-format"; 122 return nil, "invalid-token-format";
120 end 123 end
121 if token_host ~= module.host then 124 if token_host ~= module.host then
122 return nil, "invalid-host"; 125 return nil, "invalid-host";
123 end 126 end