Skip to content

UrlGen.buildFullUrl() does not use the "signed" parameter #4

@oliverhenlich

Description

@oliverhenlich

When using the src parameter (rather than path) I've noticed that url signing is not implemented.
This can be seen when looking at the source code for UrlGen.buildFullUrl() where the signed parameter is never used.

This is a show stopper for us because:

  • We are planning to use your "Web Proxy" as an origin.
  • This means we must enable "Restrict Unsigned Image Urls" in the global settings to prevent unauthorized use of this resizing service.
  • Some of our use cases involve pointing to existing Imagekit urls.
  • All urls are generated using the ImageKit client library which omits the signing parameters and as a result the url is not usable.

As a workaround I thought perhaps I could configure a separate "Url Pattern" that does not use the "Web Proxy" origin and thus does not need to have its urls signed. However it seems like the "Restrict Unsigned Image Urls" switch is a global switch and can't be configured for individual "Url Patterns". Maybe I'm wrong and there is a way?

Here is a full example demonstrating the problem.
It would also be good not to crash with a NullPointerException when the options do not include the optional transformation option (see example below).

import io.imagekit.sdk.ImageKit;
import io.imagekit.sdk.config.Configuration;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class Clip1 {
    public static void main(String[] args) {
        ImageKit imageKit = ImageKit.getInstance();
        imageKit.setConfig(new Configuration("public_<key>", "private_<key>", "https://ik.imagekit.io/imagekitId"));

        Map<String, Object> options = new HashMap<>();
        options.put("src", "https://ik.imagekit.io/imagekitId/path/file.jpg");
        options.put("signed", true);
        options.put("expireSeconds", 100);
        options.put("urlEndpoint", "https://ik.imagekit.io/imagekitId");

        // Omitting this causes a NullPointerException
        options.put("transformation", Collections.emptyList());

        String url = imageKit.getUrl(options);
        System.out.println("url = " + url);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions