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

Allow parameterising secret_key and ttl #2

Merged
merged 2 commits into from
May 26, 2022

Conversation

bjeanes
Copy link
Contributor

@bjeanes bjeanes commented May 24, 2022

This addresses #1 but with a different approach, which minimises the diff while maintaining backwards compatibility.

This allows context-specific keys to be used for encoding and decoding as well as context-specific ttls:

key = SecureRandom.bytes(32)
ciphertext = Branca.encode("sensitive information", secret_key: key)
Branca.decode(ciphertext, secret_key: key, ttl: 30)

@bjeanes
Copy link
Contributor Author

bjeanes commented May 24, 2022

I also made it so that DecodeError was raised. Though I realise this probably would NOT be a backwards compatible change and so could be removed. However, I saw that you had the exception defined but were not using it so assumed this to be your original intent.

@thadeu thadeu added the enhancement New feature or request label May 24, 2022
lib/branca.rb Outdated Show resolved Hide resolved
lib/branca.rb Show resolved Hide resolved
Copy link
Owner

@thadeu thadeu left a comment

Choose a reason for hiding this comment

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

@bjeanes Amazing your changes, simple and powerful! Keeping backwards compatible with other versions.

I added build and tests on gh actions in this repository in order to help our changes

Copy link
Owner

@thadeu thadeu left a comment

Choose a reason for hiding this comment

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

LGTM

@thadeu thadeu merged commit b610020 into thadeu:main May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants