MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / authorize

Function authorize

modules/msrp_relay/auth.c:256–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256static int authorize(struct msrp_msg *req, str *realm, unsigned int *expires,
257 str **auth_info_hdr)
258{
259 int rc;
260 int reply_code;
261 dig_cred_t *cred;
262 struct nonce_params np;
263 HASHHEX ha1;
264 const struct digest_auth_calc *digest_calc;
265 str _;
266 const str method = str_init(AUTH_STR);
267 struct msrp_url *to;
268 str tmp;
269 str reply_hdr = {NULL, 0};
270 str reason = {NULL, 0};
271 pv_value_t passwd_pval;
272 struct digest_auth_credential auth_data;
273
274 if (req->expires) {
275 tmp = req->expires->body;
276 trim(&tmp);
277 if (str2int(&tmp, expires) < 0) {
278 LM_ERR("Expires header body is not an integer\n");
279 reply_code = 400;
280 goto err_reply;
281 }
282
283 if (auth_min_expires > 0 && *expires < auth_min_expires) {
284 LM_DBG("Received 'Expires' value not allowed\n");
285
286 reply_hdr = build_expires_hdr(MIN_EXPIRES_HDR_S,
287 MIN_EXPIRES_HDR_LEN, auth_min_expires);
288 if (!reply_hdr.s) {
289 reply_code = 403;
290 reason = str_init(REASON_SERVER_ERROR_STR);
291 goto err_reply;
292 }
293
294 reason = str_init(OUT_OF_BOUNDS_STR);
295 reply_code = 423;
296 goto err_reply;
297 } else if (auth_max_expires > 0 && *expires > auth_max_expires) {
298 LM_DBG("Received 'Expires' value not allowed\n");
299
300 reply_hdr = build_expires_hdr(MAX_EXPIRES_HDR_S,
301 MAX_EXPIRES_HDR_LEN, auth_max_expires);
302 if (!reply_hdr.s) {
303 reply_code = 403;
304 reason = str_init(REASON_SERVER_ERROR_STR);
305 goto err_reply;
306 }
307
308 reason = str_init(OUT_OF_BOUNDS_STR);
309 reply_code = 423;
310 goto err_reply;
311 }
312 } else {
313 *expires = auth_expires;

Callers 1

handle_msrp_auth_reqFunction · 0.70

Calls 10

trimFunction · 0.85
str2intFunction · 0.85
build_expires_hdrFunction · 0.85
parse_credentialsFunction · 0.85
check_dig_credFunction · 0.85
str_strcasecmpFunction · 0.85
decr_nonceFunction · 0.85
is_nonce_staleFunction · 0.85
run_msrp_auth_routeFunction · 0.85
get_digest_calcFunction · 0.85

Tested by

no test coverage detected