Prioritize HTTP-HOST header over SERVER-NAME when getting clientUrl (?)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 798
- Forks
- 419
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I've tried setting up phpCAS to a Docker container with the romeoz/docker-nginx-php image hosting and serving the service. When trying the simple example from /docs, the redirect URL created by the CAS_Client class is faulty, causing me to be redirected to a 404 when I'd entered my credentials to the CAS server.
I should have been redirected to the HTTP-HOST, http://192.168.99.100:8080/docs/examples/example_simple.php?ticket=XXX (for me it is this as I run docker-machine and set up the docker container to port 8080), but the URL became http://app/docs/examples/example_simple.php?ticket=XXX.
After "debugging" I found out that the _getClientUrl-function gave me the wrong url. The client url is determined by this snippet (source/CAS/Client.php:3594):
if (empty($_SERVER['SERVER_NAME'])) {
$server_url = $_SERVER['HTTP_HOST'];
} else {
$server_url = $_SERVER['SERVER_NAME'];
}
Here the server name is prioritzed over the http host, but this resulted in the problem stated above. In my application the http host should be used instead, every time. Is there a reason for this logic or is this a simple mistake?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with _getClientUrl in source/CAS/Client.php around line 3594 and reproduce the redirect using the simple example from /docs. Check how SERVER_NAME and HTTP_HOST are selected; done means the generated redirect uses the intended host and no longer leads to the reported 404.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100