Skip to content

Commit

Permalink
Update wrapping.rst - example for unauthenticated unwrap (#789)
Browse files Browse the repository at this point in the history
* Update wrapping.rst

Provide example of using unwrap with just the wrapping token. Previous example is non-functional unless already authenticated.

* update example

* correct automethod name

* doctest fixes

---------

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
  • Loading branch information
nneul and briantist committed Jan 29, 2023
1 parent 026d6b5 commit ee0a9e6
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions docs/usage/system_backend/wrapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ Wrapping

Unwrap
------
Is Sealed
---------

.. automethod:: hvac.api.system_backend.Seal.is_sealed
.. automethod:: hvac.api.system_backend.Wrapping.unwrap
:noindex:

Examples
Expand Down Expand Up @@ -49,6 +47,34 @@ Example output:
Unwrapped approle role token secret id accessor: "..."


.. testcode:: sys_wrapping

import hvac

client = hvac.Client(url='https://127.0.0.1:8200')
client.write(
path="auth/approle-test/role/testrole",
)
result = client.write(
path='auth/approle-test/role/testrole/secret-id',
wrap_ttl="10s",
)
result_token = result['wrap_info']['token']

unwrapping_client = hvac.Client(url='https://127.0.0.1:8200', token=result_token)

# Do not pass the token to unwrap when authenticating with the wrapping token
unwrap_response = unwrapping_client.sys.unwrap()

print('Unwrapped approle role token secret id accessor: "%s"' % unwrap_response['data']['secret_id_accessor'])

Example output:

.. testoutput:: sys_wrapping

Unwrapped approle role token secret id accessor: "..."


.. testcleanup:: sys_wrapping

client.sys.disable_auth_method(
Expand Down

0 comments on commit ee0a9e6

Please sign in to comment.