Skoda091

Skoda091

Cognitex - Module for managing user acounts through AWS Cognito service

I have recently created a small library for managing user accounts through AWS Cognito service.

Cognitex

The following functionality is covered;

  • User registration

  • Confirm registration (with the confirmation code received from AWS, by email)

  • User authentication

  • Fetch user data by an access token

  • Fetch user data by username

  • Change user password

  • Update user attributes

  • Reset a forgotten password

Installation

To use cognitex with your projects, edit your mix.exs file to add it as a dependency:

def deps do
[
  {:cognitex, "~> 0.1.0"}
]
end

Configuration

An example config might look like this:

config :aws,
  key: "<AWS_ACCESS_KEY_ID>",
  secret: "<AWS_SECRET_ACCESS_KEY>",
  region: "<AWS_REGION>",
  client_id: "<AWS_CLIENT_ID>",
  user_pool_id: "<AWS_USER_POOL_ID>"

Set up AWS Cognito with the correct configuration

First, we will set up a new AWS Cognito user pool with the correct configuration.

  1. Visit your AWS console and go to the AWS Cognito service. Click on “Manage your User Pools” and click “Create a User Pool”.

  2. Specify a name for your pool and click “Review Defaults”.

  3. Optional: edit the password policy to remove some of the requirements. If you are just testing, using simple passwords will make it easier.

  4. Click the “edit client” link. Specify a name for your app and be sure to disable the client secret and enable the ADMIN_NO_SRP_AUTH option.

  5. Click “Create pool”. Take note of the Pool Id at the top of the page and click on the apps page. Here, take note of the App client id.

Usage

iex> Cognitex.sign_up("john.smith@example.com", "Test123", name: "John", family_name: "Smith")
{:ok,
  %{
    "CodeDeliveryDetails" => %{
      "AttributeName" => "email",
      "DeliveryMedium" => "EMAIL",
      "Destination" => "j***@e***.co"
      },
      "UserConfirmed" => false,
      "UserSub" => "uuid"
      }
   }

iex> Cognitex.sign_up("john.smith@example.com", "Test123", name: "John", family_name: "Smith")

{:error,
  %{
    message: "An account with the given email already exists.",
    status: "UsernameExistsException"
  }
}

Full documentation is available here.

Thanks!

Where Next?

Popular in Libraries Top

Qqwy
TypeCheck: Fast and flexible runtime type-checking for your Elixir projects. Core ideas Type- and function specifications are const...
336 13801 100
New
woutdp
Hi! I wanted to introduce my latest project LiveSvelte. It allows you to render Svelte inside LiveView with end-to-end reactivity. It’s ...
New
michalmuskala
Another small library today. PersistentEts Hex: persistent_ets | Hex GitHub: GitHub - michalmuskala/persistent_ets Ets table backed by...
New
benlime
I created a new library GitHub - benvp/ex_cva: Class Variance Authority for Elixir which aims to make it very easy to define different va...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
martinthenth
Hello everybody :wave: Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New
Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
Antrater
Hi everyone! I’m thrilled to announce a huge thing. We have been developing Elixir Moon Design System for quite a while. We are finally ...
New
mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story &lt;- Meeseeks.all(html, css("tr.athing")) do...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
381 12391 119
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
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
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

Sub Categories:

We're in Beta

About us Mission Statement