apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: openid-connect yml conf could not use $env to set plugin properties

Open 150149 opened this issue 1 year ago • 3 comments

Current Behavior

When I use yaml config to set plugin properties, apisix openid-connect plugin could not read $env://KEYCLOAK_PWDvalue. Environment variable can be seen through linux cmd:

echo $KEYCLOAK_PWD

But apisix plugin could not read those config properties

Expected Behavior

Apisix plugin can read those config properties

Error Logs

No response

Steps to Reproduce

  1. Create config(Show only key code)
  - uri: /api/xxx/*
    service_id: xxxx
    plugins:
      openid-connect:
        client_id: xxx
        client_secret: $ENV://KEYCLOAK_PWD
        discovery: xxxx
        scope: openid

Environment

  • APISIX version (3.2.0):
  • Operating system (Linux 3.10.0-1160.118.1.el7.x86_64 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux):
  • OpenResty / Nginx version (openresty/1.21.4.2):
  • etcd version, if relevant (not use):
  • APISIX Dashboard version, if relevant(not use)

150149 avatar Jun 04 '24 02:06 150149

Could you change $env: to all caps and try again? I remember some time ago there was a PR allowing ENV to be lower case, but that was definitely available after 3.2.0.

kayx23 avatar Jun 05 '24 05:06 kayx23

Could you change $env: to all caps and try again? I remember some time ago there was a PR allowing ENV to be lower case, but that was definitely available after 3.2.0.

client_secret: $ENV://FS_KEYCLOAK_PWD

Emmmm.....I've tried all caps and it doesn't work.

150149 avatar Jun 05 '24 05:06 150149

By checking you need to add local fetch_secrets = require("apisix.secret").fetch_secrets and

function _M.rewrite(plugin_conf, ctx)
    local conf = fetch_secrets(plugin_conf)

like https://github.com/apache/apisix/pull/11451

darkSheep404 avatar Aug 09 '24 08:08 darkSheep404

Duplicate of #12219

Baoyuantop avatar Jun 06 '25 03:06 Baoyuantop