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

provider/random: Add b64_std to random_id #9903

Merged
merged 2 commits into from
Nov 6, 2016
Merged

Conversation

jen20
Copy link
Contributor

@jen20 jen20 commented Nov 6, 2016

This commit makes three related changes to the random_id resource:

  1. Deprecate the b64 attribute.
  2. Introduce a new b64_url attribut which functions in the same manner as the original b64 attribute.
  3. Introduce a new b64_std attribute which uses standard base64 encoding for the value rather than URL encoding.

Resource identifiers continue to use URL encoded base 64.

The reason for adding standard encoding of the base 64 value is to allow the use of generated values as a Serf Encryption Key for separating Consul clusters - these rely on standard encoding and do not permit some characters which are allowed by URL encoding. b64_url is introduced in order that there is consistency in specifying the desired encoding during interpolation.

We also clean up the code for the random provider and move to using the more recent schema-provided Noop functions in preference to custom functions in the provider.

cc @sean-, @stack72

jen20 added 2 commits November 6, 2016 09:58
This commit makes three related changes to the `random_id` resource:

1. Deprecate the `b64` attribute
2. Introduce a new `b64_url` attribute which functions in the same
   manner as the original `b64` attribute
3. Introduce a new `b64_std` attribute which uses standard base64
   encoding for the value rather than URL encoding.

Resource identifiers continue to use URL encoded base 64.

The reason for adding standard encoding of the base 64 value is to allow
the use of generated values as a Serf Encryption Key for separating
Consul clusters - these rely on standard encoding and do not permit some
characters which are allowed by URL encoding. `b64_url` is introduced
in order that there is consistency in specifying the desired encoding
during interpolation.
Copy link
Contributor

@phinze phinze left a comment

Choose a reason for hiding this comment

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

LGTM!


byteLength := d.Get("byte_length").(int)
bytes := make([]byte, byteLength)

n, err := rand.Reader.Read(bytes)
if n != byteLength {
return fmt.Errorf("generated insufficient random bytes")
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to cover this here, but noting that this catches the global rand source and should probably be reworked to use a local one at some point.

@jen20 jen20 merged commit 65a8c7b into master Nov 6, 2016
@jen20 jen20 deleted the random-std-b64-encoding branch November 6, 2016 22:25
@ghost
Copy link

ghost commented Apr 20, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants