| 804 | } |
| 805 | |
| 806 | static int fcgi_check_authn(request_rec *r) |
| 807 | { |
| 808 | const char *fn = "fcgi_check_authn"; |
| 809 | fcgi_dir_conf *dconf = ap_get_module_config(r->per_dir_config, |
| 810 | &authnz_fcgi_module); |
| 811 | const char *password = NULL; |
| 812 | const fcgi_provider_conf *conf; |
| 813 | const char *prov; |
| 814 | const char *auth_type; |
| 815 | char rspbuf[NON200_RESPONSE_BUF_LEN + 1]; /* extra byte for '\0' */ |
| 816 | apr_size_t rspbuflen = sizeof rspbuf - 1; |
| 817 | int res; |
| 818 | |
| 819 | prov = dconf && dconf->name ? dconf->name : NULL; |
| 820 | |
| 821 | if (!prov || !ap_cstr_casecmp(prov, "None")) { |
| 822 | return DECLINED; |
| 823 | } |
| 824 | |
| 825 | auth_type = ap_auth_type(r); |
| 826 | |
| 827 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, |
| 828 | APLOGNO(02516) "%s, prov %s, authoritative %s, " |
| 829 | "require-basic %s, user expr? %s type %s", |
| 830 | fn, prov, |
| 831 | dconf->authoritative ? "yes" : "no", |
| 832 | dconf->require_basic_auth ? "yes" : "no", |
| 833 | dconf->user_expr ? "yes" : "no", |
| 834 | auth_type); |
| 835 | |
| 836 | if (auth_type && !ap_cstr_casecmp(auth_type, "Basic")) { |
| 837 | if ((res = ap_get_basic_auth_pw(r, &password))) { |
| 838 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, |
| 839 | APLOGNO(02517) "%s: couldn't retrieve basic auth " |
| 840 | "password", fn); |
| 841 | if (dconf->require_basic_auth) { |
| 842 | return res; |
| 843 | } |
| 844 | password = NULL; |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | conf = apr_hash_get(fcgi_authn_providers, prov, APR_HASH_KEY_STRING); |
| 849 | if (!conf) { |
| 850 | ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, |
| 851 | APLOGNO(02518) "%s: can't find config for provider %s", |
| 852 | fn, prov); |
| 853 | return HTTP_INTERNAL_SERVER_ERROR; |
| 854 | } |
| 855 | |
| 856 | if (APLOGrdebug(r)) { |
| 857 | log_provider_info(conf, r); |
| 858 | } |
| 859 | |
| 860 | req_rsp(r, conf, password, AP_FCGI_APACHE_ROLE_AUTHENTICATOR_STR, |
| 861 | rspbuf, &rspbuflen); |
| 862 | |
| 863 | if (r->status == HTTP_OK) { |
nothing calls this directly
no test coverage detected