Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ACL attribute read/write #12305

Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d5eb767
Add access control server skeleton
mlepage-google Nov 25, 2021
2748396
Regen code.
mlepage-google Nov 26, 2021
dd3d079
Restyle code
mlepage-google Nov 26, 2021
2e5b927
Update from upstream changes
mlepage-google Nov 27, 2021
e4af168
Merge branch 'master' into access-control-server-skeleton
mlepage-google Nov 29, 2021
dcc1381
Restyle
mlepage-google Nov 29, 2021
c593e2a
Merge branch 'master' into access-control-server-skeleton
mlepage-google Nov 29, 2021
d3df60c
Add access-control-server to CMakeLists.txt
mlepage-google Nov 29, 2021
bf1709f
Remove nullable from list attribute
mlepage-google Nov 29, 2021
b8bc6ec
Merge branch 'master' into access-control-server-skeleton
mlepage-google Nov 29, 2021
2fb788a
Merge branch 'master' into access-control-server-skeleton
mlepage-google Nov 30, 2021
89a5974
Regen and restyle
mlepage-google Nov 30, 2021
71b5fa7
Merge branch 'master' into access-control-server-skeleton
mlepage-google Nov 30, 2021
c68c025
Regen and restyle
mlepage-google Nov 30, 2021
21466e7
Merge branch 'master' into access-control-server-skeleton
mlepage-google Dec 1, 2021
80dc54b
Fix test
mlepage-google Dec 2, 2021
53baaf3
Regen and restyle
mlepage-google Dec 2, 2021
63a0ce0
Regen and restyle
mlepage-google Dec 2, 2021
08c41e9
Merge branch 'master' into access-control-server-skeleton
mlepage-google Dec 2, 2021
466a548
Merge branch 'master' into access-control-server-skeleton
mlepage-google Dec 2, 2021
6a5b6f8
Regen and restyle
mlepage-google Dec 2, 2021
a2208c6
Merge branch 'master' into access-control-server-skeleton
mlepage-google Dec 2, 2021
1655019
Regen and restyle
mlepage-google Dec 2, 2021
c710106
Merge branch 'master' into access-control-server-skeleton
mlepage-google Dec 2, 2021
49cbd62
Regen and restyle
mlepage-google Dec 2, 2021
5ac7f6a
Regen and restyle
mlepage-google Dec 2, 2021
ea2d4df
Add AccessControl cluster to Darwin test helper
mlepage-google Dec 3, 2021
c8a905a
Remove AccessControl cluster from some tests
mlepage-google Dec 3, 2021
6eec4e3
Fix unless in test file
mlepage-google Dec 3, 2021
4334838
Merge branch 'master' into access-control-server-skeleton
mlepage-google Dec 3, 2021
fb1e25f
Restyle and regen
mlepage-google Dec 3, 2021
e9a2499
Implement ACL attribute
mlepage-google Dec 3, 2021
04d074d
Merge branch 'master' into access-control-server-skeleton
mlepage-google Dec 3, 2021
ccad3d2
Regen and restyle
mlepage-google Dec 3, 2021
cd3a461
Merge branch 'access-control-server-skeleton' into access-control-ser…
mlepage-google Dec 3, 2021
ff1b272
Merge branch 'master' into access-control-server-implementation
mlepage-google Dec 4, 2021
406a6f9
Regen and restyle
mlepage-google Dec 4, 2021
9fa4b97
Change extension attribute storage to RAM
mlepage-google Dec 4, 2021
8435fdd
Re-enable access control cluster tests
mlepage-google Dec 4, 2021
884341b
Fix extension attribute
mlepage-google Dec 4, 2021
31853e4
Merge branch 'master' into access-control-server-implementation
mlepage-google Dec 6, 2021
53926dd
Restyle and regen
mlepage-google Dec 6, 2021
12b0651
Change lambda arg to auto in access control server
mlepage-google Dec 6, 2021
e19c1ad
Add missing variable definitions
mlepage-google Dec 7, 2021
0a62238
Merge branch 'master' into access-control-server-implementation
mlepage-google Dec 7, 2021
b7e997e
Regen and restyle
mlepage-google Dec 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"minInterval": 0,
"maxInterval": 65534,
"reportableChange": 0
},
Expand All @@ -910,12 +910,12 @@
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"storageOption": "RAM",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? This is going to take up space in the attr store that is completely unused...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the easiest way to get the tests running for now, because the attribute exists. Otherwise I have to go through and ensure all the "not yet implemented" parts have "some kind of implementation" sufficient to keep the tests happy. I made the length 4 just in case any test tried to write more than one, but I could change the length to 1 for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see PR #12690

