Skip to content

CORS + API Auth breaks #863

@ironhacker

Description

@ironhacker

I downloaded and compiled main to get the new CORS support and it works OK until I enable API Auth. Either setting works on its own, but both combined fail with a 401 Unauthorized on the preflight request. If I make the same GET request from Postman (no preflight) with API Key it's good.

export ENABLE_AUTH=true
export AUTH_DATA_SOURCE=file://auth.yaml (abbreviated here)
export AUTH_PROVIDER=apiKey (this seems required now - defaults to basic auth)

CORS + ENABLE_AUTH=false (this works fine)

CORS + ENABLE_AUTH=true (works in Postman, but fails in Browser with 401 in preflight)

My auth file looks like this. Aside: this seems confusing. Turning on auth should secure all endpoints by default. I have no idea what's leaking.

name: db2rest-security

resourceRoles:
  - resource: "/v1/rdbms/db/**"
    method: get
    roles:
      - admin
  - resource: "/v1/rdbms/db/**"
    method: post
    roles:
      - admin

apiKeys:
  - key: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    roles: [admin]
    active: true

Do I have a configuration issue? FYI I tried adding options explicitly - didn't help.

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions