11/*
2- * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
2+ * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1717package com .iexec .resultproxy .proxy ;
1818
1919import com .iexec .common .result .ResultModel ;
20- import com .iexec .common .security .SignedChallenge ;
2120import com .iexec .commons .poco .chain .WorkerpoolAuthorization ;
22- import com .iexec .commons .poco .eip712 .entity .EIP712Challenge ;
2321import com .iexec .resultproxy .authorization .AuthorizationService ;
24- import com .iexec .resultproxy .challenge .ChallengeService ;
2522import com .iexec .resultproxy .ipfs .task .IpfsNameService ;
2623import com .iexec .resultproxy .jwt .JwtService ;
2724import lombok .extern .slf4j .Slf4j ;
3734public class ProxyController {
3835
3936 private final AuthorizationService authorizationService ;
40- private final ChallengeService challengeService ;
4137 private final JwtService jwtService ;
4238 private final ProxyService proxyService ;
4339 private final IpfsNameService ipfsNameService ;
4440
4541 public ProxyController (AuthorizationService authorizationService ,
46- ChallengeService challengeService ,
4742 JwtService jwtService ,
4843 ProxyService proxyService ,
4944 IpfsNameService ipfsNameService ) {
5045 this .authorizationService = authorizationService ;
51- this .challengeService = challengeService ;
5246 this .jwtService = jwtService ;
5347 this .proxyService = proxyService ;
5448 this .ipfsNameService = ipfsNameService ;
5549 }
5650
57- /**
58- * @deprecated Use new endpoint with valid {@code WorkerpoolAuthorization}
59- */
60- @ Deprecated (forRemoval = true )
61- @ GetMapping (value = "/results/challenge" )
62- public ResponseEntity <EIP712Challenge > getChallenge (@ RequestParam (name = "chainId" ) Integer chainId ) {
63- EIP712Challenge eip712Challenge = challengeService .createChallenge (chainId );
64- return ResponseEntity .ok (eip712Challenge );
65- }
66-
67- /**
68- * @deprecated Use new endpoint with valid {@code WorkerpoolAuthorization}
69- */
70- @ Deprecated (forRemoval = true )
71- @ PostMapping (value = "/results/login" )
72- public ResponseEntity <String > login (@ RequestParam (name = "chainId" ) Integer chainId ,
73- @ RequestBody String token ) {
74- SignedChallenge signedChallenge = challengeService .tokenToSignedChallengeObject (token );
75- if (!challengeService .isSignedChallengeValid (signedChallenge )) {
76- return ResponseEntity .status (HttpStatus .UNAUTHORIZED ).build ();
77- }
78-
79- String jwtString = jwtService .getOrCreateJwt (signedChallenge .getWalletAddress ());
80- if (jwtString == null || jwtString .isEmpty ()) {
81- return ResponseEntity .status (HttpStatus .INTERNAL_SERVER_ERROR ).build ();
82- }
83-
84- challengeService .invalidateChallenge (signedChallenge .getChallengeHash ());
85- return ResponseEntity .ok (jwtString );
86- }
87-
8851 /**
8952 * Logs against Result Proxy with valid {@code WorkerpoolAuthorization}.
53+ * <p>
54+ * The address of the signer needs to be stored in the {@code workerWallet} field of {@code WorkerpoolAuthorization}
9055 */
9156 @ PostMapping ("/v1/results/token" )
9257 public ResponseEntity <String > getJwt (@ RequestHeader ("Authorization" ) String authorization ,
@@ -104,16 +69,6 @@ public ResponseEntity<String> getJwt(@RequestHeader("Authorization") String auth
10469 return ResponseEntity .ok (jwtString );
10570 }
10671
107- /**
108- * @deprecated Use {@code /v1/results} endpoint, will be removed in v10
109- */
110- @ Deprecated (forRemoval = true )
111- @ PostMapping ("/" )
112- public ResponseEntity <String > addResultDeprecated (@ RequestHeader ("Authorization" ) String token ,
113- @ RequestBody ResultModel model ) {
114- return addResult (token , model );
115- }
116-
11772 /**
11873 * Push result on IPFS through iExec Result Proxy.
11974 *
@@ -152,16 +107,6 @@ public ResponseEntity<String> addResult(@RequestHeader("Authorization") String t
152107 return ok (resultLink );
153108 }
154109
155- /**
156- * @deprecated Use {@code /v1/results/{chainTaskId}} endpoint, will be removed in v10
157- */
158- @ Deprecated (forRemoval = true )
159- @ RequestMapping (method = RequestMethod .HEAD , path = "/results/{chainTaskId}" )
160- public ResponseEntity <String > isResultUploadedDeprecated (@ PathVariable (name = "chainTaskId" ) String chainTaskId ,
161- @ RequestHeader ("Authorization" ) String token ) {
162- return isResultUploaded (chainTaskId , token );
163- }
164-
165110 /**
166111 * Checks if a given task has been uploaded on IPFS through the current iExec Result Proxy instance.
167112 *
@@ -186,15 +131,6 @@ public ResponseEntity<String> isResultUploaded(@PathVariable(name = "chainTaskId
186131 return ResponseEntity .status (status ).build ();
187132 }
188133
189- /**
190- * @deprecated Use {@code /v1/results/{chainTaskId}/ipfshash} endpoint, will be removed in v10
191- */
192- @ Deprecated (forRemoval = true )
193- @ GetMapping ("/results/{chainTaskId}/ipfshash" )
194- public ResponseEntity <String > getIpfsHashForTaskDeprecated (@ PathVariable ("chainTaskId" ) String chainTaskId ) {
195- return getIpfsHashForTask (chainTaskId );
196- }
197-
198134 /**
199135 * Retrieves ipfsHash for taskId if required
200136 *
0 commit comments