Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with service param for server #34

Open
artel1992 opened this issue Oct 14, 2021 · 3 comments
Open

Problem with service param for server #34

artel1992 opened this issue Oct 14, 2021 · 3 comments

Comments

@artel1992
Copy link

My service param has port. My site has ssl but plugin add 80 port to service. Why does it happen?
Example:
my site: my.moodle.com
in service param: my.cas.com?service=https://my.moodle.com:80

@mackensen
Copy link
Contributor

The plugin doesn't add a port to the service definition, that has to be coming either from your CAS server or (more likely) Moodle itself.

@artel1992
Copy link
Author

Where I can set port in moodle? I sure that my cas server doesn't add port.

@artel1992
Copy link
Author

artel1992 commented Oct 15, 2021

so I find that moodle set port here:
/auth/cas/CAS/CAS/Client.php

private function _getClientUrl()
    {
        if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
            // explode the host list separated by comma and use the first host
            $hosts = explode(',', $_SERVER['HTTP_X_FORWARDED_HOST']);
            // see rfc7239#5.3 and rfc7230#2.7.1: port is in HTTP_X_FORWARDED_HOST if non default
            return $hosts[0];
        } else if (!empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
            $server_url = $_SERVER['HTTP_X_FORWARDED_SERVER'];
        } else {
            if (empty($_SERVER['SERVER_NAME'])) {
                $server_url = $_SERVER['HTTP_HOST'];
            } else {
                $server_url = $_SERVER['SERVER_NAME'];
            }
        }
        if (!strpos($server_url, ':')) {
            if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
                $server_port = $_SERVER['SERVER_PORT'];
            } else {
                $ports = explode(',', $_SERVER['HTTP_X_FORWARDED_PORT']);
                $server_port = $ports[0];
            }

            if ( ($this->_isHttps() && $server_port!=443)
                || (!$this->_isHttps() && $server_port!=80)
            ) {
                $server_url .= ':';
                $server_url .= $server_port;
            }
        }
        return $server_url;
    }

but I don't know what edit the var $_SERVER. Can you help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants