CherryPoppins

CherryPoppins

Storing API credentials in DB

Let’s say I have an app that handles ordering bubble gum for clients. Each client has their own API credentials for the bubble gum supplier. I handle placing orders for more bubble gum by sending an order request using the client’s API keys. When I had one client I stored their API creds as an ENV and accessed them when making a requests to the bubble gum supplier that way. Now I have more than one client and I need to store all of their API credentials so I can use each client’s API keys accordingly to place orders via API requests.

What is the best way to store these with security in mind? Encrypt the keys then store in DB as :string and decrypt before inserting the keys into the request? If so is there a recommended library for encryption? I’m using Postgres if that matters.

Most Liked

OvermindDL1

OvermindDL1

Encrypting is fine, though if you want what’s generally regarded as high security if it’s really that important then I use Consul by Hashicorp, it’s exceedingly powerful for holding encrypted data like access tokens. Encrypting in the database is “fine” but where you hold the decryption key really really matters (in which case something like consul is also great for holding the decryption key). The main important thing is to make it as hard as possible for someone to get that key and what it decrypts even if they have access to the server.

stefanchrobot

stefanchrobot

cloak_ecto is the library that you’re after.

CherryPoppins

CherryPoppins

Are you referring to Cloak.Ecto hexdocs? If so, I don’t think I just want it encrypted in the DB. My fear with that would be the Account info would be accidentally preloaded or otherwise pulled from the DB and thrown around the code base where not needed. So, i like the idea of having to intentionally decrypt the account info specifically when I am adding it to the api request, otherwise its always encrypted. So, I am looking at Cloak and wondering if that library is trusted.

stefanchrobot

stefanchrobot

I think that redacting the field would address your concerns.

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

We're in Beta

About us Mission Statement