Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
enh(openid): handle authorization management on authentication (#11320)…
Browse files Browse the repository at this point in the history
… (#11349)
  • Loading branch information
jeremyjaouen authored Jul 8, 2022
1 parent 0249b96 commit 1f97adc
Show file tree
Hide file tree
Showing 9 changed files with 690 additions and 30 deletions.
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;
}
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();
}
}
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;
}
Loading

0 comments on commit 1f97adc

Please sign in to comment.