Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Group membership check #1074

Merged
merged 136 commits into from
Nov 22, 2021
Merged

Group membership check #1074

merged 136 commits into from
Nov 22, 2021

Conversation

chkeita
Copy link
Contributor

@chkeita chkeita commented Jul 15, 2021

This PR enables the restriction of certain api to some user based on their principalid or their group membership

Api Restriction rules

We provide the ability to create a set of rules that specify which group has access to an api
The set of rules is a list of RuleDefinition defined set in the property api_access_rules of the Instance configuration

  [
      {
          "methods": ["get", "post"],
          "endpoint": ["/api/jobs"],
          "allowed_groups": ["<group_id>"]
      }
  ]

We store and manage in the RequestAccess class defined in #1420

Rules enforcement

Those rules are enforced when the request is received by the service.
A call to check_access determine if the request is authorized or not.

Group membership information retrieval

The group membership is retrieved from azure call to msgraph in the AzureADGroupMembership class
This call requires specific permissions which depending on the environmentt can only be granted by an admin.
We also provide for testing purposes a StaticGroupMembership class to provide the access restriction functionality without querying azure.
The class is initialized with the group membership information stored in the Instance configuration in the field group_membership

Testing

A functional test is provided in api_restriction_test.py

- add timeout to access rule cache
- update python version in deployment
- update unit tests
fix type in static group memebership
fix group membership check logic
make the group membership query transitive
api_access_rules is now a dictionary
add environment variable to disable cache
@chkeita chkeita marked this pull request as ready for review November 17, 2021 17:19
@chkeita chkeita merged commit aa74550 into microsoft:main Nov 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OneFuzz CLI Role Assignment Infrastructure
2 participants