airflow: Incorrect implementation of GCP auth type in VaultBackend?
Short
I’m pretty sure the authentication flow for GCP in the airflow.providers.hashicorp.secrets.vault.VaultBackend is incorrect and not usable. The Vault API used /auth/gcp/config has a different purpose, /auth/gcp/login should be used instead.
I’ve seen the /auth/<type>/config API being used in a couple other auth types, e.g. RADIUS and Azure, so the problem is probably broader than just GCP.
It’s a bold statement as it means nobody has really used VaultBackend with these auth types. I may be wrong, but I would be surprised.
Details
I’ve analysed Airflow’s VaultBackend code while researching how to integrate Vault with GCP for a different project. Here’s the discrepancy I found between the current implementation and the Vault’s design.
Current implementation
GCP auth is implemented in vault_client.py#L277. The implementation delegates to official Vault client’s method that calls /auth/gcp/config while providing the Airflow’s GCP credentials to the call.
This is however an administrative API to configure Vault’s capability to verify JWT tokens via GCP API. The credentials expected are credentials for Vault to use when communicating with GCP IAM API, not application’s credentials. This is explained in /auth/gcp/config API docs. The API doesn’t respond with any data, so from the point of view of VaultBackend this call is basically just a no-op.
/auth/gcp/config call requires X-Vault-Token header with a token that has proper permissions. I’m guessing either this auth method was not tested at all or some administrative (root?) Vault token was passed (by mistake?) during manual tests? I haven’t seen any integration tests for the auth methods, I understand they would be difficult/costly.
Expected implementation
The proper API to use is /auth/gcp/login. It requires a signed JWT token issued by IAM’s signJwt based on application’s GCP credentials. It returns a Vault token to be passed in subsequent requests.
This is described in the Vault docs on GCP auth and on Google blog along with an implementation example Authenticating to HashiCorp Vault using Google Cloud IAM.
Am I missing something? What do you think about this?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 17 (14 by maintainers)
I can’t reopen it either. You need to recreate it by pushing a new branch and creating new PR.
@aaabramov -> I suggest to open a new issue about it. Ass I already commented above - tt makes very little sense to comment on an issue opened 3 years ago. Quite likely it’s related- but different issue and many of the things that were valid 3 years ago are not valid any more. And there is no point in tagging me again - I might or might not be involved in any way in diagnosing and solving the issue. Possibly people from google will get interested when you open a new issue (and link to that one marking it as imilar) and they migh help with it. Or other people might get interest and implement it.
By commenting on a closed issue you are limiting your visibility and a chance that someone will look at it. Highly recommend to open a new issue.
@potiuk I can confirm that this issue still exists.
Instead of login (
auth/{gcp}/login), airflow calls configure (auth/{gcp}/config). References:It should be changed to
_client.auth.gcp.login(...).@fpopic thanks for opening https://github.com/apache/airflow/pull/35855, this is a good start.
Moreover, for the same reason,
azureandradiusauthn won’t work as well.Not sure what you are asking for @fpopic -> but a) this issue is closed, b) we cannot assign anyone who is not a contributor or has not commented themselves on the issue.