Skip to content

feat: set allowed groups with environment variable#14

Merged
bsuttor merged 2 commits intomainfrom
WEB-4331
Nov 25, 2025
Merged

feat: set allowed groups with environment variable#14
bsuttor merged 2 commits intomainfrom
WEB-4331

Conversation

@remdub
Copy link
Member

@remdub remdub commented Nov 25, 2025

WEB-4331

@remdub remdub requested a review from Copilot November 25, 2025 08:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds functionality to configure allowed groups for OIDC authentication via an environment variable. The implementation reads from the keycloak_allowed_groups environment variable and sets the allowed groups on the OIDC authentication plugin during setup.

Key changes:

  • Added _set_allowed_groups() function to parse and set allowed groups from environment variable
  • Integrated the function into the set_oidc_settings() workflow
  • Added comprehensive test coverage for the new functionality

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/pas/plugins/kimug/utils.py Implemented _set_allowed_groups() function and integrated it into OIDC setup
tests/utils/test_utils.py Added test coverage for _set_allowed_groups() function
CHANGES.md Documented the new feature in the changelog

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# varenv set by puppet is a string representation of a list, e.g. "[group1, group2]"
# we need to convert it to a tuple
if varenv_allowed_groups is not None:
if varenv_allowed_groups.startswith("[") and varenv_allowed_groups.endswith(
Copy link
Member

Choose a reason for hiding this comment

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

maybe it should be better to use python ast lib, something like ast.literal_eval(varenv_allowed_groups) ?

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 (see latest commit). I also had to quote the items, because the environment variable value generated by puppet is not a valid list representation.
It's [group1, group2, group3] , instead of ["group1", "group2", "group3"].


utils._set_allowed_groups(oidc)

assert oidc.allowed_groups == ("group1", "group2", "group3")
Copy link
Member

@bsuttor bsuttor Nov 25, 2025

Choose a reason for hiding this comment

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

And adding a test with a string of an empty list ?

@remdub remdub requested a review from bsuttor November 25, 2025 09:12
Copy link
Member

@bsuttor bsuttor left a comment

Choose a reason for hiding this comment

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

LGTM

@bsuttor bsuttor merged commit 9ebaeb2 into main Nov 25, 2025
7 checks passed
@bsuttor bsuttor deleted the WEB-4331 branch November 25, 2025 09:14
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.

3 participants