Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable CORS for Podman REST APIs #8645

Closed
adamchew89 opened this issue Dec 8, 2020 · 15 comments · Fixed by #11019
Closed

How to enable CORS for Podman REST APIs #8645

adamchew89 opened this issue Dec 8, 2020 · 15 comments · Fixed by #11019
Assignees
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@adamchew89
Copy link

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind feature

Description

Unable to call Podman REST API from web application due to CORS. How do I enable CORS on Podman REST API.
Able to overcome CORS issue for GET methods by installing firefox plugin https://mybrowseraddon.com/access-control-allow-origin.html but not working for POST methods.

Steps to reproduce the issue:

  1. Start Podman with: podman system service --time=50000 tcp:localhost:7080 --log-level=debug --time=0

  2. Manually create dummy pod with: podman pod create dummy

  3. On JSFiddle: Run the following with Javascript + jQuery 1.9.1
    $.get('http://localhost:7080/v1.40.0/libpod/pods/dummy/json').then(response=> console.log({response})).catch(error=>console.log({error}));

Describe the results you received:

Received CORS error:

Invalid X-Frame-Options header was found when loading “https://fiddle.jshell.net/_display/?editor_console=true”: “ALLOWALL” is not a valid directive.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:7080/v1.40.0/libpod/pods/dm-perception-pod-0/json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

{ "error": { "readyState": 0, "status": 0, "statusText": "error" } }

Describe the results you expected:

To receive Podman REST Api response that may look like this:
{ "Id": "c68c0db77cca1b632bf075f3b3c4bb90b056f21948a1f5f97d0dab4c1e385b65", "Name": "dummy", "Created": "2020-12-07T15:19:56.167536112+08:00", "CreateCommand": [ "podman", "pod", "create", "-n", "dummy" ], "State": "Running", "Hostname": "dummy", "CreateCgroup": true, "CgroupParent": "/libpod_parent", "CgroupPath": "/libpod_parent/c68c0db77cca1b632bf075f3b3c4bb90b056f21948a1f5f97d0dab4c1e385b65", "CreateInfra": true, "InfraContainerID": "e72e2d9521b4d95274dd5f4f43c6c451bd3bb351b03f7ad17b95ff1babfaf8b6", "InfraConfig": { "PortBindings": {}, "HostNetwork": false, "StaticIP": "", "StaticMAC": "", "NoManageResolvConf": false, "DNSServer": null, "DNSSearch": null, "DNSOption": null, "NoManageHosts": false, "HostAdd": null, "Networks": null, "NetworkOptions": null }, "SharedNamespaces": [ "uts", "ipc", "net" ], "NumContainers": 1, "Containers": [ { "Id": "e72e2d9521b4d95274dd5f4f43c6c451bd3bb351b03f7ad17b95ff1babfaf8b6", "Name": "c68c0db77cca-infra", "State": "running" } ] }

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Version:      2.2.0
API Version:  2.1.0
Go Version:   go1.15.2
Built:        Thu Jan  1 07:30:00 1970
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.18.0
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: 'conmon: /usr/libexec/podman/conmon'
    path: /usr/libexec/podman/conmon
    version: 'conmon version 2.0.20, commit: '
  cpus: 1
  distribution:
    distribution: ubuntu
    version: "20.04"
  eventLogger: journald
  hostname: d4a-VirtualBox
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.4.0-56-generic
  linkmode: dynamic
  memFree: 4413603840
  memTotal: 8248553472
  ociRuntime:
    name: runc
    package: 'runc: /usr/sbin/runc'
    path: /usr/sbin/runc
    version: 'runc version spec: 1.0.1-dev'
  os: linux
  remoteSocket:
    path: /run/user/1000/podman/podman.sock
  rootless: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: 'slirp4netns: /usr/bin/slirp4netns'
    version: |-
      slirp4netns version 1.1.7
      commit: unknown
      libslirp: 4.3.1-git
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.4.3
  swapFree: 2147479552
  swapTotal: 2147479552
  uptime: 44m 22.5s
registries:
  search:
  - docker.io
  - quay.io
store:
  configFile: /home/d4a/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 1
    stopped: 1
  graphDriverName: vfs
  graphOptions: {}
  graphRoot: /home/d4a/.local/share/containers/storage
  graphStatus: {}
  imageStore:
    number: 1
  runRoot: /run/user/1000/containers
  volumePath: /home/d4a/.local/share/containers/storage/volumes
version:
  APIVersion: 2.1.0
  Built: 0
  BuiltTime: Thu Jan  1 07:30:00 1970
  GitCommit: ""
  GoVersion: go1.15.2
  OsArch: linux/amd64
  Version: 2.2.0

Package info (e.g. output of rpm -q podman or apt list podman):

Listing... Done
podman/unknown,now 2.2.0~2 amd64 [installed]
podman/unknown 2.2.0~2 arm64
podman/unknown 2.2.0~2 armhf
podman/unknown 2.2.0~2 s390x

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):

VirtualBox 6.1 w/ Ubuntu 20.04.01 VM on Windows 10 host.

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 8, 2020
@github-actions
Copy link

github-actions bot commented Jan 8, 2021

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Jan 10, 2021

@adamchew89 Could you try this again against the latest code in main branch?

@rhatdan
Copy link
Member

rhatdan commented Jan 10, 2021

@jwhonce Can you help out @adamchew89 ?

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Feb 11, 2021

@adamchew89 Any progress on this?

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@jwhonce jwhonce added In Progress This issue is actively being worked by the assignee, please do not work on this at this time. and removed stale-issue In Progress This issue is actively being worked by the assignee, please do not work on this at this time. labels Mar 15, 2021
@jwhonce
Copy link
Member

jwhonce commented Mar 15, 2021

@adamchew89 The Podman team discussed adding this feature. We are open to making this change, but at this time do not see the demand to add the feature to our roadmap. We would be happy to accept a PR with the change.

/cc @baude

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan rhatdan added Good First Issue This issue would be a good issue for a first time contributor to undertake. and removed stale-issue labels Apr 15, 2021
@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@boaz0
Copy link
Collaborator

boaz0 commented Jun 2, 2021

@rhatdan @jwhonce can you assign it to me?

@rhatdan rhatdan assigned boaz0 and unassigned jwhonce Jun 2, 2021
@rhatdan
Copy link
Member

rhatdan commented Jun 2, 2021

You got it.

@github-actions
Copy link

github-actions bot commented Jul 5, 2021

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Jul 5, 2021

@boaz0 Did you ever get a chance to work on this?

@boaz0
Copy link
Collaborator

boaz0 commented Jul 5, 2021

I did work on it here #10546 and now what I need to do is writing tests for it and then I am OK with closing this.

@rhatdan
Copy link
Member

rhatdan commented Jul 7, 2021

Great.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants