-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Group plugin, increase test coverage
- Loading branch information
Showing
7 changed files
with
365 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .oidc_group import OIDCGroup # noQA | ||
from .plugin import IKeycloakGroupsPlugin # noQA | ||
from .plugin import KeycloakGroupsPlugin # noQA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from AccessControl import ClassSecurityInfo | ||
from pas.plugins.oidc import logger | ||
from Products.PlonePAS.plugins.group import PloneGroup | ||
from typing import Union | ||
|
||
|
||
_ATTRS_NOT_WRAPPED = [ | ||
"id", | ||
"_members", | ||
"_roles", | ||
] | ||
|
||
|
||
class OIDCGroup(PloneGroup): | ||
security = ClassSecurityInfo() | ||
|
||
@security.public | ||
def addMember(self, id: str) -> None: | ||
logger.info(f"{self._id} does not support user assignment") | ||
|
||
@security.public | ||
def removeMember(self, id: str) -> None: | ||
logger.info(f"{self._id} does not support user removal") | ||
|
||
|
||
MaybeOIDCGroup = Union[OIDCGroup, None] | ||
|
||
|
||
def wrap_group(group_info: dict) -> MaybeOIDCGroup: | ||
"""Given a dictionary with group information, return a OIDCGroup.""" | ||
group = OIDCGroup(group_info["id"], group_info["title"]) | ||
# Add title, description properties to the group object | ||
data = {k: v for k, v in group_info.items() if k not in _ATTRS_NOT_WRAPPED} | ||
group.addPropertysheet("temp", data) | ||
return group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.