bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management service but I’m not finding any. Ideally I’d be able to switch from say Google Cloud KMS to AWS KMS seamlessly with minimal configuration.
I’ve thought about open sourcing something that does this but I’m hesitant to create yet another project that may or may not be useful so I figure I’d check here first!
I already have a Google KMS adapter written using the elixir-google-api library and the following interface:
defmodule KMS do
@type key_details :: KMS.KeyDetails.t()
@type public_key :: JOSE.JWK.t()
@type list_keys_response :: {:ok, [key_details]} | {:error, any}
@type public_key_response :: {:ok, public_key} | {:error, any}
@type sign_response :: {:ok, KMS.Signature.t()} | {:error, any}
@client Application.compile_env!(:my_app, [__MODULE__, :client])
@callback list_keys(opts :: keyword) :: list_keys_response
@callback get_public_key(key_id :: String.t(), opts :: keyword) :: public_key_response
@callback sign(String.t(), key_id :: String.t(), opts :: keyword) :: sign_response
@spec list_keys(keyword) :: list_keys_response
def list_keys(opts), do: @client.list_keys(opts)
@spec list_keys!(keyword) :: [key_details]
def list_keys!(opts) do
case list_keys(opts) do
{:ok, keys} -> keys
{:error, error} -> raise KMS.NoKeyDetailsFoundError, message: "#{inspect(error)}"
end
end
@spec get_public_key(String.t(), keyword) :: public_key_response
def get_public_key(key_id, opts), do: @client.get_public_key(key_id, opts)
@spec get_public_key!(String.t(), keyword) :: public_key
def get_public_key!(key_id, opts) do
case get_public_key(key_id, opts) do
{:ok, public_key} -> public_key
{:error, error} -> raise KMS.NoPublicKeyFoundError, message: "#{inspect(error)}"
end
end
@spec sign(String.t(), String.t(), keyword) :: sign_response
def sign(message, key_id, opts), do: @client.sign(message, key_id, opts)
end
Trending in Questions
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
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
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
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
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
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
chulkilee
I don’t know if there is one for KMS - but you may use adapter pattern (like Tesla for HTTP client) to have general interface and specific implementation modules.
However I’m not sure we can have a good abstraction of KMS; I’ve used three KMS but they are slightly different - especially auth and details on options. I’ve built own domain/context module for my abstraction/policy etc. wrapping existing library instead of making generic wrapper for all KMS provider for that reason.
Do you have any similar libraries for KMS in other languages?
bradley
I’m also unsure whether there’s a good abstraction for KMS. As I’ve mentioned, I’ve been able to switch from Google Cloud to AWS without any change to the core KMS interface. Auth details do vary but I think those are more implementation details of the specific cloud provider and I think aren’t concerns for the core interface.
Not that I’m aware of.