Skip to content

Commit

Permalink
Add transitional support to access control (#12110)
Browse files Browse the repository at this point in the history
During development, let access control delegates declare they are
transitional, so access is allowed. This is the default for now,
but won't be once the rest of the system is in place.

In particular, unit tests are not transitional and do test functional
access control (allow and deny).
  • Loading branch information
mlepage-google authored and pull[bot] committed Oct 16, 2023
1 parent 44a5a6e commit b86d77b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/access/AccessControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ CHIP_ERROR AccessControl::Finish()
CHIP_ERROR AccessControl::Check(const SubjectDescriptor & subjectDescriptor, const RequestPath & requestPath,
Privilege requestPrivilege)
{
// During development, allow access if delegate is transitional
ReturnErrorCodeIf(mDelegate.IsTransitional(), CHIP_NO_ERROR);

EntryIterator iterator;
ReturnErrorOnFailure(Entries(iterator, &subjectDescriptor.fabricIndex));

Expand Down
3 changes: 3 additions & 0 deletions src/access/AccessControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ class AccessControl
return CHIP_ERROR_NOT_IMPLEMENTED;
}

// Transitional (during development, will be removed later)
virtual bool IsTransitional() const { return true; }

// Listening
virtual void SetListener(Listener & listener) { mListener = &listener; }
virtual void ClearListener() { mListener = nullptr; }
Expand Down
2 changes: 2 additions & 0 deletions src/access/examples/ExampleAccessControlDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,8 @@ class AccessControlDelegate : public AccessControl::Delegate
return CHIP_ERROR_BUFFER_TOO_SMALL;
}

bool IsTransitional() const override { return false; }

private:
CHIP_ERROR LoadFromFlash() { return CHIP_NO_ERROR; }

Expand Down

0 comments on commit b86d77b

Please sign in to comment.