@@ -37,15 +37,15 @@ class SecretApiController extends OCSController {
3737
3838 use Errors;
3939
40- public function __construct (IRequest $ request ,
41- SecretService $ service ,
40+ public function __construct (IRequest $ request ,
41+ SecretService $ service ,
4242 ISession $ session ,
43- NotificationService $ notificationService ,
43+ NotificationService $ notificationService ,
4444 INotificationManager $ notificationManager ,
45- IURLGenerator $ urlGenerator ,
46- IAppManager $ appManager ,
47- LoggerInterface $ logger ,
48- ?string $ userId ) {
45+ IURLGenerator $ urlGenerator ,
46+ IAppManager $ appManager ,
47+ LoggerInterface $ logger ,
48+ ?string $ userId ) {
4949 parent ::__construct (Application::APP_ID , $ request );
5050 $ this ->service = $ service ;
5151 $ this ->notificationService = $ notificationService ;
@@ -54,7 +54,7 @@ public function __construct(IRequest $request,
5454 $ this ->urlGenerator = $ urlGenerator ;
5555 $ this ->logger = $ logger ;
5656 $ this ->session = $ session ;
57- $ this ->appVersion = $ appManager ->getAppInfo (Application::APP_ID )[" version " ];
57+ $ this ->appVersion = $ appManager ->getAppInfo (Application::APP_ID )[' version ' ];
5858 }
5959
6060 /**
@@ -82,8 +82,8 @@ public function getAll(): DataResponse {
8282 * @param string $uuid The uuid of the secret
8383 *
8484 * @return DataResponse<Http::STATUS_OK, SecretsData, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array{message: string}, array{}>
85- * 200: Return secret with given uuid
86- * 404: Secret not found
85+ * 200: Return secret with given uuid
86+ * 404: Secret not found
8787 */
8888 public function get (string $ uuid ): DataResponse {
8989 return $ this ->handleNotFound (function () use ($ uuid ) {
@@ -98,7 +98,7 @@ public function get(string $uuid): DataResponse {
9898 * @NoCSRFRequired
9999 *
100100 * @return DataResponse<Http::STATUS_OK, array{version: string}, array{}>
101- * 200: Return application/api version
101+ * 200: Return application/api version
102102 *
103103 */
104104 #[AnonRateLimit(limit: 120 , period: 60 )]
@@ -116,9 +116,9 @@ public function getVersion(): DataResponse {
116116 * @param string|null $password The password for the secret share
117117 *
118118 * @return DataResponse<Http::STATUS_NOT_FOUND, array{message: string}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, array{message: string}, array{}>|DataResponse<Http::STATUS_OK, array{iv: string, encrypted: string}, array{}>
119- * 200: Return requested secret
120- * 404: Secret not found for uuid
121- * 401: Unauthorized
119+ * 200: Return requested secret
120+ * 404: Secret not found for uuid
121+ * 401: Unauthorized
122122 *
123123 */
124124 #[UserRateLimit(limit: 500 , period: 60 )]
@@ -128,22 +128,25 @@ public function getVersion(): DataResponse {
128128 public function retrieveSharedSecret (string $ uuid , ?string $ password ): DataResponse {
129129
130130 $ pwHash = null ;
131- $ pwHashLegacy = null ;
132131 if ($ password ) {
133- $ pwHashLegacy = hash ("sha256 " , $ password . $ uuid );
134132 $ pwHash = $ this ->service ->verifyPassword ($ uuid , $ password );
133+ if ($ pwHash === null ) {
134+ $ pwHash = hash ('sha256 ' , $ password . $ uuid );
135+ }
135136 } elseif ($ this ->session ->get ('public_link_authenticated_token ' ) === $ uuid ) {
136137 $ pwHash = $ this ->session ->get ('public_link_authenticated_password_hash ' );
137- $ pwHashLegacy = $ this ->session ->get ('public_link_authenticated_password_hash_legacy ' );
138+ } elseif ($ this ->session ->get ('public_link_authenticated_frontend ' )) {
139+ $ authPayload = json_decode ($ this ->session ->get ('public_link_authenticated_frontend ' ));
140+ $ pwHash = $ authPayload ->$ uuid ;
138141 }
139142 try {
140- $ secret = $ this ->service ->retrieveAndInvalidateSecret ($ uuid , $ pwHash, $ pwHashLegacy );
143+ $ secret = $ this ->service ->retrieveAndInvalidateSecret ($ uuid , $ pwHash );
141144 } catch (SecretNotFound $ e ) {
142- $ resp = new DataResponse ([" message " => " No secret with the given uuid was found " ], Http::STATUS_NOT_FOUND );
145+ $ resp = new DataResponse ([' message ' => ' No secret with the given uuid was found ' ], Http::STATUS_NOT_FOUND );
143146 $ resp ->throttle (['action ' => 'retrieval ' ]);
144147 return $ resp ;
145148 } catch (UnauthorizedException $ e ) {
146- $ resp = new DataResponse ([" message " => " Forbidden " ], Http::STATUS_UNAUTHORIZED );
149+ $ resp = new DataResponse ([' message ' => ' Forbidden ' ], Http::STATUS_UNAUTHORIZED );
147150 $ resp ->throttle (['action ' => 'password ' ]);
148151 return $ resp ;
149152 }
@@ -169,8 +172,8 @@ public function retrieveSharedSecret(string $uuid, ?string $password): DataRespo
169172 * @param ?string $password (Optional) password to protect the secret share
170173 *
171174 * @return DataResponse<Http::STATUS_CREATED, SecretsData, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, array{message: string}, array{}>
172- * 201: Secret created
173- * 401: Unauthorized
175+ * 201: Secret created
176+ * 401: Unauthorized
174177 */
175178 public function createSecret (string $ title , string $ encrypted , string $ iv , ?string $ expires , ?string $ password ) {
176179 if (!$ this ->userId ) {
@@ -187,8 +190,8 @@ public function createSecret(string $title, string $encrypted, string $iv, ?stri
187190 * @param string $title The new title of the secret
188191 *
189192 * @return DataResponse<Http::STATUS_OK, SecretsData, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array{message: string}, array{}>
190- * 200: Return updated secret
191- * 404: Secret not found
193+ * 200: Return updated secret
194+ * 404: Secret not found
192195 */
193196 public function updateTitle (string $ uuid , string $ title ): DataResponse {
194197 return $ this ->handleNotFound (function () use ($ uuid , $ title ) {
@@ -203,8 +206,8 @@ public function updateTitle(string $uuid, string $title): DataResponse {
203206 * @param string $uuid The uuid of the secret
204207 *
205208 * @return DataResponse<Http::STATUS_OK, array{message: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array{message: string}, array{}>
206- * 200: Secret deleted
207- * 404: Secret not found
209+ * 200: Secret deleted
210+ * 404: Secret not found
208211 */
209212 public function delete (string $ uuid ): DataResponse {
210213 try {
0 commit comments