diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index a5f4a4a895a..d9e92a820ba 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -29,6 +29,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released - Fixed a bug where deleting a dataset would fail if its representation on disk was already missing. [#6720](https://github.com/scalableminds/webknossos/pull/6720) - Fixed a bug where a user with multiple organizations could not log in anymore after one of their organization accounts got deactivated. [#6719](https://github.com/scalableminds/webknossos/pull/6719) - Fixed rare crash in new Datasets tab in dashboard. [#6750](https://github.com/scalableminds/webknossos/pull/6750) and [#6753](https://github.com/scalableminds/webknossos/pull/6753) +- Fixed a bug where remote datasets without authentication could not be explored. [#6764](https://github.com/scalableminds/webknossos/pull/6764) ### Removed diff --git a/app/models/binary/credential/CredentialService.scala b/app/models/binary/credential/CredentialService.scala index 8012d59280e..ab206fc362d 100644 --- a/app/models/binary/credential/CredentialService.scala +++ b/app/models/binary/credential/CredentialService.scala @@ -1,7 +1,11 @@ package models.binary.credential import com.scalableminds.util.tools.Fox -import com.scalableminds.webknossos.datastore.storage.{HttpBasicAuthCredential, S3AccessKeyCredential} +import com.scalableminds.webknossos.datastore.storage.{ + FileSystemsHolder, + HttpBasicAuthCredential, + S3AccessKeyCredential +} import utils.ObjectId import java.net.URI @@ -17,7 +21,7 @@ class CredentialService @Inject()(credentialDao: CredentialDAO) { organization: String)(implicit ec: ExecutionContext): Fox[Option[ObjectId]] = { val scheme = uri.getScheme scheme match { - case "https" => + case FileSystemsHolder.schemeHttps => username match { case Some(u) => val _id = ObjectId.generate @@ -25,11 +29,10 @@ class CredentialService @Inject()(credentialDao: CredentialDAO) { _ <- credentialDao.insertOne( _id, HttpBasicAuthCredential(uri.toString, u, password.getOrElse(""), user, organization)) - _ <- credentialDao.findOne(_id) } yield Some(_id) - case None => Fox.empty + case None => Fox.successful(None) } - case "s3" => + case FileSystemsHolder.schemeS3 => username match { case Some(keyId) => password match { @@ -39,11 +42,10 @@ class CredentialService @Inject()(credentialDao: CredentialDAO) { _ <- credentialDao.insertOne( _id, S3AccessKeyCredential(uri.toString, keyId, secretKey, user, organization)) - _ <- credentialDao.findOne(_id) } yield Some(_id) - case None => Fox.empty + case None => Fox.successful(None) } - case None => Fox.empty + case None => Fox.successful(None) } } } diff --git a/app/models/binary/explore/ExploreRemoteLayerService.scala b/app/models/binary/explore/ExploreRemoteLayerService.scala index 983ef7d7a21..aa0cfe72a98 100644 --- a/app/models/binary/explore/ExploreRemoteLayerService.scala +++ b/app/models/binary/explore/ExploreRemoteLayerService.scala @@ -144,11 +144,12 @@ class ExploreRemoteLayerService @Inject()(credentialService: CredentialService) requestingUser: User)(implicit ec: ExecutionContext): Fox[List[(DataLayer, Vec3Double)]] = for { remoteSource <- tryo(RemoteSourceDescriptor(new URI(normalizeUri(layerUri)), user, password)).toFox ?~> s"Received invalid URI: $layerUri" - credentialId <- credentialService.createCredential(new URI(normalizeUri(layerUri)), - user, - password, - requestingUser._id.toString, - requestingUser._organization.toString) + credentialId <- credentialService.createCredential( + new URI(normalizeUri(layerUri)), + user, + password, + requestingUser._id.toString, + requestingUser._organization.toString) ?~> "Failed to set up remote file system credentaial" fileSystem <- FileSystemsHolder.getOrCreate(remoteSource).toFox ?~> "Failed to set up remote file system" remotePath <- tryo(fileSystem.getPath(remoteSource.remotePath)) ?~> "Failed to get remote path" layersWithVoxelSizes <- exploreRemoteLayersForRemotePath( diff --git a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/storage/FileSystemsHolder.scala b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/storage/FileSystemsHolder.scala index ff41d7cf9b5..fa14bb9cc89 100644 --- a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/storage/FileSystemsHolder.scala +++ b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/storage/FileSystemsHolder.scala @@ -18,9 +18,9 @@ class FileSystemsProvidersCache(val maxEntries: Int) extends LRUConcurrentCache[ object FileSystemsHolder extends LazyLogging { - private val schemeS3 = "s3" - private val schemeHttps = "https" - private val schemeHttp = "http" + val schemeS3: String = "s3" + val schemeHttps: String = "https" + val schemeHttp: String = "http" private val fileSystemsCache = new FileSystemsCache(maxEntries = 100) private val fileSystemsProvidersCache = new FileSystemsProvidersCache(maxEntries = 100)