Skip to content

Conversation

@syntaxerrormmm
Copy link

No description provided.

@stephdl
Copy link
Contributor

stephdl commented Dec 1, 2016

your brilliant solution could have a $path and $url customisable (if the path is not 'moodle' and also if the sysadmin wants another url). So I would propose that you rebase your work on the PR #12 (once merged) and make it adjustable.

you can ping me if you want to know but it is no more than a

my $url = $moodle{'url'} || '.\$_SERVER[\"HTTP_HOST\"]';

in root/etc/e-smith/templates/var/www/moodle/web/config.php/10base

@syntaxerrormmm
Copy link
Author

syntaxerrormmm commented Dec 1, 2016

So I would propose that you rebase your work on the PR #12 (once merged) and make it adjustable.

I would like to propose a different approach on configuration parameters. I envision these ones:

  • A route parameter, which can be used both for complete domains or as path to the local webserver
  • A secure boolean to provide SSL or not (respectively).

Pseudocode should be something like:

my $url = "'" . $moodle{'route'} . "'" ;
if ($moodle{'route'} =~ /^\//) {
  $url = "\$_SERVER[\"HTTP_POST\"] . '" . $moodle{'route'} . "'";
}
my $proto = 'http://';
if ($moodle{'secure'}) {
  $proto = 'https://';
}

# ...
\$CFG->wwwroot   = '$proto' . $url;

Obviuosly this needs testing.

And this would be probably needs to be revised if and when we implement vhosts.

@stephdl
Copy link
Contributor

stephdl commented Dec 1, 2016

I'm not sure to offer the http protocol is a good point, we should enforce the security by a mandatory https, of course IMHO

For your 'route' property i don't catch your idea, what will be the default value of 'route'. A good habit in the e-smith database is to give a default value, either by a value set in the default configuration database or directly in the code.

You are right the next nfr are the virtualhost.....you should set up a new issue on github

@syntaxerrormmm
Copy link
Author

I'm not sure to offer the http protocol is a good point, we should enforce the security by a mandatory https, of course IMHO

Yeah, but we need to have some machinery to choose (if possible) which SSL certificate to use.

For your 'route' property i don't catch your idea

Basically, you may use route in two different ways:

  • route = host.domain.ext or route = host.domain.ext/moodle-dir to bind the service only to that name, also specifying a different path for the Moodle platform;
  • route = /moodle-dir if you want to serve a different path for Moodle and this would be served for any resolvable and routable addresses.

A good habit in the e-smith database is to give a default value

The default from my point of view may be:

route = /moodle
secure = yes

@stephdl
Copy link
Contributor

stephdl commented Dec 1, 2016

The default from my point of view may be:
route = /moodle
secure = yes

should be
secure = enabled

Ok I got your point and I understand better your way, I fear that the '/' of /moodle can be forgotten and drives to errors however we can use only one property instead of two if we want to create the virtualhost.

Maybe we can create a validator if the '/' is missing and if there is no '.' to add '/' at the beginning.

can you have a go on the code ?

@syntaxerrormmm
Copy link
Author

can you have a go on the code ?

Not now, but will do ASAP. Could you please point documentation on how to implement the validator, please?

@stephdl
Copy link
Contributor

stephdl commented Dec 1, 2016

if (($route !~ m/./) && ($route !~ m/^//)) {
$route = '/'.$route;
}

or better I do love the oneliner

$route = '/'.$route if (($route !~ m/./) && ($route !~ m/^//));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants