authentik icon indicating copy to clipboard operation
authentik copied to clipboard

Add Application icon via API

Open 3isenHeiM opened this issue 1 year ago • 1 comments

Describe the bug I've tried to add an icon for an application, with a SVG file. I've used this call as stated in the doc, but the file is not correctly rendered.

2024-08-28_14-23

To Reproduce Here is the snippet I'm using:

def add_app_icon(hostname, token, slug, filename):

    if not os.path.isfile(filename):
        print("File '%s' not found. Exiting" %filename)
        exit(1)  

    url = "https://%s/api/v3/core/applications/%s/set_icon/" % (hostname, slug)

    payload = {}
    files={
        'file': ('file',open(filename,'rb'),'image/svg+xml'),
    }

    headers = {
      'Authorization': 'Bearer %s' % token
    }

    try:
        response = requests.request("POST", url, headers=headers, data=payload, files=files, verify=False)

        if not response.ok :
            response.raise_for_status()

        return response.json()

    except Exception as e:
        print(repr(e))
    return None

When firing this request I get an {} back as response content, and a HTTP 200. However the icon is not correctly rendered.

The HTTP POST call to set_icon/ is used upload the SVG but then I do not know how to get the path of the image file to update the application (using a PUT request?).

I've analyzed the API calls when performing this actions in a browser and it's the same behavior.

Expected behavior The SVG file being rendered correctly, or the docs to be updated accordingly.

Version and Deployment (please complete the following information):

  • authentik version: 2024.6.0
  • Deployment: docker-compose

3isenHeiM avatar Aug 28 '24 12:08 3isenHeiM

Might be linked to #11029.

3isenHeiM avatar Aug 30 '24 09:08 3isenHeiM

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Why is this marked as "wont-fix" ?

3isenHeiM avatar Oct 30 '24 18:10 3isenHeiM

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

We are aware of the file APIs to be less than optimal. We'll rework them at some point

rissson avatar Jan 06 '25 11:01 rissson

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.