dstockdale

dstockdale

I’m just wondering if anyone knows if there’s an equivalent approach / library in Elixir to credentials that came out in Rails 5.2

I dismissed it at first but since I’ve been battling with Ansible and setting tonnes of environment variables by using ansible-vault edit ... on a project I’ve realised it’s quite cool. It means I don’t really need the indirection and complexity that Ansible brings to just changing a few configuration variables.

If you’ve no idea what it is it’s just an encrypted yaml file. Your encrypted yaml can be checked into your repo as it’s encrypted, so deploying configs is suddenly easy.

You edit config/credentials.yml.enc with rails credentials:edit which decrypts the file and let’s you change the config vars and carry on. I like the idea of being able to do this in Elixir apps too. Is there anything out there or is this a terrible idea?

Showing Posts 1 to 9

idi527

idi527

I like this idea. I think it shouldn’t be too difficult to implement with elixir … If you use distillery, you would probably copy the encrypted config into release’s priv/ and decrypt / read it into memory during application’s startup hooks. Then in each of your apps’ init callbacks you would have access to the decrypted config.

dstockdale

dstockdale OP

Cool. I like the sound of that. I might have a go at doing it when I get some free time.

carlosoteras

carlosoteras

Hello everyone :grinning_face_with_smiling_eyes: Rails 5.2 introduced a new feature called Credentials and I think that is a good feature for Phoenix (or elixir) sometimes we have a build server and prod server in build server we need environment variables to build a project with Distillery, the point is that’s not easy to change environment variables to each project pipeline and usually we use (puppet, chef, etc) for that things. I’ll be very happy if have a possibility to add the project credentials together with the project (encrypted). To learn more about credentials.

rails/rails#30067

webdeb

webdeb

Can you provide an example for those secret settings?

carlosoteras

carlosoteras

Config:

credentials :dev, 
  username: "dev_user",
  password: "user123"
  aws: [secret_access_key: "123467"]

credentials :prod, 
  username: "example"
  password: "hardpassword123"

API:

Credential.get(:username)
Credential.get(:password)
Credential.get([:aws, :secret_access_key])
webdeb

webdeb

You need your configs at the run-time, so you could use env variables for this.
I can recommend confex

config :credentials, 
  username: {:system, "USERNAME", "dev_user"},
  password: {:system, "PASSWORD", "dev_user"}.
  aws: [secret_access_key: {:system, "AWS_SECRET_KEY", "1234567"}]

At startup of you App, just do

defmodule MyApp do
  use Application

  def start(_type, _args) do
    # Replace Application environment with resolved values
    Confex.resolve_env!(:credentials)

    # ...
  end
end

This way you will be able to access your configs via the usual
Application.get_env(:credentials, :username)

brightball

brightball

Have we had the .secret files for a while? That seems mostly equivalent, except that it’s not supposed to go in your repo.

Doesn’t seem like it would take much to do an encrypt/decrypt on that file.

carlosoteras

carlosoteras

I didn’t know about confex, seems very useful.

kieraneglin

kieraneglin

Hopping in this a little late, but I just created my first Elixir library and it handles encrypted secrets much like Rails! Let me know what you think: GitHub - kieraneglin/encrypted_secrets_ex: Store your application's secrets inside your VCS · GitHub

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews