Skip to content
This repository was archived by the owner on Aug 27, 2021. It is now read-only.

Commit a285693

Browse files
committed
fix bug logout was probably never working, compatibility with Piwik 3
1 parent 68e5281 commit a285693

File tree

5 files changed

+46
-42
lines changed

5 files changed

+46
-42
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## Changelog
22

3-
* 3.0.0 Compatibility with Piwik 3.0
3+
* 3.0.0
4+
- Compatibility with Piwik 3.0
5+
- Fix logout feature
46
* 1.0.4 - Support for LemonLDAP::ng and `HTTP_AUTH_USER`
57
* 1.0.3 - Fixing regression w/ Piwik 2.15 when authenticating by token auth or by username/password (w/o an HTTP server).
68
* 1.0 - First public release [compatible with Piwik 2](http://piwik.org/blog/2013/12/piwik-2-0-release-announced-biggest-best-release-yet/)

Controller.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
*/
99
namespace Piwik\Plugins\LoginHttpAuth;
1010

11-
use Piwik\Session;
1211
use Piwik\View;
1312

1413
class Controller extends \Piwik\Plugins\Login\Controller
1514
{
1615
public function logmeout()
1716
{
1817
// Effectively log out of Http auth
19-
$settings = new Settings('LoginHttpAuthPlugin');
18+
$settings = new SystemSettings('LoginHttpAuth');
2019
header('WWW-Authenticate: Basic realm="'. $settings->authName->getValue() .'"');
2120
header('HTTP/1.0 401 Unauthorized');
2221
self::clearSession();

LoginHttpAuth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class LoginHttpAuth extends \Piwik\Plugin
1717
{
18-
public function getListHooksRegistered()
18+
public function registerEvents()
1919
{
2020
return array(
2121
'Request.initAuthenticationObject' => 'initAuthenticationObject',

Settings.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

SystemSettings.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Piwik - free/libre analytics platform
4+
*
5+
* @link http://piwik.org
6+
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7+
*/
8+
9+
namespace Piwik\Plugins\LoginHttpAuth;
10+
11+
use Piwik\Settings\Setting;
12+
use Piwik\Settings\FieldConfig;
13+
14+
/**
15+
* Defines Settings for LoginHttpAuth.
16+
*
17+
* Usage like this:
18+
* $settings = new SystemSettings();
19+
* $settings->metric->getValue();
20+
* $settings->description->getValue();
21+
*/
22+
class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings
23+
{
24+
/** @var Setting */
25+
public $authName;
26+
27+
protected function init()
28+
{
29+
$this->authName = $this->createAuthNameSetting();
30+
}
31+
32+
private function createAuthNameSetting()
33+
{
34+
return $this->makeSetting('authName', $default = 'Piwik', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
35+
$field->title = 'Authentication realm';
36+
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
37+
$field->uiControlAttributes = array('size' => 15);
38+
$field->description = 'Use this value for the AuthName directive in .htaccess.';
39+
});
40+
}
41+
}

0 commit comments

Comments
 (0)