Esempio n. 1
0
    def post(self, id=None):
        if 'state' in request.json and request.json['state'] == 'create':
            domain_controller = DomainController(
                None, request.json['name'], request.json['address'],
                request.json['port'], request.json['accept_self_signed'])
            db.session.add(domain_controller)
            db.session.commit()
            return self.get(domain_controller.id)
        else:
            domain_controller = DomainController.query.get(id)
            name = clean(request.json['name'].rstrip())
            address = clean(request.json['address'].rstrip())
            port = clean(request.json['port'].rstrip())

            if name != '':
                domain_controller.name = name

            if address != '':
                domain_controller.address = address

            if port != '':
                domain_controller.port = port

            db.session.add(domain_controller)
            db.session.commit()
            return self.get(id)
Esempio n. 2
0
    def post(self, id=None):
        if 'state' in request.json and request.json['state'] == 'create':
            domain_controller = DomainController(
                None,
                request.json['name'],
                request.json['address'],
                request.json['port'],
                request.json['accept_self_signed']
            )
            db.session.add(domain_controller)
            db.session.commit()
            return self.get(domain_controller.id)
        else:
            domain_controller = DomainController.query.get(id)
            name = clean(request.json['name'].rstrip())
            address = clean(request.json['address'].rstrip())
            port = clean(request.json['port'].rstrip())

            if name != '':
                domain_controller.name = name

            if address != '':
                domain_controller.address = address

            if port != '':
                domain_controller.port = port

            db.session.add(domain_controller)
            db.session.commit()
            return self.get(id)
Esempio n. 3
0
 def post(self):
     """Send an SSL cert/key"""
     query = request.get_json()
     DC = clean(query.get('domain_controller'))
     name = clean(query.get('name'))
     cert = clean(query.get('cert'))
     key = clean(query.get('key'))
     check = SSL.query.filter_by(
         domaincontroller_id=DC,
         name=name
         ).count()
     if check > 0:
         abort(400)
     new_cert = SSL()
     new_cert.name = name
     DC = DomainController.query.get(DC)
     new_cert.domain_controller = DC
     db.session.add(new_cert)
     db.session.commit()
     req.post(
         DC.url + '/ssl',
         headers=json_headers,
         data=json.dumps(
             {'name': name,
              'cert': cert,
              'key': key}),
         verify=False
     )
Esempio n. 4
0
    def post(self, id=None):
        if 'state' in request.json and request.json['state'] == 'create':
            host = Host(None, clean(request.json['name']),
                        request.json['params'].replace("<br>", "\r\n"),
                        clean(request.json['provider']))
            db.session.add(host)
            db.session.commit()
            return {
                'host': marshal(host, host_fields),
            }
        else:
            host = Host.query.get(id)
            name = clean(request.json['name'].rstrip())

            params = request.json['params']
            while (params.find('<br><br>') != -1):
                params = params.replace("<br><br>", "<br>")

            params = params.replace("<br>", "\r\n")
            params = params.replace('<div>', '\r\n')
            params = params.replace('&nbsp;', '')
            params = params.replace('</div>', '\r\n')

            provider = clean(request.json['provider'].rstrip())

            if name != '':
                host.name = name
            if provider != '':
                host.provider = provider

            host.params = params

            db.session.add(host)
            db.session.commit()
            return self.get(id)
Esempio n. 5
0
    def post(self, id=None):
        if 'state' in request.json and request.json['state'] == 'create':
            action = 'create'
            project = Project(None, request.json['name'])
        else:
            action = 'update'
            project = Project.query.get(id)

        if 'name' in request.json\
                and request.json['name'] != '':
            project.name = clean(request.json['name'])
        if 'git_address' in request.json\
                and request.json['git_address'] != '':
            project.git_address = clean(request.json['git_address'].replace(
                ' ', ''))
        elif 'base_path' in request.json:
            project.base_path = request.json['base_path']

        auditlog(current_user,
                 action,
                 project,
                 request_details=request.get_json())
        db.session.add(project)
        db.session.commit()

        return marshal(project, project_fields)
