kopia lustrzana https://github.com/nextcloud/social
				
				
				
			set the source of the signature (header or ld-json signature)
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/226/head
							rodzic
							
								
									1dda85adaa
								
							
						
					
					
						commit
						a636ec03a3
					
				|  | @ -167,9 +167,9 @@ class ActivityPubController extends Controller { | |||
| 
 | ||||
| 			$activity = $this->importService->importFromJson($body); | ||||
| 			if (!$this->signatureService->checkObject($activity)) { | ||||
| 				$activity->setOrigin($origin); | ||||
| 				$activity->setOrigin($origin, SignatureService::ORIGIN_HEADER); | ||||
| 			} | ||||
| 			 | ||||
| 
 | ||||
| 			try { | ||||
| 				$this->importService->parseIncomingRequest($activity); | ||||
| 			} catch (UnknownItemException $e) { | ||||
|  | @ -208,7 +208,7 @@ class ActivityPubController extends Controller { | |||
| 
 | ||||
| 			$activity = $this->importService->importFromJson($body); | ||||
| 			if (!$this->signatureService->checkObject($activity)) { | ||||
| 				$activity->setOrigin($origin); | ||||
| 				$activity->setOrigin($origin, SignatureService::ORIGIN_HEADER); | ||||
| 			} | ||||
| 
 | ||||
| 			try { | ||||
|  |  | |||
|  | @ -103,6 +103,9 @@ class Item { | |||
| 	/** @var string */ | ||||
| 	private $origin = ''; | ||||
| 
 | ||||
| 	/** @var int */ | ||||
| 	private $originSource = 0; | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * @return string | ||||
|  | @ -432,13 +435,23 @@ class Item { | |||
| 		return $this->origin; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * @return int | ||||
| 	 */ | ||||
| 	public function getOriginSource(): int { | ||||
| 		return $this->originSource; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * @param string $origin | ||||
| 	 * | ||||
| 	 * @param int $source | ||||
| 	 * | ||||
| 	 * @return Item | ||||
| 	 */ | ||||
| 	public function setOrigin(string $origin): Item { | ||||
| 	public function setOrigin(string $origin, int $source): Item { | ||||
| 		$this->origin = $origin; | ||||
| 		$this->originSource = $source; | ||||
| 
 | ||||
| 		return $this; | ||||
| 	} | ||||
|  | @ -512,7 +525,6 @@ class Item { | |||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * @return string | ||||
| 	 */ | ||||
|  |  | |||
|  | @ -56,6 +56,10 @@ class SignatureService { | |||
| 	use TArrayTools; | ||||
| 
 | ||||
| 
 | ||||
| 	const ORIGIN_HEADER = 1; | ||||
| 	const ORIGIN_SIGNATURE = 2; | ||||
| 
 | ||||
| 
 | ||||
| 	const DATE_FORMAT = 'D, d M Y H:i:s T'; | ||||
| 	const DATE_DELAY = 30; | ||||
| 
 | ||||
|  | @ -165,7 +169,7 @@ class SignatureService { | |||
| 			$signature->import(json_decode($object->getSource(), true)); | ||||
| 			$signature->setPublicKey($this->retrieveKey($actorId)); | ||||
| 			if ($signature->verify()) { | ||||
| 				$object->setOrigin($this->getKeyOrigin($actorId)); | ||||
| 				$object->setOrigin($this->getKeyOrigin($actorId), SignatureService::ORIGIN_SIGNATURE); | ||||
| 
 | ||||
| 				return true; | ||||
| 			} | ||||
|  | @ -294,6 +298,7 @@ class SignatureService { | |||
| 	 * @throws SocialAppConfigException | ||||
| 	 * @throws UnknownItemException | ||||
| 	 * @throws RedundancyLimitException | ||||
| 	 * @throws InvalidOriginException | ||||
| 	 */ | ||||
| 	private function retrieveKey($keyId): string { | ||||
| 		$actor = $this->cacheActorService->getFromId($keyId); | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Maxence Lange
						Maxence Lange