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

Unable to set array config options via environment variables #342

Closed
cgearing opened this issue Jan 20, 2020 · 8 comments · Fixed by #384
Closed

Unable to set array config options via environment variables #342

cgearing opened this issue Jan 20, 2020 · 8 comments · Fixed by #384
Assignees
Labels
bug Something is not working. help wanted We are looking for help on this one.
Milestone

Comments

@cgearing
Copy link

Describe the bug

There doesn't seem to be a way to provide the value for a configuration key that expects an array via an enrivonment variable.

Reproducing the bug

For example, with a docker-compose.yml like

  oathkeeper:
    image: oryd/oathkeeper
    ports:
      - "127.0.0.1:8091:4455"
    volumes:
      - ./ory/rules.yml:/ory/rules/rules.yml
    environment:
      SERVE_API_PORT: 4456
      SERVE_API_HOST: ""
      SERVE_PROXY_PORT: 4455
      SERVE_PROXY_HOST: ""
      LOG_LEVEL: debug
      AUTHENTICATORS_JWT_ENABLED: "true"
      MUTATORS_HEADER_ENABLED: "true"
      AUTHORIZERS_ALLOW_ENABLED: "true"
      AUTHENTICATORS_NOOP_ENABLED: "true"
      ACCESS_RULES_REPOSITORIES: "file://ory/rules/rules.yml"
      SERVE_API_CORS_ENABLED: "true"
      SERVE_API_CORS_ALLOWED_HEADERS: "['Access-Control-Allow-Origin','Authorization']"
      CORS_ALLOWED_ORIGINS: "*"
      SERVE_API_CORS_DEBUG: "true"

the following error would be produced.

Server logs

oathkeeper_1              | time="2020-01-20T10:59:15Z" level=warning msg="No config file was defined and no file was found in $HOME/.oathkeeper.yaml" error="Config File \".oathkeeper\" Not Found in \"[/]\""
oathkeeper_1              | time="2020-01-20T10:59:15Z" level=fatal msg="The configuration is invalid and could not be loaded." error="invalid type. Expected: array, given: string" validation_error[0]="serve.api.cors.allowed_headers: Invalid type. Expected: array, given: string"

Expected behavior

Some clear instructions of how to provide an array of values to these keys would be really helpful. Alternatively, if it's not possible to parse these from environment variables, a little note in the docs would be great :)

Environment

  • Version: ORY Oathkeeper v0.35.1-beta.1+oryOS.15
  • Environment: Docker with Docker-Compose
@aeneasr
Copy link
Member

aeneasr commented Jan 20, 2020

Ah yeah, I've struggled with this as well. I think the right way to do that is (in yaml):

SERVE_API_CORS_ALLOWED_HEADERS: "Access-Control-Allow-Origin,Authorization"

@cgearing
Copy link
Author

I get the same response from Oathkeeper with that syntax unfortunately!

@aeneasr
Copy link
Member

aeneasr commented Jan 20, 2020

Hm too bad, you could also try:

SERVE_API_CORS_ALLOWED_HEADERS: "Access-Control-Allow-Origin, Authorization"
SERVE_API_CORS_ALLOWED_HEADERS: "[Access-Control-Allow-Origin,Authorization]"

If none of these work it might be a better idea to mount a config volume.

@cgearing
Copy link
Author

The approach I've gone for is to mount a config file - it's just a shame you can't seem to define everything via envars unless I'm missing something!

@aeneasr
Copy link
Member

aeneasr commented Jan 20, 2020

Yeah, this has always been a problem with env vars. I'll keep this open to remind myself to check what the right syntax is actually

@aeneasr
Copy link
Member

aeneasr commented Jan 20, 2020

Ok, I checked the syntax - Access-Control-Allow-Origin, Authorization and Access-Control-Allow-Origin,Authorization should both work but it appears to be an issue with our configuration pipeline that causes this to be treated as a regular string. Tracking as a bug!

@zepatrik
Copy link
Member

needs ory/viper#14

@zepatrik
Copy link
Member

zepatrik commented Mar 25, 2020

Just for anyone curious: the correct syntax is comma separated values (standard csv)

@aeneasr aeneasr added help wanted We are looking for help on this one. and removed up for grab labels Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working. help wanted We are looking for help on this one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants