mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Added job to update the service groups on a daily basis
This commit is contained in:
@@ -7,3 +7,4 @@ ROOT=/home/matalok/auth/auth
|
||||
@daily $ROOT/run-cron.py eve_api.cron CorpManagementUpdate > $ROOT/logs/corpman-update.log 2>&1
|
||||
0 */6 * * * $ROOT/run-cron.py eve_api.cron AllianceUpdate > $ROOT/logs/alliance-update.log 2>&1
|
||||
@daily $ROOT/run-cron.py eve_proxy.cron ClearStaleCache > $ROOT/logs/cache-clear.log 2>&1
|
||||
@daily $ROOT/run-cron.py sso.cron UpdateServicegroups > $ROOT/logs/servicegroup-update.log 2>&1
|
||||
|
||||
27
sso/cron.py
27
sso/cron.py
@@ -46,3 +46,30 @@ class ValidateDisabledUsers():
|
||||
api.settings = servacc.service.settings
|
||||
if not api.disable_user(servacc.service_uid):
|
||||
self._logger.error('Error disabling %s on %s' % (servacc, servacc.service))
|
||||
|
||||
|
||||
class UpdateServiceGroups():
|
||||
"""
|
||||
Cycles through all service accounts and updates group access.
|
||||
"""
|
||||
|
||||
# run daily
|
||||
run_every = 84600
|
||||
|
||||
@property
|
||||
def _logger(self):
|
||||
if not hasattr(self, '__logger'):
|
||||
self.__logger = logging.getLogger(__name__)
|
||||
return self.__logger
|
||||
|
||||
def job(self):
|
||||
for serv in Service.objects.filter(active=1):
|
||||
self._logger.info('Updating %s service' % serv)
|
||||
api = serv.api_class
|
||||
for servacc in ServiceAccount.objects.filter(active=1, service=serv):
|
||||
self._logger.info('Processing %s' % servacc)
|
||||
try:
|
||||
api.update_groups(servacc.service_uid, servacc.user.groups.all())
|
||||
except:
|
||||
self._logger.error('Error updating %s' % servacc)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user