summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorDouglas Mendizábal <mail@doug.gt>2015-02-06 15:52:26 -0600
committerDouglas Mendizábal <mail@doug.gt>2015-02-06 16:14:40 -0600
commit741550e6e1f8be5211db83b1c46bf06c53924ce0 (patch)
tree1c198b492a5982ab1e2c8b1dec39434168cb3c8b /doc
parent5cc121bfc050629c5daa2baf64543e072e6199a9 (diff)
downloadpython-barbicanclient-741550e6e1f8be5211db83b1c46bf06c53924ce0.tar.gz
Change usage example to show plain/text secret
Change the main example to use a plain/text payload because of the unexpected behavior in the current example. Change-Id: I7f16e973fdd9e67f7f98267a0067bb795071dc26 Related-Bug: #1419166
Diffstat (limited to 'doc')
-rw-r--r--doc/source/usage.rst21
1 files changed, 13 insertions, 8 deletions
diff --git a/doc/source/usage.rst b/doc/source/usage.rst
index ac9768e..9ee5b40 100644
--- a/doc/source/usage.rst
+++ b/doc/source/usage.rst
@@ -32,19 +32,24 @@ class that is exposed as the `secrets` attribute of the Client.
Example::
- # Create a random encryption key and store it in Barbican
+ # Store a random plain text password in Barbican
- import base64
- import os
from barbicanclient import client
+ import random
+ import string
+
+ def random_password(length):
+ sys_random = random.SystemRandom()
+ return u''.join(
+ sys_random.choice(string.ascii_letters + string.digits) for _ in range(length)
+ )
barbican = client.Client(...)
my_secret = barbican.secrets.create()
- my_secret.name = 'Encryption Key'
- my_secret.payload = base64.b64encode(os.urandom(32))
- my_secret.payload_content_type = 'application/octet-stream'
- my_secret.payload_content_encoding = 'base64'
+ my_secret.name = u'Random plain text password'
+ my_secret.payload = random_password(24)
+ my_secret.payload_content_type = u'text/plain'
my_secret_ref = my_secret.store()
@@ -56,7 +61,7 @@ Example::
# Retrieve Secret from secret reference
retrieved_secret = barbican.secrets.get(my_secret_ref)
- key = retrieved_secret.payload
+ my_password = retrieved_secret.payload
Orders
======