Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sticksnleaves/hora
Password management for Elixir
https://github.com/sticksnleaves/hora
comeonin ecto elixir elixir-lang password-manager
Last synced: about 2 months ago
JSON representation
Password management for Elixir
- Host: GitHub
- URL: https://github.com/sticksnleaves/hora
- Owner: sticksnleaves
- License: mit
- Created: 2017-03-27T16:41:38.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-31T17:29:15.000Z (over 7 years ago)
- Last Synced: 2024-10-30T16:55:52.867Z (2 months ago)
- Topics: comeonin, ecto, elixir, elixir-lang, password-manager
- Language: Elixir
- Size: 37.1 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hora
Assumption free, adapter based password management for Elixir.
## Installation
This package can be installed by adding `hora` to your list of dependencies in
`mix.exs`:```elixir
def deps do
[
{:hora, "~> 1.0.0"},
{:comeonin, "~> 3.0"}, # optional, needed for bcrypt and pbkdf2_sha512 support
{:ecto, "~> 2.1"} # optional, needed for changeset support
]
end
```## Adapters
Hora takes an adapter based strategy for defining the cryptographic functions
used to secure passwords. We provide support for bcrypt and pbkdf2_sha512 but
it's possible to use your own custom adapters as well.* [`Hora.Adapter.Bcrypt`](https://hexdocs.pm/hora/Hora.Adapter.Bcrypt.html)
* [`Hora.Adapter.Pbkdf2`](https://hexdocs.pm/hora/Hora.Adapter.Pbkdf2.html)## Usage
```elixir
iex> Hora.verify_password("uncrypted_password", "crypted_password")iex> Hora.secure_password("uncrypted_password")
```## Ecto
```elixir
defmodule MyModule do
use Ecto.Schemaschema "my_schema" do
field :password, :string, virtual: true
field :password_digest, :string
enddef changeset(schema, params) do
schema
|> cast(params, [:password])
|> Hora.Changeset.put_secure_password(:password, :password_digest)
end
end
```## Configuration
You can define which adapter to use and it's options in one of two ways:
1. Through application configuration
**Example**
```elixir
config :hora,
adapter: Hora.Adapter.Bcrypt,
adapter_options: [log_rounds: 14]
```
2. When using the Hora functions:**Example**
```elixir
Hora.secure_password("uncrypted_password", adapter: Hora.Adapter.Bcrypt)
``````elixir
Hora.verify_password("uncrypted_password", "crypted_password", adapter: Hora.Adapter.Bcrypt)
``````elixir
Hora.Changeset.put_secure_password("uncrypted_password", adapter: Hora.Adapter.Bcrypt)
```