def __init__(self, db): ''' General description : This function initializes the database variables and \ index to refer in functions. ''' self.db = db self.configdb = Config.Config(db) self.toolDB = Tool.Tool(self.db) self.userDB = Users.Users(self.db) self.roleDB = Role.Role(self.db) self.buildsDB = Build.Build() self.versionsDB = Versions.Versions(db) self.emailsDB = Emails.Emails(self.db) self.deploymentRequestDB = DeploymentRequest.DeploymentRequest(db) self.CloneRequestDB = CloneRequest.CloneRequest(db) self.contributionGitPushLogs = ContributionGitPushLogs.ContributionGitPushLogs( db) self.sync = Sync.Sync(db) self.auditingDB = Auditing.Auditing() self.distributionSync = DistributionSync.DistributionSync(db) self.mediaFilesDB = MediaFiles.MediaFiles(self.db) self.logo_path = logo_path self.full_logo_path = str(current_path) + self.logo_path self.media_files_path = media_path self.full_media_files_path = media_full_path self.folder_list_to_clean = [ export_full_path, distribution_center_export_full_path ] self.config_id = 15 self.load_configuration() self.schedulerService = SchedulerService.SchedulerService() self.deploymentUnitDB = DeploymentUnit.DeploymentUnit() self.repositoryDB = Repository.Repository()
def __init__(self): self.versionsDB = Versions.Versions(mongodb) self.toolDB = Tool.Tool(mongodb) self.tagDB = Tags.Tags() self.toolsetdb = ToolSet.ToolSet(mongodb) self.deploymentunitsetdb = DeploymentUnitSet.DeploymentUnitSet() self.deploymentunitdb = DeploymentUnit.DeploymentUnit() self.teamDB = Teams.Teams(mongodb) self.machineDB = Machine.Machine(mongodb) self.machinegroupsDB = MachineGroups.MachineGroups(mongodb) self.toolsetdb = ToolSet.ToolSet(mongodb) self.userdb = Users.Users(mongodb) self.roledb = Role.Role(mongodb)
def __init__(self, db, key): self.RSAKEY = RSA.generate(1024) self.SECRET_KEY = self.RSAKEY.exportKey('PEM') self.SECRET_PUBLIC_KEY = self.RSAKEY.publickey().exportKey('PEM') self.ENCRYPTION_METHOD = 'RS512' # WE WILL VERIFY EXPIRATION BY OURSELVES self.JWT_OPTIONS = {'verify_exp': False, } self.userdb = Users.Users(db) self.auditdb = Auditing.Auditing() self.roledb = Role.Role(db) self.passHelper = PasswordHelper.PasswordHelper(key) self.permissiondb = Permissions.Permissions(db) self.permissiongroupdb = PermissionGroup.PermissionGroup(db) self.accountDB = Accounts.Accounts() self.configdb = Config.Config(db) self.systemDetailsDB = SystemDetails.SystemDetails(db) self.configdbData = self.configdb.getConfigByName("AuthService") # 6 is for AuthRequestService configuration self.auditing_config = self.configdb.getConfigByName("AuditingServices") # 6 is for AuthRequestService configuration self.mailer = Mailer.Mailer() self.validTokens = {} self.teamService = TeamService.TeamService() self.collection = db.SystemDetails # Set Collection as Permissions self.teamsdb = Teams.Teams(db) if self.configdbData is not None: if self.configdbData.get("expiration") is not None: self.expiration = int(self.configdbData.get("expiration")) else: raise Exception( "Config AuthService does not have expiration set") if self.configdbData.get("email_domain") is not None: self.email_domain = str(self.configdbData.get("email_domain")) else: raise Exception( "Config AuthService does not have email_domain set") self.allow_multi_user_session = self.configdbData.get("allow_multi_user_session","false") else: raise Exception("Config was not found for Authorization services") # ADD DEAMON THREAD TO REMOVE IN VALID TOKENS AUTOMATICALLY pool = ThreadPoolExecutor(2,__name__+".__init__") pool.submit(self.removeInvalidTokens) pool.submit(self.check_if_user_logged_in_from_last_6_months)
''' Created on Jan 5, 2018 @author: vijasing ''' from DBUtil import Teams, Machine, Users, Role, UserFavoriteMachine from settings import mongodb from Services.AppInitServices import authService from flask import jsonify teamsdb = Teams.Teams(mongodb) machinedb = Machine.Machine(mongodb) userdb = Users.Users(mongodb) roledb = Role.Role(mongodb) machineFavDb = UserFavoriteMachine.UserFavoriteMachine(mongodb) def delete_user(uid): """Start User Deletion""" user_id = authService.get_userid_by_auth_token() if user_id is None: return jsonify({ "result": "failed", "message": "Token verification failed" }), 404 loggedInUser = userdb.get_user_by_id(user_id, False) UserToDelete = userdb.get_user_by_id(uid, False) loggedInUserRole = roledb.get_role_by_id(loggedInUser["roleid"], True) if loggedInUserRole["name"].lower() == "superadmin": pass else:
from flask_restplus import Resource from modules.apimodels import UserModel from modules.apimodels.Restplus import api, header_parser from Services import LdapHelper from datetime import datetime, timedelta import re from Services.HelperServices import genrate_random_key # blueprint declaration userAPI = Blueprint('userAPI', __name__) userAPINs = api.namespace('user', description='User Operations') # get global db connection db = mongodb accountDB = Accounts.Accounts() userdb = Users.Users(db) roledb = Role.Role(db) machineFavDb = UserFavoriteMachine.UserFavoriteMachine(db) emaildb = Emails.Emails(db) perGroup = PermissionGroup.PermissionGroup(db) teamDB = Teams.Teams(db) mailer = Mailer.Mailer() systemDetailsDB = SystemDetails.SystemDetails(db) teamService = TeamService.TeamService() machine_db = Machine.Machine(db) configDb = Config.Config(db) @userAPINs.route('/new', methods=['POST']) class addNewUser(Resource): @api.expect(header_parser, UserModel.add_user_input_model, validate=True) @api.marshal_with(UserModel.add_user_response_model)
#Collections db = mongodb tagDB = Tags.Tags() machineTypeDb = MachineType.MachineType(db) machineFavDb = UserFavoriteMachine.UserFavoriteMachine(db) toolInstallationDB = ToolInstallation.ToolInstallation(db) machineDB = Machine.Machine(db) userdb = Users.Users(db) accountDB = Accounts.Accounts() tooldb = Tool.Tool(db) versionsDB = Versions.Versions(db) toolsonmachinedb = ToolsOnMachine.ToolsOnMachine(db) remoteAuthenticationService = RemoteAuthenticationService.RemoteAuthenticationService( ) machinegroupDB = MachineGroups.MachineGroups(db) roleDb = Role.Role(db) deploymentUnitDb = DeploymentUnit.DeploymentUnit() teamService = TeamService.TeamService() distributionMachinetDB = DistributionMachine.DistributionMachine(db) teamsDb = Teams.Teams(db) deploymentRequestDb = DeploymentRequest.DeploymentRequest(db) buildDB = Build.Build() passHelper = PasswordHelper.PasswordHelper(key) # MachineType - ********************************************************** @machineAPI.route('/machine/type/all', methods=['GET']) @authService.authorized @swag_from(relative_path + '/swgger/MachineAPI/getAllMachineTypes.yml') def get_all_machine_types(): type_list = machineTypeDb.get_all_machine_type()