MCPcopy Create free account
hub / github.com/apache/httpd / add_auth_info

Function add_auth_info

modules/aaa/mod_auth_digest.c:1851–1943  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1849 */
1850
1851static int add_auth_info(request_rec *r)
1852{
1853 const digest_config_rec *conf =
1854 (digest_config_rec *) ap_get_module_config(r->per_dir_config,
1855 &auth_digest_module);
1856 digest_header_rec *resp =
1857 (digest_header_rec *) ap_get_module_config(r->request_config,
1858 &auth_digest_module);
1859 const char *ai = NULL, *nextnonce = "";
1860
1861 if (resp == NULL || !resp->needed_auth || conf == NULL) {
1862 return OK;
1863 }
1864
1865 /* 2069-style entity-digest is not supported (it's too hard, and
1866 * there are no clients which support 2069 but not 2617). */
1867
1868 /* setup nextnonce
1869 */
1870 if (conf->nonce_lifetime > 0) {
1871 /* send nextnonce if current nonce will expire in less than 30 secs */
1872 if ((r->request_time - resp->nonce_time) > (conf->nonce_lifetime-NEXTNONCE_DELTA)) {
1873 nextnonce = apr_pstrcat(r->pool, ", nextnonce=\"",
1874 gen_nonce(r->pool, r->request_time,
1875 resp->opaque, r->server, conf),
1876 "\"", NULL);
1877 if (resp->client)
1878 resp->client->nonce_count = 0;
1879 }
1880 }
1881 else if (conf->nonce_lifetime == 0 && resp->client) {
1882 const char *nonce = gen_nonce(r->pool, 0, resp->opaque, r->server,
1883 conf);
1884 nextnonce = apr_pstrcat(r->pool, ", nextnonce=\"", nonce, "\"", NULL);
1885 memcpy(resp->client->last_nonce, nonce, NONCE_LEN+1);
1886 }
1887 /* else nonce never expires, hence no nextnonce */
1888
1889
1890 /* do rfc-2069 digest
1891 */
1892 if (!apr_is_empty_array(conf->qop_list) &&
1893 !ap_cstr_casecmp(*(const char **)(conf->qop_list->elts), "none")
1894 && resp->message_qop == NULL) {
1895 /* use only RFC-2069 format */
1896 ai = nextnonce;
1897 }
1898 else {
1899 const char *resp_dig, *ha1, *a2, *ha2;
1900
1901 /* calculate rspauth attribute
1902 */
1903 ha1 = resp->ha1;
1904
1905 a2 = apr_pstrcat(r->pool, ":", resp->uri, NULL);
1906 ha2 = ap_md5(r->pool, (const unsigned char *)a2);
1907
1908 resp_dig = ap_md5(r->pool,

Callers

nothing calls this directly

Calls 5

ap_get_module_configFunction · 0.85
gen_nonceFunction · 0.85
ap_cstr_casecmpFunction · 0.85
ap_md5Function · 0.85
ap_escape_quotesFunction · 0.85

Tested by

no test coverage detected