Make expiration of URLs configurable#783
Draft
daniel-beck wants to merge 1 commit intojenkinsci:masterfrom
Draft
Make expiration of URLs configurable#783daniel-beck wants to merge 1 commit intojenkinsci:masterfrom
daniel-beck wants to merge 1 commit intojenkinsci:masterfrom
Conversation
jglick
reviewed
Mar 10, 2026
Comment on lines
+264
to
+266
| if (expiration.isZero()) { | ||
| return blob.getMetadata().getUri().toURL(); | ||
| } |
Member
jglick
reviewed
Mar 10, 2026
| @NonNull | ||
| public abstract URL toExternalURL(@NonNull Blob blob, @NonNull HttpMethod httpMethod) throws IOException; | ||
| public URL toExternalURL(@NonNull Blob blob, @NonNull HttpMethod httpMethod) throws IOException { | ||
| return toExternalURL(blob, httpMethod, Duration.ofSeconds(SystemProperties.getInteger(BlobStoreProvider.class.getName() + ".DEFAULT_DURATION_SECONDS", 3600))); |
Member
There was a problem hiding this comment.
Use SystemProperties.getDuration.
jglick
reviewed
Mar 10, 2026
| @Override | ||
| public URL toExternalURL() throws IOException { | ||
| return provider.toExternalURL(getBlob(), HttpMethod.GET); | ||
| return provider.toExternalURL(getBlob(), HttpMethod.GET, Duration.ofSeconds(SystemProperties.getInteger(JCloudsVirtualFile.class.getName() + ".EXPIRATION_SECONDS", 60))); |
jglick
reviewed
Mar 10, 2026
| blob.getMetadata().setContainer(this.getContainer()); | ||
| blob.getMetadata().getContentMetadata().setContentType(contentTypes.get(entry.getValue())); | ||
| artifactUrls.put(entry.getValue(), this.toExternalURL(blob, HttpMethod.PUT, s3Presigner)); | ||
| artifactUrls.put(entry.getValue(), this.toExternalURL(blob, HttpMethod.PUT, s3Presigner, Duration.ofHours(1))); |
Member
There was a problem hiding this comment.
What is this duration? Why is it not configurable?
jglick
reviewed
Mar 10, 2026
| */ | ||
| @NonNull | ||
| public abstract URL toExternalURL(@NonNull Blob blob, @NonNull HttpMethod httpMethod) throws IOException; | ||
| public URL toExternalURL(@NonNull Blob blob, @NonNull HttpMethod httpMethod) throws IOException { |
Member
There was a problem hiding this comment.
Not implemented externally, no need to offer a compat layer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We got a report from someone who wanted to reduce the pre-signed URL validity period from the default of 1 hr.
This PR implements that as a pair of system properties:
io.jenkins.plugins.artifact_manager_jclouds.JCloudsVirtualFile.EXPIRATION_SECONDSis the validity of the pre-signed URL that a user is redirected to when accessing an artifact, in seconds. The default is reduced from 1 hr to 1 minute. If set to 0, the plugin will not generate a pre-signed URL, and the links won't work for anyone accessing them directly (unless the bucket is public I guess).io.jenkins.plugins.artifact_manager_jclouds.BlobStoreProvider.DEFAULT_DURATION_SECONDSis the validity of the pre-signed external URL forarchive,stash, andunstashoperations, in seconds. This remains 1 hr by default. This addition will also allow users for whom 1 hr of archiving isn't enough to tune the expiration of that to be longer.This is for your consideration. Test coverage (actual, e.g., minio-based coverage so far is pretty minimal, so a bit more effort) and docs will follow if accepted in principle.
Testing done
Manual so far, with a local Minio server and script console
System.setProperty('io.jenkins.plugins.artifact_manager_jclouds.JCloudsVirtualFile.EXPIRATION_SECONDS', '…'):Locally set expiration to 0 and got redirected to an XML
AccessDeniederror page.Locally set expiration to 5, downloaded an artifact, reloaded the URL a few seconds later and got
AccessDenied.Please note that locally for
hpi:runI neededbecause the current parent pom doesn't resolve transitive dependencies correctly.
Submitter checklist