Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/Auth/Source/Discourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ public function __construct(array $info, array $config)
* @param array &$state Information about the current authentication.
* @return void
*/
public function authenticate(&$state)
public function authenticate(array &$state): void
{
assert(is_array($state));

// We are going to need the authId in order to retrieve this authentication source later
$state[self::AUTHID] = $this->authId;

$nonce = hash('sha512', mt_rand());
$nonce = hash('sha512', (string) mt_rand());
$state['authdiscourse:nonce'] = $nonce;

$stateID = Auth\State::saveState($state, self::STAGE_INIT);
Expand Down Expand Up @@ -123,7 +121,7 @@ public function finalStep(array &$state): void
}

// validate sso
if(hash_hmac('sha256', urldecode($sso), $this->secret) !== $sig){
if (hash_hmac('sha256', urldecode($sso), $this->secret) !== $sig) {
throw new Error\NotFound();
}

Expand All @@ -132,7 +130,7 @@ public function finalStep(array &$state): void
parse_str(base64_decode($sso), $query);

// verify nonce with generated nonce during authenticate function
if($query['nonce'] != $state['authdiscourse:nonce']){
if ($query['nonce'] != $state['authdiscourse:nonce']) {
throw new Error\NotFound();
}

Expand Down