westerveltco / django-opfield

A custom Django field for storing and securely accessing a 1Password vault item
https://django-opfield.westervelt.dev
MIT License
3 stars 0 forks source link

[ERROR] 2024/05/13 22:03:30 Unable to determine location of config directory. #12

Closed joshuadavidthomas closed 4 months ago

joshuadavidthomas commented 4 months ago

Trying to access the secret of a URI, I am getting this error from the 1Password CLI:

[ERROR] 2024/05/13 22:03:30 Unable to determine location of config directory.

Seems like explicitly setting the env of the subprocess.run is clobbering how op get the config for the CLI tool.

joshuadavidthomas commented 4 months ago

I only did that as a way to make sure the the token was set.

Couple of options:

  1. Don't do that and either just call the the get_op_service_account_token method when accessing the secret or in AppConfig.ready.
  2. Pass in the environ:

    result = subprocess.run(
       [op, "read", op_uri],
       capture_output=True,
       env={"OP_SERVICE_ACCOUNT_TOKEN": op_token, **os.environ},
       timeout=op_timeout,
    )
  3. Figure out op cli gets the config from the environment.