Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashi_vault - enable use of tokens without lookup-self #24

Merged
merged 4 commits into from
Dec 23, 2020

Conversation

briantist
Copy link
Collaborator

SUMMARY

Fixes #18

The issue has most of the technical information.

The method we use to determine if a token is valid relies on the token having the ability to lookup itself. By default, all tokens inherit the "default" policy in Vault, and by default the default policy contains that capability.

However when you create a token you may request that it doesn't include the default policy. You may also modify an installation's default policy to remove this capability.

In these cases, it would be impossible to use that (perfectly valid) token with this plugin, because it would fail early attempts to validate it.

This PR adds a new option allowing you to optionally disable that early validation.

When disabled, the token will be used to query a secret without any other checks. This means that if your token is expired or otherwise invalid, you will see the same error message as if your token wasn't granted the right permission.

  • Adds a new boolean option token_validate to control whether a token should be validated
  • Adds tests to ensure that a no-default-policy token fails with validation on and works with validation off
  • Updated docs and examples
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

hashi_vault.py

ADDITIONAL INFORMATION

@briantist briantist added the bug Something isn't working label Dec 9, 2020
@codecov
Copy link

codecov bot commented Dec 9, 2020

Codecov Report

Merging #24 (45474c6) into main (052c724) will decrease coverage by 0.74%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
- Coverage   64.73%   63.98%   -0.75%     
==========================================
  Files           1        1              
  Lines         224      236      +12     
  Branches       44       42       -2     
==========================================
+ Hits          145      151       +6     
- Misses         64       71       +7     
+ Partials       15       14       -1     
Impacted Files Coverage Δ
...ommunity/hashi_vault/plugins/lookup/hashi_vault.py 63.98% <0.00%> (-0.75%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 052c724...45474c6. Read the comment docs.

briantist added a commit to briantist/community.hashi_vault that referenced this pull request Dec 9, 2020
@briantist briantist added the enhancement New feature or request label Dec 9, 2020
@briantist
Copy link
Collaborator Author

@rasta-rocket could you try out this change?

@briantist briantist added this to the v0.2.0 milestone Dec 13, 2020
@briantist briantist self-assigned this Dec 13, 2020
Copy link
Contributor

@rasta-rocket rasta-rocket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a little change
Great job 👍 💪👍 💪👍 💪👍 💪

plugins/lookup/hashi_vault.py Outdated Show resolved Hide resolved
Co-authored-by: Bruno FERNANDO <bruno.fernando@jobteaser.com>
@briantist
Copy link
Collaborator Author

Thanks @rasta-rocket good catch!
Were you able to try out the code itself?

@briantist
Copy link
Collaborator Author

Hey @rasta-rocket looking to get this merged and released, if you have a moment do you mind reviewing once more?

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest looks fine (didn't look at tests).

plugins/lookup/hashi_vault.py Outdated Show resolved Hide resolved
Co-authored-by: Felix Fontein <felix@fontein.de>
@briantist briantist merged commit 0f4665f into ansible-collections:main Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hashi_vault lookup plugin require auth/token/lookup-self policy on the Vault token to read secrets
3 participants