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

Encrypted payload support #263

Merged
merged 1 commit into from
Jun 15, 2017
Merged

Encrypted payload support #263

merged 1 commit into from
Jun 15, 2017

Conversation

bobjflong
Copy link
Contributor

No description provided.

cipher.encrypt
cipher.key = key
cipher.iv = initialization_vector
json = ActiveSupport::JSON.encode(payload).gsub('<', '\u003C')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pretty sure that this gsub is not necessary as the results are encrypted and Base64'd anyway. However retaining it for now.

cipher.iv = initialization_vector
json = ActiveSupport::JSON.encode(payload).gsub('<', '\u003C')
encrypted = initialization_vector + cipher.update(json) + cipher.final + cipher.auth_tag
Base64.encode64(encrypted).gsub("\n", "\\n")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just so that the result can be interpolated as JavaScript without a syntax error caused by line breaks.


ENCRYPTED_MODE_SETTINGS_WHITELIST = [:app_id, :session_duration, :widget, :custom_launcher_selector, :hide_default_launcher, :alignment, :horizontal_padding, :vertical_padding]

def initialize(secret, initialization_vector, options)

Choose a reason for hiding this comment

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

Could we just encapsulate the IV generation (through securerandom) and drop it from the list of the function args?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It helps to able to Dependency Inject it so that we can specify fixed IVs for things like testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kant01ne
Copy link
Contributor

looks good!

Failing specs because of ruby 1.9.3. we will need to upgrade intercom-ruby to a new major version to fix this before we ship this PR.

@kant01ne
Copy link
Contributor

FYI: Circle is not failing because of ruby version

@kant01ne
Copy link
Contributor

#264

@bobjflong
Copy link
Contributor Author

@Skaelv I'm pretty sure that the Circle failure is the same thing. This repo doesn't have a .ruby-version so Circle falls back to the default, which for Ubuntu 12.04 is ruby-1.9.3.

@kant01ne
Copy link
Contributor

Just merged my PR if you want to rebase

@bobjflong bobjflong changed the title WIP: encrypted payload spike Encrypted payload spike Jun 15, 2017
@bobjflong bobjflong changed the title Encrypted payload spike Encrypted payload support Jun 15, 2017
@bobjflong bobjflong merged commit 8d4b827 into master Jun 15, 2017
@bobjflong bobjflong deleted the BL/enc branch June 15, 2017 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants