dwyl / dwyl/phoenix-ecto-encryption-example
Notes on README
- Dominant language
- Elixir
- Stars
- 291
- Forks
- 21
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 3
Description
@nelsonic This README is AWESOME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (I know this is not what issues are for but it really is amazing. Thanks so much)
I have gone through and made some points, and wanted to list them here. I can separate them out into different issues if needed and start working on them but just wanted to have them documented somewhere.
### Prerequisites?
> Basic understanding of Ecto (the module used to interface with databases in elixir/phoenix)
There is no link for this point (The previous points have links to learning repos). I have looked through the [learn-phoenix-framework](https://github.com/dwyl/learn-phoenix-framework) repo but couldn't find anything specific to just learning the basics of ecto (almost all the examples have something to do with ecto in them but nothing ecto specific). I was thinking that we could make a tutorial in the learn-phoenix repo that introduces that basics of ecto (migration/schema/repo) (I would be up for making this just to be clear 👍)
### Time Requirement?
> Simply reading ("skimming") through this example will only take 15 minutes.
Following the examples on your computer (to fully understand it) will take around 1 hour
Personally, I'm not a fan of the time thing as I feel it can make people feel down if they take longer. Just my opinion though.
## How
Before the
```elixir
mix ecto.migrate
```
command, we need to edit the migration file. It needs the following line added to it
```elixir
create(unique_index(:users, [:email_hash]))
```
This missing line was causing tests to fail later on in the example.
## 3. Define The 6 Functions
### 3.4 Hash Email Address
These tests depend on the `:secret_key_base`. They were failing for me following the example because mine was different. Not sure how best to resolve this. Could we use a pattern match similar to the [decrypt function](https://github.com/dwyl/phoenix-ecto-encryption-example/blob/master/lib/encryption/aes.ex#L66).
## 4 Create `EncryptedField` Custom Ecto Type
I know you suggest users write their own tests at this point so not really a problem but just thought I would mention this. The tests in [test/lib/encrypted_field_test.exs](https://github.com/dwyl/phoenix-ecto-encryption-example/blob/master/test/lib/encrypted_field_test.exs) do not test the `load/1` function (only the load/2). This function may not exist for people following the readme. (Again, not an issue, just mentioning it 👍)
## 5. Use EncryptedField Ecto Type in User Schema
```elixir
alias Encryption.EncryptedField
```
Also need to add `User` as an `alias` at this point as it is used in the `changeset` function.
## 8. Create PasswordField Ecto Type for Hashing Email Address
> def verify_pass(password, stored_hash) do
Argon2.verify_pass(password, stored_hash)
end
This functions name has been changed in error. Should be `verify_password`. Caused tests in `password_field_tests.exs` to fail.
### 10.2 Re-order :email_hash Field in User Schema
users schema never shows adding a `:password` field during the example
```elixir
field :password, :binary, virtual: true # virtual means "don't persist"`
```
This doesn't break any tests or anything. Just something I noticed. Was it added for the user interface mentioned in the conclusion?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.