On 21 December 2016 at 11:22, David Hawes <dha...@vt.edu> wrote:
...
> I've attached a horrible, inflexible, mostly untested and probably
> buggy patch against git master that should rewrite the Host header to
> the service URL. Let me know if it works for your case.

The previous patch probably won't work. This one has the same caveats
as above, but it works on my test machine.

-- 
- CAS gitter chatroom: https://gitter.im/apereo/cas
- CAS mailing list guidelines: https://apereo.github.io/cas/Mailing-Lists.html
- CAS documentation website: https://apereo.github.io/cas
- CAS project website: https://github.com/apereo/cas
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-user+unsubscr...@apereo.org.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/CAAgu-wC4K9dLioJN8Ey_2wR4tzoXNbQgGg59dpQJWvk8nxF3NA%40mail.gmail.com.
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)

Reply via email to