Skip to content

Conversation

Edouard-chin
Copy link
Member

@Edouard-chin Edouard-chin commented May 13, 2019

Allow on_rotation in MessageEncryptor to be passed in constructor:

  • Use case:

    I'm writing a wrapper around MessageEncryptor to make things easier
    to rotate a secret in our app.

    It currently works something like

    crypt = RotatableSecret.new(['old_secret', 'new_secret'])
    crypt.decrypt_and_verify(message, on_rotation: -> { ... })

    I'd like the caller to not have to care about passing the
    on_rotation option and have the wrapper deal with it when
    instantiating the MessageEncryptor object.

    Also, almost all of the time the on_rotation should be the same when
    rotating a secret (logging something or StatsD event) so I think
    it's not worth having to repeat ourselves each time we decrypt a message.

@Edouard-chin Edouard-chin force-pushed the ec-on-rotation-constructor branch 2 times, most recently from ac1a51f to 59c20fd Compare May 14, 2019 16:58
@Edouard-chin
Copy link
Member Author

cc/ @rafaelfranca (since I know you declared bankruptcy on notifications recently 😄)

@kaspth
Copy link
Contributor

kaspth commented May 26, 2019

I'm curious what you're doing in on_rotation just passing data to statsd?

@Edouard-chin
Copy link
Member Author

thanks for the feedbacks, pushed a new commit.

I'm curious what you're doing in on_rotation just passing data to statsd?

Yeah just passing data to statsd to know when the old secrets is no longer used.

@Edouard-chin Edouard-chin force-pushed the ec-on-rotation-constructor branch 2 times, most recently from 8b8e0a5 to 95e9974 Compare June 6, 2019 12:13
Copy link
Contributor

@kaspth kaspth left a comment

Choose a reason for hiding this comment

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

Now we just got to get a passing build.

I've been trying to rebuild but then the checkout fails https://buildkite.com/rails/rails/builds/61568#_

@Edouard-chin
Copy link
Member Author

Thanks I'll try to amend/force push a bit later today. Might just be some network blips

- Use case:

  I'm writing a wrapper around MessageEncryptor to make things easier
  to rotate a secret in our app.

  It works something like
  ```ruby
  crypt = RotatableSecret.new(['old_secret', 'new_secret'])
  crypt.decrypt_and_verify(message)
  ```

  I'd like the caller to not have to care about passing the
  `on_rotation` option and have the wrapper deal with it when
  instantiating the MessageEncryptor object.

  Also, almost all of the time the on_rotation should be the same when
  rotating a secret (logging something or StatsD event) so I think
  it's not worth having to repeat ourselves each time we decrypt a message.
@Edouard-chin Edouard-chin force-pushed the ec-on-rotation-constructor branch from 95e9974 to a5502f4 Compare June 6, 2019 13:21
@Edouard-chin
Copy link
Member Author

should be good now

@kaspth kaspth merged commit 480d9f2 into rails:master Jun 6, 2019
@Edouard-chin Edouard-chin deleted the ec-on-rotation-constructor branch June 6, 2019 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants