Skip to content

Commit

Permalink
Support force_ssl option in admin plugin #1479
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jul 13, 2018
1 parent e87217a commit 9a1dec5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
1. [](#bugfix)
* Force `html` for markdown preview [grav#2066](https://github.com/getgrav/grav/issues/2066)
* Add missing `authorizeTask()` checks in controller [#1483](https://github.com/getgrav/grav/issues/1483)
* Add support for `force_ssl` to admin URLs [#1479](https://github.com/getgrav/grav-plugin-admin/issues/1479)

# v1.8.5
## 06/20/2018
Expand Down
10 changes: 10 additions & 0 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,16 @@ protected function initializeController($task, $post)
*/
public function onPagesInitialized()
{
$config = $this->config;

// Force SSL with redirect if required
if ($config->get('system.force_ssl')) {
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
$url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$this->grav->redirect($url);
}
}

$this->session = $this->grav['session'];

// Set original route for the home page.
Expand Down

0 comments on commit 9a1dec5

Please sign in to comment.