$user->getUID(), 'fileId' => $file->getId(), 'isFileReadOnly' => $isFileReadOnly, 'user' => [ 'id' => $user->getUID(), 'name' => $user->getDisplayName() ], 'iat' => $issuedAt, 'exp' => $expirationTime ]; return $this->generateJWTFromPayload($payload); } /** * @throws InvalidPathException * @throws NotFoundException */ public function generateJWTFromPayload(array $payload): string { $key = $this->configService->getJwtSecretKey(); return JWT::encode($payload, $key, JWTConsts::JWT_ALGORITHM); } public function getUserIdFromJWT(string $jwt): string { try { $key = $this->configService->getJwtSecretKey(); $decoded = JWT::decode($jwt, new Key($key, JWTConsts::JWT_ALGORITHM)); return $decoded->userid; } catch (Exception) { throw new UnauthorizedException(); } } }