Prototype of base64 wrapped encrypted value.#184
Conversation
93562be to
5e709b6
Compare
5e709b6 to
bfcd9ea
Compare
| def embed_as(_), | ||
| do: :dump | ||
|
|
||
| def equal?(term1, term2), |
There was a problem hiding this comment.
Ecto will skip dumping and loading if this is set to :self.
| # We got nil from the database... Just use that. | ||
| nil -> value | ||
| # We got any binary. Decode64 and decrypt. | ||
| <<>> <> _ -> value |> Base.decode64!(padding: true) |> AES.decrypt() |
There was a problem hiding this comment.
In a final version, probably we want to avoid the bang function. This is just to show how it would work!
There was a problem hiding this comment.
@hickscorp looks like a good addition. Running the workflow. 👌
Haha thank you - but as much as I appreciate that this would be useful, it's in no state to reach your codebase and was meant as a prototype / example. A few things, in case still of interest:
So. I unfortunately don't have enough time now, as I'm prototyping a product and just needed this "quick and dirty". If you want to do it, please take over my PR by all means! Otherwise I can do it later, but I can't guarantee when. Please don't merge this nasty code of mine, it's really meant as a proof of concept. |
Ok so - unable to use this for embeds or anything that stores into
JSONorJSONBat database / field level.That's because non-standard strings aren't possible to express without heavy escaping in JSON.
So why not wrap them into a B64 step?
Super-useful if you want to be able to use it in an
embedded_schema...Ah yeah also as a side note - if you have
def embed_as(_), do: :selfthen Ecto will skip thedumpandloadcalls silently. Not great, as it means that users who useFields.Encrypted*types won't know that they in fact aren't encrypting anything... I checked myself.So to force Ecto to
load/dump, I useddef embebd_as(_), do: :dumpand it seems to work for embeds as well now.