diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MavenFacade.kt b/reposilite-backend/src/main/kotlin/com/reposilite/maven/MavenFacade.kt index 84830028d..e789c2d97 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MavenFacade.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/maven/MavenFacade.kt @@ -88,6 +88,17 @@ class MavenFacade internal constructor( handler = handler ) + fun getAvailableFiles(request: LookupRequest, directoryInfo: DirectoryInfo): List = + getRepository(request.repository)!!.let { repository -> + directoryInfo.files.filter { + repositorySecurityProvider.canBrowseResource( + accessToken = request.accessToken, + repository = repository, + gav = request.gav.resolve(it.name) + ).isOk + } + } + fun createLatestBadge(lookupRequest: LatestBadgeRequest): Result = findLatestVersion(lookupRequest.toVersionLookupRequest()) .flatMap { latestService.createLatestBadge(lookupRequest, it.version) } diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/DirectoryIndexPage.kt b/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/DirectoryIndexPage.kt index d965b5ff3..43a5682fd 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/DirectoryIndexPage.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/DirectoryIndexPage.kt @@ -1,9 +1,9 @@ package com.reposilite.maven.infrastructure -import com.reposilite.storage.api.DirectoryInfo +import com.reposilite.storage.api.FileDetails import com.reposilite.storage.api.FileType -internal fun createDirectoryIndexPage(basePath: String, uri: String, directory: DirectoryInfo): String { +internal fun createDirectoryIndexPage(basePath: String, uri: String, authenticatedFiles: List): String { val formattedUri = basePath + uri.removePrefix("/") // language=html @@ -34,7 +34,7 @@ internal fun createDirectoryIndexPage(basePath: String, uri: String, directory:
  • Parent Directory
  • - ${directory.files.flatMap { + ${authenticatedFiles.flatMap { listOf( "
  • ", "${it.name}${if (it.type == FileType.DIRECTORY) "/" else ""}", diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenEndpoints.kt b/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenEndpoints.kt index 7e7eb0d6d..047d7564d 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenEndpoints.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenEndpoints.kt @@ -101,7 +101,7 @@ internal class MavenEndpoints( createDirectoryIndexPage( basePath = frontendFacade.formattedBasePath.get(), uri = ctx.uri(), - directory = details, + authenticatedFiles = mavenFacade.getAvailableFiles(request, details), ) ) else ->