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)
from DBUtil import Tags from Services import TeamService, TagHelperService, HelperServices from Services.AppInitServices import authService from settings import mongodb from flask_restplus import Resource from modules.apimodels import TagModel from modules.apimodels.Restplus import api, header_parser from modules.apimodels.GenericReponseModel import generic_response_model tagAPI = Blueprint('TagAPI', __name__) tagAPINs = api.namespace('tag', description='Tag Operations') # get global db connection db = mongodb tagDB = Tags.Tags() teamService = TeamService.TeamService() @tagAPINs.route('/all', methods=['GET']) class getalltag(Resource): @api.expect(header_parser, validate=True) @api.marshal_with(TagModel.get_all_tags_response_model) @authService.authorized def get(self): return {"result": "success", "data": list(tagDB.get_tags())}, 200 @tagAPINs.route('/view/<id>', methods=['GET']) @api.doc(params={'id': 'Tag ID'}) class getTagbyID(Resource): @api.expect(header_parser, validate=True)