Auth.Apikey (auth v1.6.6)
Defines apikeys schema and CRUD functions
Link to this section Summary
Functions
create_api_key/1
uses the encrypt_encode/1
to create an API Key
that is just two strings joined with a forwardslash ("/").
This allows us to use a single environment variable.
decode_decrypt/1
accepts a key
and attempts to Base58.decode
followed by AES.decrypt it. If decode or decrypt fails, return 0 (zero).
encrypt_encode/1
does exactly what it's name suggests,
AES Encrypts a string of plaintext and then Base58 encodes it.
We encode it using Base58 so it's human-friendly (readable).
Updates a apikey.
Link to this section Functions
changeset(apikey, attrs)
create_api_key(id)
create_api_key/1
uses the encrypt_encode/1
to create an API Key
that is just two strings joined with a forwardslash ("/").
This allows us to use a single environment variable.
create_apikey(app)
decode_decrypt(key)
decode_decrypt/1
accepts a key
and attempts to Base58.decode
followed by AES.decrypt it. If decode or decrypt fails, return 0 (zero).
decrypt_api_key(key)
encrypt_encode(plaintext)
encrypt_encode/1
does exactly what it's name suggests,
AES Encrypts a string of plaintext and then Base58 encodes it.
We encode it using Base58 so it's human-friendly (readable).
get_apikey_by_app_id(app_id)
update_apikey(apikey, attrs)
Updates a apikey.
examples
Examples
iex> update_apikey(apikey, %{field: new_value})
{:ok, %Apikey{}}
iex> update_apikey(apikey, %{field: bad_value})
{:error, %Ecto.Changeset{}}