Patch to Put: Policies API

This commit is contained in:
Matej Bačo
2026-05-20 12:34:01 +02:00
parent 5df3280131
commit d3c7fabdcc
10 changed files with 29 additions and 39 deletions
@@ -28,7 +28,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/auth-methods/:methodId')
->httpAlias('/v1/projects/:projectId/auth/:methodId')
->desc('Update project auth method status')
@@ -26,7 +26,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/policies/membership-privacy')
->httpAlias('/v1/projects/:projectId/auth/memberships-privacy')
->desc('Update membership privacy policy')
@@ -50,11 +50,11 @@ class Update extends Action
)
],
))
->param('userId', null, new Boolean(), 'Set to true if you want make user ID visible to all team members, or false to hide it.', optional: true)
->param('userEmail', null, new Boolean(), 'Set to true if you want make user email visible to all team members, or false to hide it.', optional: true)
->param('userPhone', null, new Boolean(), 'Set to true if you want make user phone number visible to all team members, or false to hide it.', optional: true)
->param('userName', null, new Boolean(), 'Set to true if you want make user name visible to all team members, or false to hide it.', optional: true)
->param('userMFA', null, new Boolean(), 'Set to true if you want make user MFA status visible to all team members, or false to hide it.', optional: true)
->param('userId', false, new Boolean(), 'Set to true if you want make user ID visible to all team members, or false to hide it.')
->param('userEmail', false, new Boolean(), 'Set to true if you want make user email visible to all team members, or false to hide it.')
->param('userPhone', false, new Boolean(), 'Set to true if you want make user phone number visible to all team members, or false to hide it.')
->param('userName', false, new Boolean(), 'Set to true if you want make user name visible to all team members, or false to hide it.')
->param('userMFA', false, new Boolean(), 'Set to true if you want make user MFA status visible to all team members, or false to hide it.')
->inject('response')
->inject('dbForPlatform')
->inject('project')
@@ -64,11 +64,11 @@ class Update extends Action
}
public function action(
?bool $userId,
?bool $userEmail,
?bool $userPhone,
?bool $userName,
?bool $userMFA,
bool $userId,
bool $userEmail,
bool $userPhone,
bool $userName,
bool $userMFA,
Response $response,
Database $dbForPlatform,
Document $project,
@@ -77,21 +77,11 @@ class Update extends Action
): void {
$auths = $project->getAttribute('auths', []);
if ($userId !== null) {
$auths['membershipsUserId'] = $userId;
}
if ($userEmail !== null) {
$auths['membershipsUserEmail'] = $userEmail;
}
if ($userPhone !== null) {
$auths['membershipsUserPhone'] = $userPhone;
}
if ($userName !== null) {
$auths['membershipsUserName'] = $userName;
}
if ($userMFA !== null) {
$auths['membershipsMfa'] = $userMFA;
}
$auths['membershipsUserId'] = $userId;
$auths['membershipsUserEmail'] = $userEmail;
$auths['membershipsUserPhone'] = $userPhone;
$auths['membershipsUserName'] = $userName;
$auths['membershipsMfa'] = $userMFA;
$updates = new Document([
'auths' => $auths,
@@ -26,7 +26,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/policies/password-dictionary')
->httpAlias('/v1/projects/:projectId/auth/password-dictionary')
->desc('Update password dictionary policy')
@@ -50,7 +50,7 @@ class Update extends Action
)
],
))
->param('enabled', null, new Boolean(), 'Toggle password dictionary policy. Set to true if you want password change to block passwords in the dictionary, or false to allow them. When changing this policy, existing passwords remain valid.')
->param('enabled', false, new Boolean(), 'Toggle password dictionary policy. Set to true if you want password change to block passwords in the dictionary, or false to allow them. When changing this policy, existing passwords remain valid.')
->inject('response')
->inject('dbForPlatform')
->inject('project')
@@ -27,7 +27,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/policies/password-history')
->httpAlias('/v1/projects/:projectId/auth/password-history')
->desc('Update password history policy')
@@ -26,7 +26,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/policies/password-personal-data')
->httpAlias('/v1/projects/:projectId/auth/personal-data')
->desc('Update password personal data policy')
@@ -51,7 +51,7 @@ class Update extends Action
],
))
// TODO: Split into more toggles, simiplar to membership privacy policy
->param('enabled', null, new Boolean(), 'Toggle password personal data policy. Set to true if you want to block passwords including user\'s personal data, or false to allow it. When changing this policy, existing passwords remain valid.')
->param('enabled', false, new Boolean(), 'Toggle password personal data policy. Set to true if you want to block passwords including user\'s personal data, or false to allow it. When changing this policy, existing passwords remain valid.')
->inject('response')
->inject('dbForPlatform')
->inject('project')
@@ -26,7 +26,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/policies/session-alert')
->httpAlias('/v1/projects/:projectId/auth/session-alerts')
->desc('Update session alert policy')
@@ -50,7 +50,7 @@ class Update extends Action
)
],
))
->param('enabled', null, new Boolean(), 'Toggle session alert policy. Set to true if you want users to receive email notifications when a sessions are created for their users, or false to not send email alerts.')
->param('enabled', false, new Boolean(), 'Toggle session alert policy. Set to true if you want users to receive email notifications when a sessions are created for their users, or false to not send email alerts.')
->inject('response')
->inject('dbForPlatform')
->inject('project')
@@ -26,7 +26,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/policies/session-duration')
->httpAlias('/v1/projects/:projectId/auth/duration')
->desc('Update session duration policy')
@@ -26,7 +26,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/policies/session-invalidation')
->httpAlias('/v1/projects/:projectId/auth/session-invalidation')
->desc('Update session invalidation policy')
@@ -50,7 +50,7 @@ class Update extends Action
)
],
))
->param('enabled', null, new Boolean(), 'Toggle session invalidation policy. Set to true if you want password change to invalidate all sessions of an user, or false to keep sessions active.')
->param('enabled', false, new Boolean(), 'Toggle session invalidation policy. Set to true if you want password change to invalidate all sessions of an user, or false to keep sessions active.')
->inject('response')
->inject('dbForPlatform')
->inject('project')
@@ -27,7 +27,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/policies/session-limit')
->httpAlias('/v1/projects/:projectId/auth/max-sessions')
->desc('Update session limit policy')
@@ -27,7 +27,7 @@ class Update extends Action
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) // Should be PUT
->setHttpPath('/v1/project/policies/user-limit')
->httpAlias('/v1/projects/:projectId/auth/limit')
->desc('Update user limit policy')