Esempio n. 6
0
 def post(self):
     """Send an SSL cert/key"""
     query = request.get_json()
     DC = clean(query.get('domain_controller'))
     name = clean(query.get('name'))
     cert = clean(query.get('cert'))
     key = clean(query.get('key'))
     check = SSL.query.filter_by(
         domaincontroller_id=DC,
         name=name
         ).count()
     if check > 0:
         abort(400)
     new_cert = SSL()
     new_cert.name = name
     DC = DomainController.query.get(DC)
     new_cert.domain_controller = DC
     auditlog(
         current_user,
         'create',
         new_cert,
         request_details=request.get_json())
     db.session.add(new_cert)
     db.session.commit()
     req.post(
         DC.url + '/ssl',
         headers=json_headers,
         data=json.dumps(
             {'name': name,
              'cert': cert,
              'key': key}),
         verify=False
     )
Esempio n. 7
0
    def post(self, id=None):
        if 'state' in request.json and request.json['state'] == 'create':
            action = 'create'
            project = Project(None, request.json['name'])
        else:
            action = 'update'
            project = Project.query.get(id)

        if 'name' in request.json\
                and request.json['name'] != '':
            project.name = clean(request.json['name'])
        if 'git_address' in request.json\
                and request.json['git_address'] != '':
            project.git_address = clean(
                request.json['git_address'].replace(' ', '')
            )
        elif 'base_path' in request.json:
            project.base_path = request.json['base_path']

        auditlog(
            current_user,
            action,
            project,
            request_details=request.get_json())
        db.session.add(project)
        db.session.commit()

        return marshal(project, project_fields)
Esempio n. 8
0
    def post(self, id=None):
        if 'state' in request.json and request.json['state'] == 'create':
            team = Team(
                None,
                request.json['name'],
            )
            auditlog(
                current_user,
                'create',
                team,
                request_details=request.json)
            db.session.add(team)
            db.session.commit()
            return {
                'team': marshal(team, team_fields),
            }
        else:
            # Not used right now, put() is called instead.
            team = Team.query.get(id)
            name = clean(request.json['name'])
            if name != '':
                team.name = name

            # team = self._updatePermissions(team)

            db.session.add(team)
            db.session.commit()
            return self.get(id)
Esempio n. 9
0
 def get(self, id=None):
     """Retrieve a list of SSL certs/keys"""
     query = request.args
     if id is not None:
         return SSL.query.get(id)
     if query is not None and 'domain_controller' in query:
         dc = clean(query.get('domain_controller'))
         return SSL.query.filter_by(domaincontroller_id=dc).all()
     marsh = SSL.query.all()
     return marsh
Esempio n. 10
0
 def get(self, id=None):
     """Retrieve a list of SSL certs/keys"""
     query = request.args
     if id is not None:
         return SSL.query.get(id)
     if query is not None and 'domain_controller' in query:
         dc = clean(query.get('domain_controller'))
         return SSL.query.filter_by(domaincontroller_id=dc).all()
     marsh = SSL.query.all()
     return marsh
Esempio n. 11
0
    def post(self, id=None):
        if 'state' in request.json and request.json['state'] == 'create':
            host = Host(
                None,
                clean(request.json['name']),
                request.json['params'].replace("<br>", "\r\n"),
                clean(request.json['provider'])
            )
            db.session.add(host)
            db.session.commit()
            return {
                'host': marshal(host, host_fields),
            }
        else:
            host = Host.query.get(id)
            name = clean(request.json['name'].rstrip())

            params = request.json['params']
            while(params.find('<br><br>') != -1):
                params = params.replace("<br><br>", "<br>")

            params = params.replace("<br>", "\r\n")
            params = params.replace('<div>', '\r\n')
            params = params.replace('&nbsp;', '')
            params = params.replace('</div>', '\r\n')

            provider = clean(request.json['provider'].rstrip())

            if name != '':
                host.name = name
            if provider != '':
                host.provider = provider

            host.params = params

            db.session.add(host)
            db.session.commit()
            return self.get(id)