apereo / apereo/phpCAS

Nginx default hostname "_" forwarded to SSO server

Open
#346 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement
Dominant language
PHP
Stars
798
Forks
419
PR merge metrics
No merged PRs in 30d

Description

Default nginx config has a host name of "_"
Diff to support this is:

--- a/source/CAS/Client.php
+++ b/source/CAS/Client.php
@@ -3970,7 +3970,7 @@ class CAS_Client
         } else if (!empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
             $server_url = $_SERVER['HTTP_X_FORWARDED_SERVER'];
         } else {
-            if (empty($_SERVER['SERVER_NAME'])) {
+            if (empty($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME'] == '_') {
                 $server_url = $_SERVER['HTTP_HOST'];
             } else {
                 $server_url = $_SERVER['SERVER_NAME'];

Obviously you need to fix the config sample in the examples folder as well:

--- a/docs/examples/config.example.php
+++ b/docs/examples/config.example.php
@@ -63,11 +63,13 @@ $driver_options = '';
 ///////////////////////////////////////////

 // Generating the URLS for the local cas example services for proxy testing
+$sname = (empty($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME']=='_' )?$_SERVER['HOST_NAME']:$_SERVER['SERVER_NAME'];
 if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
-    $curbase = 'https://' . $_SERVER['SERVER_NAME'];
+    $curbase = 'https://' . $sname;
 } else {
-    $curbase = 'http://' . $_SERVER['SERVER_NAME'];
+    $curbase = 'http://' . $sname;
 }
+unset($sname);
 if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
     $curbase .= ':' . $_SERVER['SERVER_PORT'];
 }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading source/CAS/Client.php around the server URL selection and docs/examples/config.example.php around the local CAS example URL setup. Compare both paths with the reported nginx hostname value and verify that the generated SSO and example-service URLs use the forwarded host rather than "_"; the issue is done when both affected configurations behave correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
nginx, php
Domain
authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.