def rest_port(request): # get the current port if request.method == 'GET': # send back the ports for http and https apache = Apache() http_config = { 'httpPort': apache.http_port, 'httpsPort': apache.https_port } json_reply = jsonpickle.encode(http_config, unpicklable=False) return HttpResponse(json_reply) # modify the apache port if request.method == 'PUT': data = json.loads(request.raw_post_data) http_port = data['httpPort'] https_port = data['httpsPort'] apache = Apache() apache.http_port = http_port apache.https_port = https_port apache.save() apache.restart() return HttpResponse( "Port changed. Please reload your browser to http://localhost:" + http_port + "/gitstack/")
def rest_security(request): # get http/https config if request.method == 'GET': # send back the port apache = Apache() http_config = {'http': apache.http, 'https': apache.https } json_reply = jsonpickle.encode(http_config, unpicklable = False) return HttpResponse(json_reply) # modify the apache port if request.method == 'PUT': data = json.loads(request.raw_post_data) http = data['http'] https = data['https'] apache = Apache() if http == True: apache.http = True else: apache.http = False if https == True: apache.https = True else: apache.https = False apache.save() apache.restart() if apache.http == False and apache.https == True: return HttpResponse("Please reload the admin interface using https://localhost/gitstack/ .") return HttpResponse("Security settings have been successfully saved.")
def proceed_first_setup(self): from gitstack.models import Apache # create a settings.ini file shutil.copy(settings.INSTALL_DIR + '/app/gitstack/config_template/settings.ini', settings.SETTINGS_PATH) # create a group file if it does not exist if not os.path.isfile(settings.GROUP_FILE_PATH): # create an empty group file group_file = open(settings.GROUP_FILE_PATH, 'w') group_file.write('') group_file.close() # copy the self signed certificates self.copy_certificates() # save new apache configuration (update gitphp repo location) apache = Apache() apache.save()
def webinterface(request): try: # get if the web interface is enabled gitphp_path = settings.INSTALL_DIR + '/apache/conf/gitstack/gitphp.conf' if request.method == 'GET': # check if the file gitphp.conf exist isEnabled = False if os.path.isfile(gitphp_path): isEnabled = True permissions = {'enabled' : isEnabled} json_reply = json.dumps(permissions) return HttpResponse(json_reply) # update the web interface permissions if request.method == 'PUT': # retrieve the dictionary from the request web_interface_dic = json.loads(request.raw_post_data) # update the repository isEnabled = web_interface_dic['enabled'] # rename the file to enable or disable the web interface if isEnabled: os.rename(gitphp_path + '.disabled', gitphp_path) else: os.rename(gitphp_path, gitphp_path + '.disabled') # restart apache Apache.restart() # create the message if isEnabled: message = "Web interface successfully enabled" else: message = "Web interface successfully disabled" return HttpResponse(message) except Exception as e: return HttpResponseServerError(e)
def webinterface(request): try: # get if the web interface is enabled gitphp_path = settings.INSTALL_DIR + '/apache/conf/gitstack/gitphp.conf' if request.method == 'GET': # check if the file gitphp.conf exist isEnabled = False if os.path.isfile(gitphp_path): isEnabled = True permissions = {'enabled': isEnabled} json_reply = json.dumps(permissions) return HttpResponse(json_reply) # update the web interface permissions if request.method == 'PUT': # retrieve the dictionary from the request web_interface_dic = json.loads(request.raw_post_data) # update the repository isEnabled = web_interface_dic['enabled'] # rename the file to enable or disable the web interface if isEnabled: os.rename(gitphp_path + '.disabled', gitphp_path) else: os.rename(gitphp_path, gitphp_path + '.disabled') # restart apache Apache.restart() # create the message if isEnabled: message = "Web interface successfully enabled" else: message = "Web interface successfully disabled" return HttpResponse(message) except Exception as e: return HttpResponseServerError(e)
def proceed_first_setup(self): from gitstack.models import Apache # create a settings.ini file shutil.copy(settings.INSTALL_DIR + '/app/gitstack/config_template/settings.ini', settings.SETTINGS_PATH) # create a group file if it does not exist if not os.path.isfile(settings.GROUP_FILE_PATH): # create an empty group file group_file = open(settings.GROUP_FILE_PATH, 'w') group_file.write('') group_file.close() # copy the self signed certificates self.copy_certificates() # write a file for l*c*s*ng purpose open(settings.INSTALL_DIR + '/data/core', 'w').close() # save new apache configuration (update gitphp repo location) apache = Apache() apache.save()
def rest_port(request): # get the current port if request.method == 'GET': # send back the ports for http and https apache = Apache() http_config = {'httpPort': apache.http_port, 'httpsPort': apache.https_port } json_reply = jsonpickle.encode(http_config, unpicklable = False) return HttpResponse(json_reply) # modify the apache port if request.method == 'PUT': data = json.loads(request.raw_post_data) http_port = data['httpPort'] https_port = data['httpsPort'] apache = Apache() apache.http_port = http_port apache.https_port = https_port apache.save() apache.restart() return HttpResponse("Port changed. Please reload your browser to http://localhost:" + http_port + "/gitstack/")
def rest_security(request): # get http/https config if request.method == 'GET': # send back the port apache = Apache() http_config = {'http': apache.http, 'https': apache.https} json_reply = jsonpickle.encode(http_config, unpicklable=False) return HttpResponse(json_reply) # modify the apache port if request.method == 'PUT': data = json.loads(request.raw_post_data) http = data['http'] https = data['https'] apache = Apache() if http == True: apache.http = True else: apache.http = False if https == True: apache.https = True else: apache.https = False apache.save() apache.restart() if apache.http == False and apache.https == True: return HttpResponse( "Please reload the admin interface using https://localhost/gitstack/ ." ) return HttpResponse("Security settings have been successfully saved.")