Skip to content

Commit

Permalink
Merge pull request #999 from uw-it-aca/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jlaney authored Dec 10, 2024
2 parents fc48374 + 2f20f2a commit 611b15a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG DJANGO_CONTAINER_VERSION=2.0.5
ARG DJANGO_CONTAINER_VERSION=2.0.6

FROM us-docker.pkg.dev/uwit-mci-axdd/containers/django-container:${DJANGO_CONTAINER_VERSION} AS app-container

Expand Down
16 changes: 9 additions & 7 deletions sis_provisioner/management/commands/check_role_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@


from django.conf import settings
from django.core.management.base import CommandError
from sis_provisioner.management.commands import SISProvisionerCommand
from sis_provisioner.models.admin import RoleCache
from logging import getLogger

logger = getLogger(__name__)


class Command(SISProvisionerCommand):
Expand All @@ -18,11 +20,11 @@ def handle(self, *args, **options):
if RoleCache.objects.check_roles_for_account(account_id):
notify_accounts.append(account_id)
except Exception as ex:
raise CommandError(ex)

self.update_job()
logger.info(
f'Role check failed for account {account_id}: {ex}')

if len(notify_accounts):
raise CommandError(
'Permissions changed for accounts: {}'.format(
', '.join(notify_accounts)))
log_accounts = ', '.join(notify_accounts)
logger.info(f'Permissions changed for accounts: {log_accounts}')

self.update_job()
19 changes: 13 additions & 6 deletions sis_provisioner/management/commands/remove_unauthorized_admins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@


from django.conf import settings
from restclients_core.exceptions import DataFailureException
from sis_provisioner.models.admin import Admin
from sis_provisioner.dao.canvas import (
get_account_by_id, get_all_sub_accounts, get_admins, delete_admin)
from sis_provisioner.management.commands import SISProvisionerCommand
from logging import getLogger

logger = getLogger('sis_provisioner.dao.astra')
logger = getLogger(__name__)


class Command(SISProvisionerCommand):
Expand All @@ -34,15 +35,21 @@ def handle(self, *args, **options):
for account in accounts:
account_id = account.account_id

for admin in get_admins(account_id):
try:
admins = get_admins(account_id)
except DataFailureException as ex:
logger.error(
f'get_admins failed for account "{account_id}": {ex}')
continue

for admin in admins:
if not Admin.objects.verify_canvas_admin(admin, account_id):
if options.get('commit'):
delete_admin(
account_id, admin.user.user_id, admin.role)

logger.info((
'REMOVE UNAUTHORIZED ADMIN "{}", account: "{}", '
'role: "{}"').format(
admin.user.login_id, account_id, admin.role))
logger.info(
f'REMOVE UNAUTHORIZED ADMIN "{admin.user.login_id}", '
f'account: "{account_id}", role: "{admin.role}"')

self.update_job()

0 comments on commit 611b15a

Please sign in to comment.