def registTokenValidation(self, **kwargs): """Server Side Regist Validation with authentication Receives a token signed by the user and validate it Security: Message from user ciphered with Server Public Key """ # Decipher the Message with Server Private Key message = ast.literal_eval(kwargs['message']) tokenSigned = ast.literal_eval(kwargs['token']) # Decipher the Message with Server Private Key receivedData = dm.decryptMessageReceived(message['data'].decode('hex')) receivedToken = dm.decryptMessageReceived( tokenSigned['data'].decode('hex')) # Send Token to PAM """ ----------------- PAM -------------------- """ user = receivedData['userID'] auth = False path = DBmodule.getPubKeyPath() myPam = pam.pam_module(user) token = um.getRegistToken(user).encode('base64') signed = receivedToken['token'] pwd = pw.make_hash(receivedData['password']).encode('base64') serverpw = DBmodule.db_getUserPW(user).encode('base64') myPam.setItems(path, token, signed, "Menos Gambiarra") try: myPam.auth.authenticate() except PAM.error, resp: print 'Go away! (%s)' % resp
def authTokenValidation(self, **kwargs): """Server Side LogIn Validation Receives a token signed by the user and validate it Security: Message from user ciphered with Server Public Key Session Management: Create a Session Key with DiffieHellman """ message = ast.literal_eval(kwargs['message']) tokenSigned = ast.literal_eval(kwargs['token']) # Decipher the Message with Server Private Key receivedData = dm.decryptMessageReceived(message['data'].decode('hex')) receivedToken = dm.decryptMessageReceived( tokenSigned['data'].decode('hex')) """ ----------------- PAM -------------------- """ user = receivedData['userID'] auth = False path = DBmodule.getPubKeyPath() myPam = pam.pam_module(user) token = um.getUserToken(user).encode('base64') signed = receivedToken['token'] if DBmodule.db_getLogIn(receivedData['userID'], receivedData['password']) == 1: match = "Gambiarra" else: match = "Menos Gambiarra" myPam.setItems(path, token, signed, match) try: myPam.auth.authenticate() except PAM.error, resp: print 'Go away! (%s)' % resp