This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Issue Fix #1180 (#1183) * Issue fix #1191 (#1192) * Issue fix #1196 (#1197) * Add 2fa authentication (#1031) * Parent + Nested validation changes (#1138) * Add migration schema for 2FA Secret user field * Add 2fa_secret field to FieldsSeeder * Create Missing 2FA Password Exception * Add googleauthenticator dependency * Add getter for User's 2FA secret * Check for otp param in login request, and login with it * Add enforce_2fa parameter to directus_settings * Create Utils endpoint and service method to generate 2fa secret * Add enforce_2fa field to roles * Add enforce_2fa field to FieldsSeeder * Change Missing2FAPasswordException error code to 111 * Change 2FA Library * Change 2fa_secret interface in FieldsSeeder * Created exception for invalid otp * Changed findUserWithCredentials to through an InvalidOTPException on otp check * Created new exception if 2fa is enforced but not enabled by user * Added function to check if 2fa is enforced for a user * Check in AuthenticationMiddleware whether 2fa is enforced and enabled for user * Add optional needs2FA field to auth token and on token refresh * Catch error if enforce_2fa column doesn't exist Fixes crash when has2FAEnforced is called on a DB that hasn't been migrated * Use relative positions for target path array to check user edit * Fix unset on payload_arr instead of payload * Change 2FA activation on login to use activate2FA endpoint * Update ItemsService.php * Issue Fix #1194 (#1195) * Issue Fix #1194 * Update comment * Valildation issue of O2M/M2O at insertion (#1198) * Fox #1201 (#1202) * Fix #1203 (#1204) * Update collections() method in types.php (#1184) There are cases when $type is not a string but an object that inherits from ObjectType. In that situation array_key_exists failing because it should get only integers or strings as a first parameter. So in order to avoid that the 'name' property of the object is used as a key. * Improve YouTube Embed Provider (#1210) Adds in detection and parsing for youtu.be shorthand URLs. * Add check for environment on bootstrap (#1215) * Fix #1186 [Create new error code for invalid login entity] (#1218) * Fix #1217 (Changing password over the CLI doesn't work) (#1220) * Feature/audio video upload (#1214) * added file meta data for audio/video * updates as per PR feedback * Fix #1207 [Permission denied issue when using translation interface] (#1221) * Bump version to v2.5.0
- Loading branch information
1 parent
77a95be
commit c698bf5
Showing
34 changed files
with
558 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
migrations/upgrades/schemas/20190614103321_add_users_2fa_secret_field.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class AddUsers2FASecretField extends AbstractMigration | ||
{ | ||
public function change() | ||
{ | ||
$table = $this->table('directus_users'); | ||
if (!$table->hasColumn('2fa_secret')) { | ||
$table->addColumn('2fa_secret', 'string', [ | ||
'limit' => 255, | ||
'null' => true, | ||
'default' => null | ||
]); | ||
|
||
$table->save(); | ||
} | ||
|
||
$collection = 'directus_users'; | ||
$field = '2fa_secret'; | ||
$checkSql = sprintf('SELECT 1 FROM `directus_fields` WHERE `collection` = "%s" AND `field` = "%s";', $collection, $field); | ||
$result = $this->query($checkSql)->fetch(); | ||
|
||
if (!$result) { | ||
$insertSqlFormat = 'INSERT INTO `directus_fields` (`collection`, `field`, `type`, `interface`, `readonly`, `hidden_detail`, `hidden_browse`) VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s");'; | ||
$insertSql = sprintf($insertSqlFormat, $collection, $field, 'string', '2fa-secret', 1, 0, 1); | ||
$this->execute($insertSql); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
migrations/upgrades/schemas/20190618190024_add_enforce_2fa_role_field.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class AddEnforce2FARoleField extends AbstractMigration | ||
{ | ||
public function up() | ||
{ | ||
$this->addSetting(); | ||
$this->addField(); | ||
} | ||
|
||
protected function addSetting() | ||
{ | ||
$table = $this->table('directus_roles'); | ||
if (!$table->hasColumn('enforce_2fa')) { | ||
$table->addColumn('enforce_2fa', 'boolean', [ | ||
'null' => true, | ||
'default' => null | ||
]); | ||
|
||
$table->save(); | ||
} | ||
} | ||
|
||
protected function addField() | ||
{ | ||
$collection = 'directus_roles'; | ||
$field = 'enforce_2fa'; | ||
$checkSql = sprintf('SELECT 1 FROM `directus_fields` WHERE `collection` = "%s" AND `field` = "%s";', $collection, $field); | ||
$result = $this->query($checkSql)->fetch(); | ||
|
||
if (!$result) { | ||
$insertSqlFormat = 'INSERT INTO `directus_fields` (`collection`, `field`, `type`, `interface`) VALUES ("%s", "%s", "%s", "%s");'; | ||
$insertSql = sprintf($insertSqlFormat, $collection, $field, 'boolean', 'toggle'); | ||
$this->execute($insertSql); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
migrations/upgrades/schemas/20190819070856_update_directus_fields_field.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class UpdateDirectusFieldsField extends AbstractMigration | ||
{ | ||
public function up() | ||
{ | ||
$this->execute(\Directus\phinx_update( | ||
$this->getAdapter(), | ||
'directus_fields', | ||
[ | ||
'readonly' => 0, | ||
'note' => 'Duration must be in seconds' | ||
], | ||
['collection' => 'directus_files', 'field' => 'duration'] | ||
)); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/core/Directus/Authentication/Exception/InvalidOTPException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Directus\Authentication\Exception; | ||
|
||
use Directus\Exception\NotFoundException; | ||
|
||
class InvalidOTPException extends NotFoundException | ||
{ | ||
const ERROR_CODE = 112; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('Invalid user OTP', static::ERROR_CODE); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/core/Directus/Authentication/Exception/Missing2FAPasswordException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Directus\Authentication\Exception; | ||
|
||
use Directus\Exception\NotFoundException; | ||
|
||
class Missing2FAPasswordException extends NotFoundException | ||
{ | ||
const ERROR_CODE = 111; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('User missing 2FA OTP', static::ERROR_CODE); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/core/Directus/Authentication/Exception/TFAEnforcedException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Directus\Authentication\Exception; | ||
|
||
use Directus\Exception\UnauthorizedException; | ||
|
||
class TFAEnforcedException extends UnauthorizedException | ||
{ | ||
const ERROR_CODE = 113; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('2FA enforced but not activated for user'); | ||
} | ||
} |
Oops, something went wrong.