Skip to content

Commit

Permalink
lets sync some groups
Browse files Browse the repository at this point in the history
  • Loading branch information
lme-nca committed Mar 15, 2024
1 parent 172642e commit b647ba1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions dojo/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ def modify_permissions(backend, uid, user=None, social=None, *args, **kwargs):


def update_keycloak_groups(backend, uid, user=None, social=None, *args, **kwargs):
if settings.KEYCLOAK_OAUTH2_ENABLED:
if settings.KEYCLOAK_OAUTH2_ENABLED: #need another setting to enable syncing

Check notice on line 69 in dojo/pipeline.py

View workflow job for this annotation

GitHub Actions / flake8-your-pr

dojo/pipeline.py#L69

at least two spaces before inline comment (E261)

Check notice on line 69 in dojo/pipeline.py

View workflow job for this annotation

GitHub Actions / flake8-your-pr

dojo/pipeline.py#L69

inline comment should start with '# ' (E262)
soc = user.social_auth.order_by("-created").first()
token = soc.extra_data['access_token']
print("accesstoken: " + str(token))
print("response raw: " + str(kwargs['response']))

if 'groups' not in kwargs['response'] or kwargs['response']['groups'] == "":
logger.warning("No groups in response. Stopping to update groups of user based on azureAD")
return
group_IDs = kwargs['response']['groups'] # probably need another setting with a regex ?

Check notice on line 77 in dojo/pipeline.py

View workflow job for this annotation

GitHub Actions / flake8-your-pr

dojo/pipeline.py#L77

at least two spaces before inline comment (E261)
if len(group_IDs) > 0:
assign_user_to_groups(user, group_IDs, 'Keycloak')
if settings.AZUREAD_TENANT_OAUTH2_CLEANUP_GROUPS:
cleanup_old_groups_for_user(user, group_IDs)

def update_azure_groups(backend, uid, user=None, social=None, *args, **kwargs):

Check notice on line 83 in dojo/pipeline.py

View workflow job for this annotation

GitHub Actions / flake8-your-pr

dojo/pipeline.py#L83

expected 2 blank lines, found 1 (E302)
if settings.AZUREAD_TENANT_OAUTH2_ENABLED and settings.AZUREAD_TENANT_OAUTH2_GET_GROUPS and isinstance(backend, AzureADTenantOAuth2):
Expand Down

0 comments on commit b647ba1

Please sign in to comment.