-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enforce access control Issue #14454 * Forgot to save this file * Zap regen * Small logging changes in access control May not keep this for release but need it for the next few weeks. * Add another log * Add temp logs to debug nRF test failures on Zephyr * Temporarily change ChipLogDetail to ChipLogError * Change access control logs from detail to progress * Remove temporary logs * Add PermissiveAccessControlDelegate for tests This new delegate does not error and overrides the access control check to always allow. It is installed in the unit test context so that unit tests (e.g. of interaction model, which has access control baked in) can test units other than access control without failing due to access control, and without running with real access control and having to install real ACLs (that's for integration tests to do). * Fix logging I meant to do this in the last commit. * Add test helper dependency on access control
- Loading branch information
1 parent
85422fa
commit dd13dbe
Showing
11 changed files
with
166 additions
and
50 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "PermissiveAccessControlDelegate.h" | ||
|
||
namespace { | ||
|
||
using namespace chip; | ||
using namespace chip::Access; | ||
|
||
using Entry = chip::Access::AccessControl::Entry; | ||
using EntryIterator = chip::Access::AccessControl::EntryIterator; | ||
using Target = Entry::Target; | ||
|
||
class AccessControlDelegate : public AccessControl::Delegate | ||
{ | ||
public: | ||
CHIP_ERROR Init() override { return CHIP_NO_ERROR; } | ||
CHIP_ERROR Finish() override { return CHIP_NO_ERROR; } | ||
|
||
// Capabilities | ||
CHIP_ERROR GetMaxEntryCount(size_t & value) const override | ||
{ | ||
value = 0; | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
// Actualities | ||
CHIP_ERROR GetEntryCount(size_t & value) const override | ||
{ | ||
value = 0; | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
// Preparation | ||
CHIP_ERROR PrepareEntry(Entry & entry) override { return CHIP_NO_ERROR; } | ||
|
||
// CRUD | ||
CHIP_ERROR CreateEntry(size_t * index, const Entry & entry, FabricIndex * fabricIndex) override { return CHIP_NO_ERROR; } | ||
CHIP_ERROR ReadEntry(size_t index, Entry & entry, const FabricIndex * fabricIndex) const override { return CHIP_NO_ERROR; } | ||
CHIP_ERROR UpdateEntry(size_t index, const Entry & entry, const FabricIndex * fabricIndex) override { return CHIP_NO_ERROR; } | ||
CHIP_ERROR DeleteEntry(size_t index, const FabricIndex * fabricIndex) override { return CHIP_NO_ERROR; } | ||
|
||
// Iteration | ||
CHIP_ERROR Entries(EntryIterator & iterator, const FabricIndex * fabricIndex) const override { return CHIP_NO_ERROR; } | ||
|
||
// TODO(#13867): this will go away | ||
bool TemporaryCheckOverride() const override { return true; } | ||
}; | ||
|
||
} // namespace | ||
|
||
namespace chip { | ||
namespace Access { | ||
namespace Examples { | ||
|
||
AccessControl::Delegate & GetPermissiveAccessControlDelegate() | ||
{ | ||
static AccessControlDelegate accessControlDelegate; | ||
return accessControlDelegate; | ||
} | ||
|
||
} // namespace Examples | ||
} // namespace Access | ||
} // namespace chip |
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,29 @@ | ||
/* | ||
* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* | ||
* 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. | ||
*/ | ||
#pragma once | ||
|
||
#include "access/AccessControl.h" | ||
|
||
namespace chip { | ||
namespace Access { | ||
namespace Examples { | ||
|
||
AccessControl::Delegate & GetPermissiveAccessControlDelegate(); | ||
|
||
} // namespace Examples | ||
} // namespace Access | ||
} // namespace chip |
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
Oops, something went wrong.