| 1756 | } |
| 1757 | |
| 1758 | AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw) |
| 1759 | { |
| 1760 | const char *auth_line = apr_table_get(r->headers_in, |
| 1761 | (PROXYREQ_PROXY == r->proxyreq) |
| 1762 | ? "Proxy-Authorization" |
| 1763 | : "Authorization"); |
| 1764 | const char *t; |
| 1765 | |
| 1766 | if (!(t = ap_auth_type(r)) || ap_cstr_casecmp(t, "Basic")) |
| 1767 | return DECLINED; |
| 1768 | |
| 1769 | if (!ap_auth_name(r)) { |
| 1770 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00572) |
| 1771 | "need AuthName: %s", r->uri); |
| 1772 | return HTTP_INTERNAL_SERVER_ERROR; |
| 1773 | } |
| 1774 | |
| 1775 | if (!auth_line) { |
| 1776 | ap_note_auth_failure(r); |
| 1777 | return HTTP_UNAUTHORIZED; |
| 1778 | } |
| 1779 | |
| 1780 | if (ap_cstr_casecmp(ap_getword(r->pool, &auth_line, ' '), "Basic")) { |
| 1781 | /* Client tried to authenticate using wrong auth scheme */ |
| 1782 | ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(00573) |
| 1783 | "client used wrong authentication scheme: %s", r->uri); |
| 1784 | ap_note_auth_failure(r); |
| 1785 | return HTTP_UNAUTHORIZED; |
| 1786 | } |
| 1787 | |
| 1788 | while (*auth_line == ' ' || *auth_line == '\t') { |
| 1789 | auth_line++; |
| 1790 | } |
| 1791 | |
| 1792 | t = ap_pbase64decode(r->pool, auth_line); |
| 1793 | r->user = ap_getword_nulls (r->pool, &t, ':'); |
| 1794 | apr_table_setn(r->notes, AP_GET_BASIC_AUTH_PW_NOTE, "1"); |
| 1795 | r->ap_auth_type = "Basic"; |
| 1796 | |
| 1797 | *pw = t; |
| 1798 | |
| 1799 | return OK; |
| 1800 | } |
| 1801 | |
| 1802 | AP_DECLARE(apr_status_t) ap_get_basic_auth_components(const request_rec *r, |
| 1803 | const char **username, |
no test coverage detected