mirror of https://github.com/jumpserver/jumpserver
				
				
				
			fix(authentication): 修复登录时有时解密失败
							parent
							
								
									9ca8ab218c
								
							
						
					
					
						commit
						0fd2f18240
					
				| 
						 | 
				
			
			@ -34,7 +34,13 @@ def rsa_decrypt(cipher_text, rsa_private_key=None):
 | 
			
		|||
    if rsa_private_key is None:
 | 
			
		||||
        # rsa_private_key 为 None,可以能是API请求认证,不需要解密
 | 
			
		||||
        return cipher_text
 | 
			
		||||
 | 
			
		||||
    key = RSA.importKey(rsa_private_key)
 | 
			
		||||
    cipher = PKCS1_v1_5.new(key)
 | 
			
		||||
    message = cipher.decrypt(base64.b64decode(cipher_text.encode()), 'error').decode()
 | 
			
		||||
    cipher_decoded = base64.b64decode(cipher_text.encode())
 | 
			
		||||
    # Todo: 弄明白为何要以下这么写,https://xbuba.com/questions/57035263
 | 
			
		||||
    if len(cipher_decoded) == 127:
 | 
			
		||||
        hex_fixed = '00' + cipher_decoded.hex()
 | 
			
		||||
        cipher_decoded = base64.b16decode(hex_fixed.upper())
 | 
			
		||||
    message = cipher.decrypt(cipher_decoded, b'error').decode()
 | 
			
		||||
    return message
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,6 +52,7 @@ def redirect_format_api(request, *args, **kwargs):
 | 
			
		|||
        return JsonResponse({"msg": "Redirect url failed: {}".format(_path)}, status=404)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@csrf_exempt
 | 
			
		||||
def redirect_old_apps_view(request, *args, **kwargs):
 | 
			
		||||
    path = request.get_full_path()
 | 
			
		||||
    if path.find('/core') != -1:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue