Skip to content

Commit

Permalink
Add transitional support to access control
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 committed Nov 22, 2021
1 parent 63ea01b commit 387af13
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 387af13

Please sign in to comment.