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

Add support for encrypted Ecto String and Integer Array types #53

Merged
merged 2 commits into from
Feb 24, 2018

Conversation

boydm
Copy link
Contributor

@boydm boydm commented Jan 12, 2018

Had a need to encrypt an array of strings (a supported Ecto type) in the db. Example use case is a list of permissions in a record. This used to work in Cloak version 0.3 by using the EncryptedMapField because it was simply running the data through Json without actually casting into Ecto. Newer versions cloak do more type checking, so the Ecto type {:array, :string} fails now.

This PR creates two new encrypted field types corresponding to the Ecto types of {:array, :string} and {:array, :integer}. They are simple variations of the existing Map type. Docs and tests for both have been added/updated.

Now formatted...

@danielberkompas danielberkompas merged commit bd032ad into danielberkompas:master Feb 24, 2018
@danielberkompas
Copy link
Owner

@boydm Thanks! My notifications on this repo were messed up, so I only just saw this. Sorry for the delay.

@danielberkompas
Copy link
Owner

I released a new version with these changes: 0.6.0. Because Elixir doesn't have arrays, I chose to rename the types to IntegerListField and StringListField respectively.

@boydm
Copy link
Contributor Author

boydm commented Feb 27, 2018

Thanks!

Those field names are fine. The only reason I went with array in the name is because that is what it is called on the database side. It's one of those cases where it isn't obvious if it should have database-style naming or elixir-style naming. Lives in between the two.

I think you made the right choice.

And thank you for the library!

--Boyd

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.

2 participants