diff --git a/src/mod_auth_cas.c b/src/mod_auth_cas.c index 063aab1..1d78e9a 100644 --- a/src/mod_auth_cas.c +++ b/src/mod_auth_cas.c @@ -549,9 +549,18 @@ char *getCASService(const request_rec *r, const cas_cfg *c) { const apr_port_t port = r->connection->local_addr->port; const apr_byte_t ssl = isSSL(r); - const apr_uri_t *root_proxy = &c->CASRootProxiedAs; + //const apr_uri_t *root_proxy = &c->CASRootProxiedAs; + apr_uri_t *root_proxy; char *scheme, *port_str = "", *service; apr_byte_t print_port = TRUE; + apr_uri_t rp; + char *host = apr_psprintf(r->pool, "%s%s", "https://", (char *) apr_table_get(r->headers_in, "Host")); + + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "Host: %s", host); + + cas_setURL(r->pool, &rp, host); + root_proxy = &rp; + #ifdef APACHE2_0 scheme = (char *) ap_http_method(r); @@ -2131,7 +2140,10 @@ int cas_authenticate(request_rec *r) printPort = TRUE; if(c->CASRootProxiedAs.is_initialized) { - newLocation = apr_psprintf(r->pool, "%s%s%s%s", apr_uri_unparse(r->pool, &c->CASRootProxiedAs, 0), r->uri, ((r->args != NULL) ? "?" : ""), ((r->args != NULL) ? r->args : "")); + apr_uri_t rp; + char *host = apr_psprintf(r->pool, "%s%s", "https://", (char *) apr_table_get(r->headers_in, "Host")); + cas_setURL(r->pool, &rp, host); + newLocation = apr_psprintf(r->pool, "%s%s%s%s", apr_uri_unparse(r->pool, &rp, 0), r->uri, ((r->args != NULL) ? "?" : ""), ((r->args != NULL) ? r->args : "")); } else { #ifdef APACHE2_0 if(printPort == TRUE)