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

Function authorize

modules/auth_aaa/authorize.c:73–128  ·  view source on GitHub ↗

* Authorize digest credentials */

Source from the content-addressed store, hash-verified

71 * Authorize digest credentials
72 */
73static inline int authorize(struct sip_msg* _msg, str* _realm,
74 str * _uri_user, int _hftype)
75{
76 int res;
77 auth_result_t ret;
78 struct hdr_field* h;
79 auth_body_t* cred;
80 str *uri_user;
81 str user, domain;
82
83 /* get pre_auth domain from _realm pvar (if exists) */
84 if (_realm) {
85 domain = *_realm;
86 } else {
87 /* get pre_auth domain from To/From header */
88 domain.len = 0;
89 domain.s = 0;
90 }
91
92 ret = auth_api.pre_auth(_msg, &domain, _hftype, &h, 0);
93
94 if (ret != DO_AUTHORIZATION)
95 return ret;
96
97 cred = (auth_body_t*)h->parsed;
98
99 /* get uri_user from _uri_user pvap (if exists) or
100 from To/From URI */
101 if (_uri_user) {
102 res = aaa_authorize_sterman(_msg, &cred->digest,
103 &_msg->first_line.u.request.method,
104 _uri_user);
105 } else {
106 if (get_uri_user(_msg, &uri_user) < 0) {
107 LM_ERR("To/From URI not found\n");
108 return AUTH_ERROR;
109 }
110 user.s = (char *)pkg_malloc(uri_user->len);
111 if (user.s == NULL) {
112 LM_ERR("no pkg memory left for user\n");
113 return AUTH_ERROR;
114 }
115 un_escape(uri_user, &user);
116 res = aaa_authorize_sterman(_msg, &cred->digest,
117 &_msg->first_line.u.request.method,
118 &user);
119 pkg_free(user.s);
120 }
121
122 if (res == 1) {
123 ret = auth_api.post_auth(_msg, h);
124 return ret;
125 }
126
127 return AUTH_ERROR;
128}
129
130

Callers 2

aaa_proxy_authorizeFunction · 0.70
aaa_www_authorizeFunction · 0.70

Calls 3

aaa_authorize_stermanFunction · 0.85
get_uri_userFunction · 0.85
un_escapeFunction · 0.85

Tested by

no test coverage detected