| 1185 | } |
| 1186 | |
| 1187 | bool Webserver::OAuthTokenAuth(const std::string& oauth_token, |
| 1188 | struct sq_connection* connection, struct sq_request_info* request_info) { |
| 1189 | JWTHelper::UniqueJWTDecodedToken decoded_token; |
| 1190 | Status status = JWTHelper::Decode(oauth_token, decoded_token); |
| 1191 | if (!status.ok()) { |
| 1192 | LOG(ERROR) << "Error decoding OAuth token in Authorization header, " |
| 1193 | << "Error: " << status; |
| 1194 | return false; |
| 1195 | } |
| 1196 | if (FLAGS_oauth_jwt_validate_signature) { |
| 1197 | status = ExecEnv::GetInstance()->GetOAuthHelperInstance()->Verify( |
| 1198 | decoded_token.get()); |
| 1199 | if (!status.ok()) { |
| 1200 | LOG(ERROR) << "Error verifying OAuth token in Authorization header, " |
| 1201 | << "Error: " << status; |
| 1202 | return false; |
| 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | DCHECK(!FLAGS_oauth_jwt_custom_claim_username.empty()); |
| 1207 | string username; |
| 1208 | status = JWTHelper::GetCustomClaimUsername( |
| 1209 | decoded_token.get(), FLAGS_oauth_jwt_custom_claim_username, username); |
| 1210 | if (!status.ok()) { |
| 1211 | LOG(ERROR) << "Cannot retrieve username from OAUTh token in Authorization header, " |
| 1212 | << "Error: " << status; |
| 1213 | return false; |
| 1214 | } |
| 1215 | request_info->remote_user = strdup(username.c_str()); |
| 1216 | |
| 1217 | return true; |
| 1218 | } |
| 1219 | |
| 1220 | Status Webserver::HandleBasic(struct sq_connection* connection, |
| 1221 | struct sq_request_info* request_info, vector<string>* response_headers) { |
nothing calls this directly
no test coverage detected