Skip to content

Commit

Permalink
Remove crypto-module and use libraries instead
Browse files Browse the repository at this point in the history
Remove the crypto-module to reduce amount of dependencies and use hash_hmac
with SHA256 instead.

refs #3769
  • Loading branch information
majentsch committed Jul 26, 2013
1 parent 3ff0c0f commit 2807982
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 67 deletions.
9 changes: 4 additions & 5 deletions library/Icinga/Authentication/Backend/DbUserBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

namespace Icinga\Authentication\Backend;

use Icinga\Util\Crypto as Crypto;
use Icinga\Authentication\User as User;
use Icinga\Authentication\UserBackend;
use Icinga\Authentication\Credentials;
Expand Down Expand Up @@ -110,10 +109,10 @@ public function authenticate(Credentials $credential){
->select()->from($this->userTable)
->where($this->USER_NAME_COLUMN.' = ?',$credential->getUsername())
->where($this->ACTIVE_COLUMN. ' = ?',true)
->where($this->PASSWORD_COLUMN. ' = ?',Crypto::hashPassword(
$credential->getPassword(),
$this->getUserSalt($credential->getUsername())
))
->where($this->PASSWORD_COLUMN. ' = ?',hash_hmac("sha256",
$this->getUserSalt($credential->getUsername()),
$credential->getPassword())
)
->query()->fetch();
if(!empty($res)){
$this->updateLastLogin($credential->getUsername());
Expand Down
57 changes: 0 additions & 57 deletions library/Icinga/Util/Crypto.php

This file was deleted.

13 changes: 8 additions & 5 deletions test/php/library/Icinga/Authentication/DbUserBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
require_once("../../library/Icinga/Application/Config.php");
require_once("../../library/Icinga/Authentication/Credentials.php");
require_once("../../library/Icinga/Authentication/Backend/DbUserBackend.php");
require_once("../../library/Icinga/Util/Crypto.php");
require_once("../../library/Icinga/Authentication/User.php");

use Icinga\Authentication\Backend\DbUserBackend;
Expand Down Expand Up @@ -80,7 +79,10 @@ protected function setUp()
)
);

// TODO: Fetch config folder from somewhere instead of defining it statically.
/*
* TODO: Fetch config folder from somewhere instead of defining it statically, or this test
* will break when the path changes
*/
Config::$configDir = "/vagrant/config";
$config = Config::app('authentication')->users;
$config->table = $this->testTable;
Expand Down Expand Up @@ -126,9 +128,10 @@ private function setUpDb($db){
$usr = $this->users[$i];
$data = Array(
$this->USER_NAME_COLUMN => $usr[$this->USER_NAME_COLUMN],
$this->PASSWORD_COLUMN => Crypto::hashPassword(
$usr[$this->PASSWORD_COLUMN],
$usr[$this->SALT_COLUMN]),
$this->PASSWORD_COLUMN => hash_hmac("sha256",
$usr[$this->SALT_COLUMN],
$usr[$this->PASSWORD_COLUMN]
),
$this->ACTIVE_COLUMN => $usr[$this->ACTIVE_COLUMN],
$this->SALT_COLUMN => $usr[$this->SALT_COLUMN]
);
Expand Down

0 comments on commit 2807982

Please sign in to comment.