This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(openid): handle authorization management on authentication (#11320)…
… (#11349)
- Loading branch information
1 parent
0249b96
commit 1f97adc
Showing
9 changed files
with
690 additions
and
30 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/Core/Contact/Application/Repository/WriteContactGroupRepositoryInterface.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,45 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* For more information : contact@centreon.com | ||
* | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Contact\Application\Repository; | ||
|
||
use Centreon\Domain\Contact\Interfaces\ContactInterface; | ||
use Core\Contact\Domain\Model\ContactGroup; | ||
|
||
interface WriteContactGroupRepositoryInterface | ||
{ | ||
/** | ||
* Delete all contact groups for a given user | ||
* | ||
* @param ContactInterface $user | ||
*/ | ||
public function deleteContactGroupsForUser(ContactInterface $user): void; | ||
|
||
/** | ||
* Insert a contact group for a given user | ||
* | ||
* @param ContactInterface $user | ||
* @param ContactGroup $contactGroup | ||
*/ | ||
public function insertContactGroupForUser(ContactInterface $user, ContactGroup $contactGroup): void; | ||
} |
66 changes: 66 additions & 0 deletions
66
src/Core/Contact/Infrastructure/Repository/DbWriteContactGroupRepository.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,66 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* For more information : contact@centreon.com | ||
* | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Contact\Infrastructure\Repository; | ||
|
||
use Core\Contact\Domain\Model\ContactGroup; | ||
use Centreon\Infrastructure\DatabaseConnection; | ||
use Centreon\Domain\Contact\Interfaces\ContactInterface; | ||
use Centreon\Infrastructure\Repository\AbstractRepositoryDRB; | ||
use Core\Contact\Application\Repository\WriteContactGroupRepositoryInterface; | ||
|
||
class DbWriteContactGroupRepository extends AbstractRepositoryDRB implements WriteContactGroupRepositoryInterface | ||
{ | ||
/** | ||
* @param DatabaseConnection $db | ||
*/ | ||
public function __construct(DatabaseConnection $db) | ||
{ | ||
$this->db = $db; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function deleteContactGroupsForUser(ContactInterface $user): void | ||
{ | ||
$statement = $this->db->prepare($this->translateDbName( | ||
"DELETE FROM `:db`.contactgroup_contact_relation WHERE contact_contact_id = :userId" | ||
)); | ||
$statement->bindValue(':userId', $user->getId(), \PDO::PARAM_INT); | ||
$statement->execute(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function insertContactGroupForUser(ContactInterface $user, ContactGroup $contactGroup): void | ||
{ | ||
$statement = $this->db->prepare($this->translateDbName( | ||
"INSERT INTO contactgroup_contact_relation VALUES (:userId, :contactGroupId)" | ||
)); | ||
$statement->bindValue(':userId', $user->getId(), \PDO::PARAM_INT); | ||
$statement->bindValue(':contactGroupId', $contactGroup->getId(), \PDO::PARAM_INT); | ||
$statement->execute(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/Core/Security/Application/Repository/WriteAccessGroupRepositoryInterface.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,45 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2005 - 2019 Centreon (https://www.centreon.com/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* For more information : contact@centreon.com | ||
* | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Security\Application\Repository; | ||
|
||
use Core\Security\Domain\AccessGroup\Model\AccessGroup; | ||
use Centreon\Domain\Contact\Interfaces\ContactInterface; | ||
|
||
interface WriteAccessGroupRepositoryInterface | ||
{ | ||
/** | ||
* Delete all access groups for a given user | ||
* | ||
* @param ContactInterface $user | ||
*/ | ||
public function deleteAccessGroupsForUser(ContactInterface $user): void; | ||
|
||
/** | ||
* Insert access groups for a given user | ||
* | ||
* @param ContactInterface $user | ||
* @param AccessGroup[] $accessGroups | ||
*/ | ||
public function insertAccessGroupsForUser(ContactInterface $user, array $accessGroups): void; | ||
} |
Oops, something went wrong.