Skip to content

Commit

Permalink
Add trailing comma's
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jun 17, 2024
1 parent 914999d commit 84fc8e1
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 81 deletions.
6 changes: 4 additions & 2 deletions src/Auth/Process/WebAuthn.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,22 @@ public function process(array &$state): void
'urn:rsa:names:tc:SAML:2.0:ac:classes:FIDO';
Logger::debug('webauthn: userid: ' . $state['Attributes'][$this->stateData->usernameAttrib][0]);

$localToggle = !empty($state['Attributes'][$this->toggleAttrib]) && !empty($state['Attributes'][$this->toggleAttrib][0]);
$localToggle = !empty($state['Attributes'][$this->toggleAttrib])
&& !empty($state['Attributes'][$this->toggleAttrib][0]);

if (
$this->stateData->store->is2FAEnabled(
$state['Attributes'][$this->stateData->usernameAttrib][0],
$this->defaultEnabled,
$this->useDatabase,
$localToggle,
$this->force
$this->force,
) === false
) {
// nothing to be done here, end authprocfilter processing
return;
}

if // did we do Passwordless mode successfully before?
(
isset($state['Attributes']['internal:FIDO2PasswordlessAuthentication']) &&
Expand Down
7 changes: 5 additions & 2 deletions src/Auth/Source/Passwordless.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ public function __construct(array $info, array $config)

$this->authSourceConfig = Configuration::loadFromArray(
$config,
'authsources[' . var_export($this->authId, true) . ']'
'authsources[' . var_export($this->authId, true) . ']',
);
$this->authnContextClassRef = $this->authSourceConfig->getOptionalString(
"authncontextclassref",
'urn:rsa:names:tc:SAML:2.0:ac:classes:FIDO',
);
$this->authnContextClassRef = $this->authSourceConfig->getOptionalString("authncontextclassref", 'urn:rsa:names:tc:SAML:2.0:ac:classes:FIDO');
$moduleConfig = Configuration::getOptionalConfig('module_webauthn.php')->toArray();

$initialStateData = new StateData();
Expand Down
12 changes: 6 additions & 6 deletions src/Controller/AuthProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AuthProcess
*/
public function __construct(
Configuration $config,
Session $session
Session $session,
) {
$this->config = $config;
$this->session = $session;
Expand Down Expand Up @@ -150,7 +150,7 @@ public function main(Request $request): Response

if ($publicKey === false || sizeof($oneToken) == 0) {
throw new Exception(
"User attempted to authenticate with an unknown credential ID. This should already have been prevented by the browser!"
"User attempted to authenticate with an unknown credential ID. This should already have been prevented by the browser!",
);
}

Expand All @@ -169,7 +169,7 @@ public function main(Request $request): Response
$oneToken[1],
(int)$oneToken[4], // algo
base64_decode($request->request->get('signature')),
$debugEnabled
$debugEnabled,
);

/** Custom check: if the token was initially registered with UV, but now
Expand Down Expand Up @@ -207,7 +207,7 @@ public function main(Request $request): Response
$store->updateSignCount($oneToken[0], $counter);
} else {
throw new Exception(
"Signature counter less or equal to a previous authentication! Token cloning likely (old: $previousCounter, new: $counter)."
"Signature counter less or equal to a previous authentication! Token cloning likely (old: $previousCounter, new: $counter).",
);
}

Expand All @@ -230,12 +230,12 @@ function (WebAuthnAuthenticationEvent $authObject, array $state) {
echo $authObject->getValidateBuffer();
echo "Debug mode, not continuing to " . ($state['FIDO2WantsRegister'] ? "credential registration page." : "destination.");
},
[$authObject, $state]
[$authObject, $state],
);
} else {
if ($state['FIDO2WantsRegister']) {
$response = new RedirectResponse(
Module::getModuleURL('webauthn/webauthn?StateId=' . urlencode($stateId))
Module::getModuleURL('webauthn/webauthn?StateId=' . urlencode($stateId)),
);
} else {
$response = new RunnableResponse([Auth\ProcessingChain::class, 'resumeProcessing'], [$state]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ManageToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ManageToken
*/
public function __construct(
Configuration $config,
Session $session
Session $session,
) {
$this->config = $config;
$this->session = $session;
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/PushbackUserPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PushbackUserPass
*/
public function __construct(
Configuration $config,
Session $session
Session $session,
) {
$this->config = $config;
$this->session = $session;
Expand Down Expand Up @@ -104,7 +104,7 @@ public function main(Request $request): Response
class_alias($classname, '\SimpleSAML\Module\webauthn\Auth\Source\AuthSourceOverloader');
$overrideSource = new class (
['AuthId' => $authsourceString],
$authsources[$authsourceString]
$authsources[$authsourceString],
) extends AuthSourceOverloader
{
public function loginOverload(string $username, string $password): array
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/RegProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class RegProcess
*/
public function __construct(
Configuration $config,
Session $session
Session $session,
) {
$this->config = $config;
$this->session = $session;
Expand Down Expand Up @@ -127,7 +127,7 @@ public function main(Request $request): Response
$request->request->get('response_id'),
$request->request->get('attestation_client_data_json'),
($request->request->get('passwordless') == "on" ? $state['authenticatorAcceptabilityPasswordless'] : $state['authenticatorAcceptability2FA']),
$debugEnabled
$debugEnabled,
);
// at this point, we need to talk to the DB
/**
Expand Down Expand Up @@ -199,7 +199,7 @@ public function main(Request $request): Response
$friendlyName,
$username,
$regObject->getAAGUID(),
$regObject->getAttestationLevel()
$regObject->getAttestationLevel(),
);

// make sure $state gets the news, the token is to be displayed to the user on the next page
Expand All @@ -223,7 +223,7 @@ function (WebAuthnRegistrationEvent $regObject, string $id) {
Module::getModuleURL('webauthn/webauthn?StateId=' . urlencode($id)) . "'>";
echo "<button type='submit'>Return to previous page.</button>";
},
[$regObject, $id]
[$regObject, $id],
);
} elseif (array_key_exists('Registration', $state)) {
$response = new RedirectResponse(Module::getModuleURL('webauthn/webauthn?StateId=' . urlencode($id)));
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Registration
*/
public function __construct(
Configuration $config,
Session $session
Session $session,
) {
$this->config = $config;
$this->session = $session;
Expand Down Expand Up @@ -137,7 +137,7 @@ public function main(/** @scrutinizer ignore-unused */ Request $request): Runnab
$stateData->store = Store::parseStoreConfig($moduleConfig->getArray('store'));
} catch (Exception $e) {
$this->logger::error(
'webauthn: Could not create storage: ' . $e->getMessage()
'webauthn: Could not create storage: ' . $e->getMessage(),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Supercharged.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Supercharged extends WebAuthn
*/
public function __construct(
Configuration $config,
Session $session
Session $session,
) {
parent::__construct($config, $session);
}
Expand Down Expand Up @@ -66,7 +66,7 @@ public function main(Request $request): Template
$configUtils = new Utils\Config();
$username = str_split(
hash('sha512', $state['FIDO2Username'] . '|' . $configUtils->getSecretSalt()),
2
2,
);

$challengeEncoded = [];
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/WebAuthn.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class WebAuthn
*/
public function __construct(
Configuration $config,
Session $session
Session $session,
) {
$this->config = $config;
$this->session = $session;
Expand Down Expand Up @@ -192,7 +192,7 @@ public function main(Request $request): Template
$configUtils = new Utils\Config();
$username = str_split(
hash('sha512', $state['FIDO2Username'] . '|' . $configUtils->getSecretSalt()),
2
2,
);

$challengeEncoded = [];
Expand Down
6 changes: 3 additions & 3 deletions src/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract public function is2FAEnabled(
bool $defaultIfNx,
bool $useDatabase = true,
bool $toggle = false,
bool $force = true
bool $force = true,
): bool;

/**
Expand Down Expand Up @@ -91,7 +91,7 @@ abstract public function storeTokenData(
string $friendlyName,
string $hashedId,
string $aaguid,
string $attLevel
string $attLevel,
): bool;

/**
Expand Down Expand Up @@ -165,7 +165,7 @@ public static function parseStoreConfig($config): Store
$className = Module::resolveClass(
$config[0],
'WebAuthn\Store',
'\SimpleSAML\Module\webauthn\Store'
'\SimpleSAML\Module\webauthn\Store',
);

/**
Expand Down
18 changes: 9 additions & 9 deletions src/WebAuthn/Store/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function is2FAEnabled(
bool $defaultIfNx,
bool $useDatabase = true,
bool $toggle = false,
bool $force = true
bool $force = true,
): bool {
if (!$useDatabase) {
if ($force) {
Expand All @@ -160,7 +160,7 @@ public function is2FAEnabled(
} else {
$st2 = $this->db->read(
"SELECT COUNT(*) FROM userstatus WHERE user_id = :userId AND fido2Status = 'FIDO2Disabled'",
['userId' => $userId]
['userId' => $userId],
);
$rowCount2 = $st2->fetchColumn();
if ($rowCount2 === 1 /* explicitly disabled user in DB */) {
Expand All @@ -185,7 +185,7 @@ public function doesCredentialExist(string $credIdHex): bool
{
$st = $this->db->read(
'SELECT COUNT(*) FROM credentials WHERE credentialId = :credentialId',
['credentialId' => $credIdHex]
['credentialId' => $credIdHex],
);

$rowCount = $st->fetchColumn();
Expand Down Expand Up @@ -224,7 +224,7 @@ public function storeTokenData(
string $friendlyName,
string $hashedId,
string $aaguid,
string $attLevel
string $attLevel,
): bool {
$this->db->write(
'INSERT INTO credentials ' .
Expand All @@ -242,7 +242,7 @@ public function storeTokenData(
'hashedId' => $hashedId,
'aaguid' => $aaguid,
'attLevel' => $attLevel,
]
],
);

return true;
Expand All @@ -259,7 +259,7 @@ public function deleteTokenData(string $credentialId): bool
{
$this->db->write(
'DELETE FROM credentials WHERE credentialId = :credentialId',
['credentialId' => $credentialId]
['credentialId' => $credentialId],
);

Logger::debug('webauthn:Database - DELETED credential.');
Expand All @@ -279,7 +279,7 @@ public function updateSignCount(string $credentialId, int $signCounter): bool
{
$this->db->write(
'UPDATE credentials SET signCounter = :signCounter WHERE credentialId = :credentialId',
['signCounter' => $signCounter, 'credentialId' => $credentialId]
['signCounter' => $signCounter, 'credentialId' => $credentialId],
);

Logger::debug('webauthn:Database - UPDATED signature counter.');
Expand All @@ -300,7 +300,7 @@ public function getTokenData(string $userId): array

$st = $this->db->read(
'SELECT credentialId, credential, signCounter, friendlyName, algo, presenceLevel, isResidentKey FROM credentials WHERE user_id = :userId',
['userId' => $userId]
['userId' => $userId],
);

while ($row = $st->fetch(PDO::FETCH_NUM)) {
Expand All @@ -323,7 +323,7 @@ public function getUsernameByHashedId(string $hashedId): string
{
$st = $this->db->read(
'SELECT user_id FROM credentials WHERE hashedId = :hashId',
['hashId' => $hashedId]
['hashId' => $hashedId],
);

// return on first match, credential IDs are unique
Expand Down
2 changes: 1 addition & 1 deletion src/WebAuthn/WebAuthnAbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function __construct(
string $challenge,
string $authData,
string $clientDataJSON,
bool $debugMode = false
bool $debugMode = false,
) {
$this->scope = $scope;
$this->challenge = $challenge;
Expand Down
2 changes: 1 addition & 1 deletion src/WebAuthn/WebAuthnAuthenticationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
string $publicKey,
int $algo,
string $signature,
bool $debugMode = false
bool $debugMode = false,
) {
$this->eventType = "AUTH";
$this->credential = $publicKey;
Expand Down
Loading

0 comments on commit 84fc8e1

Please sign in to comment.