"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"minInterval": 0,
"maxInterval": 65534,
"reportableChange": 0
},
Expand Down
25 changes: 22 additions & 3 deletions src/access/AccessControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AccessControl
static constexpr Flags kCluster = 1 << 0;
static constexpr Flags kEndpoint = 1 << 1;
static constexpr Flags kDeviceType = 1 << 2;
Flags flags;
Flags flags = 0;
ClusterId cluster;
EndpointId endpoint;
DeviceTypeId deviceType;
Expand Down Expand Up @@ -89,6 +89,19 @@ class AccessControl

Entry() = default;

Entry(Entry && other) : mDelegate(other.mDelegate) { other.mDelegate = &mDefaultDelegate; }

Entry & operator=(Entry && other)
{
if (this != &other)
{
mDelegate->Release();
mDelegate = other.mDelegate;
other.mDelegate = &mDefaultDelegate;
}
return *this;
}

Entry(const Entry &) = delete;
Entry & operator=(const Entry &) = delete;

Expand Down Expand Up @@ -292,9 +305,12 @@ class AccessControl
virtual CHIP_ERROR Finish() { return CHIP_ERROR_NOT_IMPLEMENTED; }

// Capabilities
virtual CHIP_ERROR GetMaxEntries(int & value) const { return CHIP_ERROR_NOT_IMPLEMENTED; }
virtual CHIP_ERROR GetMaxEntryCount(size_t & value) const { return CHIP_ERROR_NOT_IMPLEMENTED; }
// TODO: more capabilities

// Actualities
virtual CHIP_ERROR GetEntryCount(size_t & value) const { return CHIP_ERROR_NOT_IMPLEMENTED; }

// Preparation
virtual CHIP_ERROR PrepareEntry(Entry & entry) { return CHIP_ERROR_NOT_IMPLEMENTED; }

Expand Down Expand Up @@ -352,7 +368,10 @@ class AccessControl
CHIP_ERROR Finish();

// Capabilities
CHIP_ERROR GetMaxEntries(int & value) const { return mDelegate.GetMaxEntries(value); }
CHIP_ERROR GetMaxEntryCount(size_t & value) const { return mDelegate.GetMaxEntryCount(value); }

// Actualities
CHIP_ERROR GetEntryCount(size_t & value) const { return mDelegate.GetEntryCount(value); }

/**
* Prepares an entry.
Expand Down
16 changes: 15 additions & 1 deletion src/access/examples/ExampleAccessControlDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,12 +968,26 @@ class AccessControlDelegate : public AccessControl::Delegate
return SaveToFlash();
}

CHIP_ERROR GetMaxEntries(int & value) const override
CHIP_ERROR GetMaxEntryCount(size_t & value) const override
{
value = ArraySize(EntryStorage::acl);
return CHIP_NO_ERROR;
}

CHIP_ERROR GetEntryCount(size_t & value) const override
{
value = 0;
for (const auto & storage : EntryStorage::acl)
{
if (!storage.InUse())
{
break;
}
value++;
}
return CHIP_NO_ERROR;
}

CHIP_ERROR PrepareEntry(Entry & entry) override
{
if (auto * delegate = EntryDelegate::Find(entry.GetDelegate()))
Expand Down
2 changes: 1 addition & 1 deletion src/access/tests/TestAccessControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct EntryData
NodeId subjects[kMaxSubjects] = { 0 };
Target targets[kMaxTargets] = { { 0 } };

void Clear() { memset(this, 0, sizeof(*this)); }
void Clear() { *this = EntryData(); }

bool IsEmpty() const { return authMode == AuthMode::kNone; }

Expand Down
1 change: 1 addition & 0 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ static_library("app") {

public_deps = [
":app_buildconfig",
"${chip_root}/src/access",
"${chip_root}/src/app/util:device_callbacks_manager",
"${chip_root}/src/lib/support",
"${chip_root}/src/messaging",
Expand Down
Loading