Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ An upload that would exceed the quota is refused with `507`. A quota of 0 or les
| `region` | Region | string | empty | Region. Empty uses the `AWS_REGION` environment variable, and then the value `reposilite`. |
| `prefix` | Key Prefix | string | empty | Prefix for all object keys, for a bucket that other services share. |
| `sharedBucket` | Shared Bucket | boolean | `false` | Places the objects under the repository id, so several repositories can share one bucket. |
| `pathStyleAccess` | Path Style Access | boolean or unset | unset | Uses path-style addresses (`https://host/bucket/key`) for this repository. When unset, the system property `reposilite.s3.pathStyleAccessEnabled` decides. |
| `metadataCacheSettings` | Local Metadata Cache | object or absent | absent | Local cache for object metadata. The default is no caching. Each instance has its own cache. Mutable metadata (`maven-metadata*` and `-SNAPSHOT` directories) is never cached, and with a cluster bus an entry is used for at most 300 seconds. |

Without both keys, Ingot uses the default AWS credential chain. Two JVM system properties change the S3 client: `reposilite.s3.pathStyleAccessEnabled=true` turns on path style access, and `reposilite.s3.use-s3-v4-signer=true` selects the V4 signer.
Expand Down
3 changes: 2 additions & 1 deletion docs/gitbook/references/repositories/storage-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Unverified at run time. In the code of this release, the usage that the file sys
| `region` | String | empty | no | Region. See [Region and credentials](#region-and-credentials). |
| `prefix` | String | empty | no | Prefix for all object keys, for example to share a bucket with other services. Leading and trailing slashes are removed. |
| `sharedBucket` | Boolean | `false` | no | Puts the objects of each repository under `<prefix>/<repository id>/`, so several repositories can share one bucket. |
| `pathStyleAccess` | Boolean or null | `null` | no | Uses path-style addresses (`https://host/bucket/key`) for this repository when set. When `null`, the system property `reposilite.s3.pathStyleAccessEnabled` decides. |
| `metadataCacheSettings` | Object or null | `null` | no | Local cache for object metadata such as the file size. `null` caches nothing. |

Fields of `metadataCacheSettings`:
Expand Down Expand Up @@ -111,7 +112,7 @@ These are JVM system properties and have no environment variable form. Pass them
| `reposilite.s3.use-s3-v4-signer` | `false` | Signs requests with the AWS S3 V4 signer. |
| `reposilite.s3.skip-bucket-creation` | `false` | Does not create the bucket at start when it does not exist. By default Ingot creates a missing bucket. |

They apply to every S3 repository of the instance. There is no per-repository setting for them.
They apply to every S3 repository of the instance. `reposilite.s3.pathStyleAccessEnabled` is the fallback of the per-repository `pathStyleAccess` setting: a repository that sets it ignores the property. The other two have no per-repository setting.

### Upload path

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class S3StorageProviderFactory(
settings: S3StorageProviderSettings
): S3StorageProvider {
val client = S3Client.builder()
val pathStyleAccessEnabled = System.getProperty("reposilite.s3.pathStyleAccessEnabled") == "true"
val pathStyleAccessEnabled = settings.resolvePathStyleAccess()

if (pathStyleAccessEnabled) {
client.serviceConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ data class S3StorageProviderSettings(
val sharedBucket: Boolean = false,
@get:Doc(title = "Local Metadata Cache", description = "Local metadata cache settings (optional). The default is no caching. NOTE: This cache is local only. If you run multiple instances, they will not share the cache!")
val metadataCacheSettings: S3MetadataCacheSettings? = null,
@get:Doc(title = "Path Style Access", description = "Address the bucket as https://host/bucket/key, which most S3-compatible servers such as MinIO need (optional). When unset, the JVM property reposilite.s3.pathStyleAccessEnabled decides")
val pathStyleAccess: Boolean? = null,
) : StorageProviderSettings, SharedNamespaceAware, SupportDetails {

/**
Expand Down Expand Up @@ -91,6 +93,15 @@ data class S3StorageProviderSettings(

}

/**
* Path-style addressing: the setting decides when it is set, and the JVM property [propertyValue]
* (`reposilite.s3.pathStyleAccessEnabled`) decides when it is not.
*/
internal fun S3StorageProviderSettings.resolvePathStyleAccess(
propertyValue: String? = System.getProperty("reposilite.s3.pathStyleAccessEnabled"),
): Boolean =
pathStyleAccess ?: (propertyValue == "true")

/** Separates the parts of a namespace key. It cannot occur in an endpoint, a bucket name or a configured prefix. */
private const val NAMESPACE_SEPARATOR = "\u0000"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2026 OneLiteFeather
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.reposilite.storage.s3

import com.reposilite.ReposiliteObjectMapper.DEFAULT_OBJECT_MAPPER
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class S3PathStyleAccessTest {

@Test
fun `should use virtual host addressing when the setting is false and the property is true`() {
val settings = S3StorageProviderSettings(pathStyleAccess = false)

assertThat(settings.resolvePathStyleAccess(propertyValue = "true")).describedAs("setting false beats property true").isFalse()
}

@Test
fun `should use path style when the setting is true and the property is absent`() {
val settings = S3StorageProviderSettings(pathStyleAccess = true)

assertThat(settings.resolvePathStyleAccess(propertyValue = null)).describedAs("setting true without property").isTrue()
}

@Test
fun `should use path style when the setting is unset and the property is true`() {
val settings = S3StorageProviderSettings()

assertThat(settings.resolvePathStyleAccess(propertyValue = "true")).describedAs("unset falls back to the property").isTrue()
}

@Test
fun `should use virtual host addressing when the setting is unset and the property is absent`() {
val settings = S3StorageProviderSettings()

assertThat(settings.resolvePathStyleAccess(propertyValue = null)).describedAs("unset without property").isFalse()
}

@Test
fun `should load a document without the field as unset and write no value for it`() {
val settings = DEFAULT_OBJECT_MAPPER.readValue("""{"type":"s3","bucketName":"maven"}""", S3StorageProviderSettings::class.java)
val written = DEFAULT_OBJECT_MAPPER.readTree(DEFAULT_OBJECT_MAPPER.writeValueAsString(settings))

assertThat(settings.pathStyleAccess).describedAs("field of an old document").isNull()
assertThat(written.get("pathStyleAccess")?.isNull ?: true).describedAs("written value of an unset field").isTrue()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
}
},
"type" : [ "object", "null" ]
},
"pathStyleAccess" : {
"type" : [ "boolean", "null" ],
"description" : "Address the bucket as https://host/bucket/key, which most S3-compatible servers such as MinIO need (optional). When unset, the JVM property reposilite.s3.pathStyleAccessEnabled decides",
"title" : "Path Style Access"
}
}
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@
"title" : "Local Metadata Cache",
"description" : "Local metadata cache settings (optional). The default is no caching. NOTE: This cache is local only. If you run multiple instances, they will not share the cache!"
} ]
},
"pathStyleAccess" : {
"type" : [ "boolean", "null" ],
"title" : "Path Style Access",
"description" : "Address the bucket as https://host/bucket/key, which most S3-compatible servers such as MinIO need (optional). When unset, the JVM property reposilite.s3.pathStyleAccessEnabled decides"
}
},
"title" : "S3 Storage Provider",
Expand Down
Loading