Skip to content

Access Control#427

Open
mhasself wants to merge 18 commits intomainfrom
access-control
Open

Access Control#427
mhasself wants to merge 18 commits intomainfrom
access-control

Conversation

@mhasself
Copy link
Member

Description

Includes:

  • Access Director Agent, for distributing access information to Agents on the OCS, and for granting exclusive access grants.
  • Under-the-hood support for credential checking, in ocs_agent.py and OCSClient.
  • Tests.
  • Documentation.

This does not include an OAuth -> OCS privileges system, but it is heading in that direction.

Motivation and Context

Resolves #124

How Has This Been Tested?

This PR includes integration tests; I also tested extensively with a dummy ocs including FakeDataAgent, HostManager, Agg. Used OCSClient to command, but also ocs-web (which was coded for this a long time ago). The unit tests in this PR include "what if an OCSClient that from earlier ocs is used?"

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

- Access Director Agent, for distributing access information to Agents
  on the OCS, and for granting exclusive access grants.
- Under-the-hood support for credential checking, in ocs_agent.py and
  OCSClient.
- Tests.
- Documentation.
Copy link
Member

@BrianJKoopman BrianJKoopman left a comment

Choose a reason for hiding this comment

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

A long overdue review. I have some questions about the configuration and meaning of some things, as well as a bunch of syntax/typo suggestions below. I've tested running this code with a system that doesn't have an AD running yet, to confirm everything works still without setting up AD (to confirm upgrading would be safe, even if one doesn't use the new control rules), but I haven't yet tried to configure the AD/AC policies myself.

Comment on lines 121 to 133
Example 3 -- like Example 2 except that the agent with `instance_id`
of "danger4" will have the level 2 and level 3 access totally
disabled (even if "danger4" is a FakeDataAgent.)::

passwords:
- default: true
password_1: ''
password_2: 'special2'
password_3: 'special3'
password_4: 'superuser'
- agent_class: FakeDataAgent
instance_id: '!danger4'
password_2: 'fake2'
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I follow this example. My first impression (I started reviewing this a while ago...), was that this should maybe read "...will have the level 3 and level 4 access totally disabled...", since we're only setting the level 2 password. But coming back to it now I'm still confused -- I would think that if the block:

  - agent_class: FakeDataAgent
    instance_id: '!danger4'
    password_2: 'fake2'

matches all FakeDataAgent instances and uses !danger4, then it wouldn't match to the agent with instance id 'danger4', so that agent instance would still follow the:

  - default: true
    password_1: ''
    password_2: 'special2'
    password_3: 'special3'
    password_4: 'superuser'

block.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are correct... I've made a new example 3, which I believe is technically accurate. Not sure what the point of example 3 was supposed to be, I think it probably made more sense in an earlier implementation!

Comment on lines 154 to 155
distributing passwords to agents. (Does not affect passwords that
were provided already hashed.)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, so what happens if you provide an already hashed password?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the answer, which is "those are distributed in hashed form, correctly annotated with the hashfunc declared for them."

"""

def __init__(self, instance_id, **kwargs):
def __init__(self, instance_id, privs=None, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

Add new privs arg to docstring.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

Can you also add a test for when the client wants to pass a password but the agent doesn't support it? That's the only thing not covered.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe I got this now. Had to refactor some test_ocs_client stuff a bit.

couple of seconds for them to synchronize.

"""
time.sleep(2)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a more reliable way to test (and possibly wait) if they're synchronized? Instances of 'wait for this to be true' tend to be flaky depending on the computing environment. And waiting longer to compensate just adds to overall test run time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes... I have implemented this via the notion of the AD's "step".

that the programmed passwords work.

"""
# This should work tho...
Copy link
Member

Choose a reason for hiding this comment

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

Why does 'bad_privs' work? Because access_policy=None?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to "This should work because acq requires only level 1, which is not password protected."

mhasself and others added 16 commits January 16, 2026 13:43
Co-authored-by: Brian Koopman <BrianJKoopman@users.noreply.github.com>
Co-authored-by: Brian Koopman <BrianJKoopman@users.noreply.github.com>
Co-authored-by: Brian Koopman <BrianJKoopman@users.noreply.github.com>
Co-authored-by: Brian Koopman <BrianJKoopman@users.noreply.github.com>
Co-authored-by: Brian Koopman <BrianJKoopman@users.noreply.github.com>
Co-authored-by: Brian Koopman <BrianJKoopman@users.noreply.github.com>
Co-authored-by: Brian Koopman <BrianJKoopman@users.noreply.github.com>
- add manager session.data to docstring
- validate agent_poll args
- add grantee to grant rejection message
@mhasself
Copy link
Member Author

Ok, I think I got everything. Thanks for the detailed review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent access control mechanism

2 participants

Comments