Exemple #1
0
    def serviceList(self):
        # We look for services for this authenticator groups. User is logged in in just 1 authenticator, so his groups must coincide with those assigned to ds
        from uds.web.util.services import getServicesData

        self._request.user = self._user

        return Connection.result(result=getServicesData(self._request))
Exemple #2
0
    def serviceList(self):
        # We look for services for this authenticator groups. User is logged in in just 1 authenticator, so his groups must coincide with those assigned to ds
        from uds.web.util.services import getServicesData

        self._request.user = self._user

        return Connection.result(result=getServicesData(self._request))
Exemple #3
0
    def serviceList(self):
        # We look for services for this authenticator groups. User is logged in in just 1 authenticator, so his groups must coincide with those assigned to ds
        from uds.web.util.services import getServicesData

        # Ensure user is present on request, used by web views methods
        self._request.user = self._user

        return Connection.result(result=getServicesData(typing.cast(ExtendedHttpRequestWithUser, self._request)))
Exemple #4
0
def action(request: 'ExtendedHttpRequestWithUser', idService: str,
           actionString: str) -> HttpResponse:
    userService = userServiceManager().locateUserService(request.user,
                                                         idService,
                                                         create=False)
    response: typing.Any = None
    rebuild: bool = False
    if userService:
        if (actionString == 'release'
                and userService.deployed_service.allow_users_remove):
            rebuild = True
            log.doLog(
                userService.deployed_service,
                log.INFO,
                "Removing User Service {} as requested by {} from {}".format(
                    userService.friendly_name, request.user.pretty_name,
                    request.ip),
                log.WEB,
            )
            userServiceManager().requestLogoff(userService)
            userService.release()
        elif (actionString == 'reset'
              and userService.deployed_service.allow_users_reset
              and userService.deployed_service.service.getType().canReset):
            rebuild = True
            log.doLog(
                userService.deployed_service,
                log.INFO,
                "Reseting User Service {} as requested by {} from {}".format(
                    userService.friendly_name, request.user.pretty_name,
                    request.ip),
                log.WEB,
            )
            # userServiceManager().requestLogoff(userService)
            userServiceManager().reset(userService)

    if rebuild:
        # Rebuild services data, but return only "this" service
        for v in services.getServicesData(request)['services']:
            if v['id'] == idService:
                response = v
                break

    return HttpResponse(json.dumps(response), content_type="application/json")
Exemple #5
0
def action(request, idService, action):
    logger.debug('ID Service: {}'.format(idService))
    userService = userServiceManager().locateUserService(request.user, idService, create=False)
    logger.debug('UserService: >{}<'.format(userService))
    response = None
    rebuild = False
    if userService:
        if action == 'release' and userService.deployed_service.allow_users_remove:
            rebuild = True
            log.doLog(
                userService.deployed_service,
                log.INFO,
                "Removing User Service {} as requested by {} from {}".format(userService.friendly_name, request.user.pretty_name, request.ip),
                log.WEB
            )
            userServiceManager().requestLogoff(userService)
            userService.release()
        elif (action == 'reset'
              and userService.deployed_service.allow_users_reset
              and userService.deployed_service.service.getType().canReset):
            rebuild = True
            log.doLog(
                userService.deployed_service,
                log.INFO,
                "Reseting User Service {} as requested by {} from {}".format(userService.friendly_name, request.user.pretty_name, request.ip),
                log.WEB
            )
            # userServiceManager().requestLogoff(userService)
            userServiceManager().reset(userService)

    if rebuild:
        # Rebuild services data, but return only "this" service
        for v in services.getServicesData(request)['services']:
            logger.debug('{} ==? {}'.format(v['id'], idService))
            if v['id'] == idService:
                response = v
                break

    return HttpResponse(json.dumps(response), content_type="application/json")
Exemple #6
0
def action(request, idService, action):
    userService = userServiceManager().locateUserService(request.user, idService, create=False)
    response = None
    rebuild = False
    if userService:
        if action == 'release' and userService.deployed_service.allow_users_remove:
            rebuild = True
            log.doLog(
                userService.deployed_service,
                log.INFO,
                "Removing User Service {} as requested by {} from {}".format(userService.friendly_name, request.user.pretty_name, request.ip),
                log.WEB
            )
            userServiceManager().requestLogoff(userService)
            userService.release()
        elif (action == 'reset'
              and userService.deployed_service.allow_users_reset
              and userService.deployed_service.service.getType().canReset):
            rebuild = True
            log.doLog(
                userService.deployed_service,
                log.INFO,
                "Reseting User Service {} as requested by {} from {}".format(userService.friendly_name, request.user.pretty_name, request.ip),
                log.WEB
            )
            # userServiceManager().requestLogoff(userService)
            userServiceManager().reset(userService)

    if rebuild:
        # Rebuild services data, but return only "this" service
        for v in services.getServicesData(request)['services']:
            logger.debug('{} ==? {}'.format(v['id'], idService))
            if v['id'] == idService:
                response = v
                break

    return HttpResponse(json.dumps(response), content_type="application/json")
Exemple #7
0
def servicesData(request):
    data = getServicesData(request)

    return HttpResponse(content=json.dumps(data), content_type='application/json')
Exemple #8
0
def servicesData(request: HttpRequest) -> HttpResponse:
    return JsonResponse(getServicesData(request))
Exemple #9
0
def servicesData(request: ExtendedHttpRequestWithUser) -> HttpResponse:
    return JsonResponse(getServicesData(request))
Exemple #10
0
def servicesData(request):
    return JsonResponse(getServicesData(request))
Exemple #11
0
def servicesData(request):
    data = getServicesData(request)

    return HttpResponse(content=json.dumps(data),
                        content_type='application/json')