Skip to content

Commit

Permalink
Set up an kInternalDeviceAccess Auth mode to be used by internal re…
Browse files Browse the repository at this point in the history
…quests when building subject descriptors (#37174)

* Support a new auth mode of "internal"

* Restyle

* Rename kInternal to kInternalDeviceAccess

---------

Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
andy31415 and andreilitvin authored Jan 31, 2025
1 parent 48ca754 commit 6de6b50
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/common/pigweed/rpc_services/Attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class Attributes : public pw_rpc::nanopb::Attributes::Service<Attributes>
return ::pw::Status::NotFound();
}

Access::SubjectDescriptor subjectDescriptor{ .authMode = chip::Access::AuthMode::kPase };
Access::SubjectDescriptor subjectDescriptor{ .authMode = chip::Access::AuthMode::kInternalDeviceAccess };
app::DataModel::WriteAttributeRequest write_request;
write_request.path = path;
write_request.operationFlags.Set(app::DataModel::OperationFlags::kInternal);
Expand Down Expand Up @@ -343,7 +343,7 @@ class Attributes : public pw_rpc::nanopb::Attributes::Service<Attributes>

::pw::Status ReadAttributeIntoTlvBuffer(const app::ConcreteAttributePath & path, MutableByteSpan & tlvBuffer)
{
Access::SubjectDescriptor subjectDescriptor{ .authMode = chip::Access::AuthMode::kPase };
Access::SubjectDescriptor subjectDescriptor{ .authMode = chip::Access::AuthMode::kInternalDeviceAccess };
app::AttributeReportIBs::Builder attributeReports;
TLV::TLVWriter writer;
TLV::TLVType outer;
Expand Down
2 changes: 2 additions & 0 deletions src/access/AccessControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ char GetAuthModeStringForLogging(AuthMode authMode)
{
case AuthMode::kNone:
return 'n';
case AuthMode::kInternalDeviceAccess:
return 'i';
case AuthMode::kPase:
return 'p';
case AuthMode::kCase:
Expand Down
9 changes: 5 additions & 4 deletions src/access/AuthMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ namespace Access {
// Auth mode should have only one value expressed, which should not be None.
enum class AuthMode : uint8_t
{
kNone = 0,
kPase = 1 << 5,
kCase = 1 << 6,
kGroup = 1 << 7
kNone = 0,
kInternalDeviceAccess = 1 << 4, // Not part of an external interaction
kPase = 1 << 5,
kCase = 1 << 6,
kGroup = 1 << 7
};

} // namespace Access
Expand Down
3 changes: 2 additions & 1 deletion src/app/dynamic_server/AccessControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class AccessControlDelegate : public Access::AccessControl::Delegate
return CHIP_ERROR_ACCESS_DENIED;
}

if (subjectDescriptor.authMode != AuthMode::kCase && subjectDescriptor.authMode != AuthMode::kPase)
if (subjectDescriptor.authMode != AuthMode::kCase && subjectDescriptor.authMode != AuthMode::kPase &&
subjectDescriptor.authMode != AuthMode::kInternalDeviceAccess)
{
// No idea who is asking; deny for now.
return CHIP_ERROR_ACCESS_DENIED;
Expand Down

0 comments on commit 6de6b50

Please sign in to comment.