kratos icon indicating copy to clipboard operation
kratos copied to clipboard

Can not pass JSON to environment variable

Open halvardssm opened this issue 2 years ago • 2 comments

Preflight checklist

Describe the bug

Hi! I am trying to overwrite the Kratos config file, specifically the self-service-registration-hooks-flow by providing the SELFSERVICE_FLOWS_REGISTRATION_AFTER_PASSWORD_HOOKS environment variable, however, I only get errors when providing an array in JSON format as specified here.

Reproducing the bug

I have tried multiple versions of the env var, but neither of them works, here are all the versions I have tried (with and without quotes '):

SELFSERVICE_FLOWS_REGISTRATION_AFTER_PASSWORD_HOOKS='[{}]'
SELFSERVICE_FLOWS_REGISTRATION_AFTER_PASSWORD_HOOKS='[]'
SELFSERVICE_FLOWS_REGISTRATION_AFTER_PASSWORD_HOOKS='[{"hook":"session"}]'

Relevant log output

No matter what I try, I always get an error similar to this:


The configuration contains values or keys which are invalid:
selfservice.flows.registration.after: map[password:map[hooks:[{"hook":"sessions"}]]]
                                      ^-- doesn't validate with "#/definitions/selfServiceAfterRegistration"

The configuration contains values or keys which are invalid:
selfservice.flows.registration.after.password: map[hooks:[{"hook":"sessions"}]]
                                               ^-- doesn't validate with "#/definitions/selfServiceAfterRegistrationMethod"

The configuration contains values or keys which are invalid:
selfservice.flows.registration.after.password.hooks: [{"hook":"sessions"}]
                                                     ^-- expected array, but got string


### Relevant configuration

```yml
selfservice:
  flows:
    registration:
      lifespan: 10m
      ui_url: https://localhost:3000/register
      after:
        password:
          hooks:
            - hook: web_hook
              config:
                url: https://localhost:3001/create-user
                method: POST
                body: file:///post-registration-hook.jsonnet

Version

0.10.1

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Docker

Additional Context

No response

halvardssm avatar Aug 10 '22 20:08 halvardssm

It’s not recommended to set complex config values using env vars, please use a config file instead :)

aeneasr avatar Aug 10 '22 23:08 aeneasr

I understand, but in my case, I simply want to remove all hooks or disable them. Is there a way to remove one or multiple hooks from the config file by using environment variables? I also tried with null or undefined, but that gave a similar error :/

halvardssm avatar Aug 11 '22 06:08 halvardssm