envoy icon indicating copy to clipboard operation
envoy copied to clipboard

plugin call credentials is supported by default today ?

Open quanjielin opened this issue 8 years ago • 4 comments

Description: In one our user case, we want to set gRPC call credential from some file content(the file is in envoy container). My question is : Is there any extra work needs to be done to make plugin call credentials work ? Or it should work by default with correct configuration (and how to) ?

From code, comment inside function callCredentials says // We don't handle plugin credentials here, callers can do so instead if they want. and plugin call credentials in extension pkg already supported reading cred from file today.

Repro steps:

  1. below is from envoy config I used (confirmed /var/run/secrets/tokentest/vault-token file exists in envoy container and has data in it, also the account envoy runs as is the file owner so no permission issue)
[
  {
    "google_grpc": {
      "target_uri": "unix:/var/run/sds/uds_path",
      "channel_credentials": {
        "local_credentials": {}
      },
      "call_credentials": [
        {
          "from_plugin": {
            "name": "envoy.grpc_credentials.file_based_metadata",
            "config": {
              "secret_data": {
                "filename": "/var/run/secrets/tokentest/vault-token"
              },
              "header_key": "istio-header"
            }
          }
        }
      ],
      "stat_prefix": "sdsstat"
    }
  }
]

  1. didn't see istoi-header header from envoy's request

quanjielin avatar Oct 05 '18 23:10 quanjielin

/cc @qiwzhang @lizan @htuch

quanjielin avatar Oct 05 '18 23:10 quanjielin

@quanjielin could you add following line into your google_grpc config

credentials_factory_name: envoy.grpc_credentials.file_based_metadata

it should be at the same level as targer_uri

qiwzhang avatar Oct 08 '18 05:10 qiwzhang

after adding that, envoy failed in validation step(validate against real k8s sa jwt token)

E1008 16:21:51.098493878      20 plugin_credentials.cc:95]   Plugin added invalid metadata value.
[2018-10-08 16:21:51.098][11][warning][upstream] external/envoy/source/common/config/grpc_mux_impl.cc:243] gRPC config stream closed: 13, 
E1008 16:21:51.128181499      19 plugin_credentials.cc:94]   validate_metadata_from_plugin: 

quanjielin avatar Oct 08 '18 16:10 quanjielin

token is passed successfully with below config, thanks @qiwzhang !

    "tls_certificate_sds_secret_configs": [
      {
        "name": "default",
        "sds_config": {
          "api_config_source": {
            "api_type": "GRPC",
            "grpc_services": [
              {
                "google_grpc": {
                  "target_uri": "unix:/var/run/sds/uds_path",
                  "channel_credentials": {
                    "local_credentials": {}
                  },
                  "call_credentials": [
                    {
                      "from_plugin": {
                        "name": "envoy.grpc_credentials.file_based_metadata",
                        "config": {
                          "header_key": "istio_sds_credentail_header-bin",
                          "secret_data": {
                            "filename": "/var/run/secrets/tokentest/vault-token"
                          }
                        }
                      }
                    }
                  ],
                  "stat_prefix": "sdsstat",
                  "credentials_factory_name": "envoy.grpc_credentials.file_based_metadata"
                }
              }
            ]
          }
        }
      }
    ]

quanjielin avatar Oct 08 '18 17:10 quanjielin