Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding EntraID SCIM Function #3

Closed
wants to merge 43 commits into from

Conversation

julialawrence
Copy link
Contributor

@julialawrence julialawrence commented Jul 15, 2024

Tracking stories:

Description:

This PR merges the feature/add-entra-id-scim-function branch into the main branch. The branch introduces a Python script that automates the synchronsation of EntraID groups and their members with AWS Identity Center. This functionality ensures consistency between EntraID and AWS Identity Center, streamlining user and group management across these platforms.

What it does:

  • Fetch EntraID Groups: Retrieves EntraID groups prefixed with a specific string (azure-aws-sso- by default).
  • Fetch EntraID Group Members: Obtains the members and admins of each EntraID group.
  • Sync with AWS Identity Center:
    • Adds or updates AWS Identity Center groups and their memberships to match EntraID.
    • Deletes AWS Identity Center groups that no longer exist in EntraID.
    • Removes users from AWS Identity Center groups if they no longer exist in the corresponding EntraID groups.
    • Deletes orphaned AWS users who are not members of any relevant groups.
  • Logging and Dry-Run Mode: Includes comprehensive logging for monitoring and debugging, with an option to perform a "dry run" to simulate actions without making actual changes.

Tests Included:

  1. Unit Tests:

    • Located in function/tests/unit/
    • Test files include:
      • test_aws_functions.py: Tests AWS-specific operations.
      • test_azure_functions.py: Tests EntraID-specific operations.
      • test_member_syncing.py: Tests the member sync logic.
    • Ensure that core functionalities, such as token retrieval, group fetching, and user management, work as expected.
  2. Integration Tests:

    • Located in function/tests/integration/
    • Test files include:
      • test_sync_function_integration_test.py: Verifies end-to-end sync between EntraID and AWS Identity Center.
    • Test scenarios involving creation, deletion, and modification of groups and users to ensure group memberships and users are consistent between Azure and AWS.

Instructions for Running Tests:

1. Install Prerequisites:

Ensure you have Python installed (version 3.6 or later is recommended).

To run the tests using the unittest framework, which is included with Python, you need to install the required dependencies listed in requirements-dev.txt. Run the following command to install them:

pip install -r requirements-dev.txt

This command will install all necessary libraries, including:

  • boto3: AWS SDK for Python to interact with AWS services.
  • requests: To make HTTP requests to EntraID.
  • Other dependencies specified in the requirements-dev.txt file.

2. Set Up Environment Variables:

Before running the script or tests, set up the required environment variables:

  • AZURE_TENANT_ID: EntraID Tenant ID
  • AZURE_CLIENT_ID: EntraID Application (client) ID
  • AZURE_CLIENT_SECRET: EntraID Application Secret
  • LOG_LEVEL: (Optional) Logging level (default: INFO)

You can export these variables in your terminal:

export AZURE_TENANT_ID="your-tenant-id"
export AZURE_CLIENT_ID="your-client-id"
export AZURE_CLIENT_SECRET="your-client-secret"
export LOG_LEVEL="INFO"

3. Run Unit Tests:

Execute unit tests using Python's built-in unittest framework:

python -m unittest discover function/tests/unit

This command will discover and run all unit tests located in the tests/unit/ directory.

4. Run Integration Tests:

Execute integration tests using unittest:

python -m unittest discover function/tests/integration

This command will discover and run all integration tests located in the tests/integration/ directory.

5. Run All Tests:

To run both unit and integration tests, use the following commands:

python -m unittest discover function/tests/unit
python -m unittest discover function/tests/integration

This command will discover and run all integration tests located in the tests/integration/ directory.

Alternatively, to run all tests at once:

python -m unittest discover function/tests

Additional Notes:

  • Logging: The script uses customisable logging because the out-of-the-box setup didn't properly flush the output on the developer's machine.
  • Dry Run Mode: If you have required permissions to run the script directly, dry_run is set to True by default and if looking to apply changes, it needs to be set to False explicitly.

@julialawrence julialawrence force-pushed the feature/add-entraid-scim-function branch from 7fb6271 to 8ba1733 Compare July 15, 2024 16:30
function/app.py Outdated Show resolved Hide resolved
@julialawrence julialawrence marked this pull request as ready for review August 30, 2024 16:29
Copy link
Contributor

@Gary-H9 Gary-H9 left a comment

Choose a reason for hiding this comment

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

LGTM

* 🔧 Add devcontainer + superlinter

* ...newlines

* 🔧 Add pyproject.toml

* Misc

* 🔧 Further config
⬆️ Bump super-linter/super-linter from 6.7.0 to 7.1.0

Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.7.0 to 7.1.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](super-linter/super-linter@3fe03ab...b92721f)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.1.3 to 4.3.4.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](actions/dependency-review-action@9129d7d...5a2ce3f)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@julialawrence julialawrence force-pushed the feature/add-entraid-scim-function branch from 8b3bac1 to 558ee4e Compare September 5, 2024 09:44
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.

4 participants