ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - madebymany/passwordless_auth: A library for simple passwordless authentication
A library for simple passwordless authentication. Contribute to madebymany/passwordless_auth development by creating an account on GitHub.
Visit Site

GitHub - madebymany/passwordless_auth: A library for simple passwordless authentication

GitHub - madebymany/passwordless_auth: A library for simple passwordless authentication

PasswordlessAuth

PasswordlessAuth provides functionality that can be used in an authentication or verification system, such as a passwordless or multi-factor authentication flow, or for verifying a user's ownership of a phone number, email address or any other identifying address.

  • Generate verification codes
  • Verify a user's attempt at entering a code
  • Rate limit attempts
  • Expire codes

This library doesn't deal with sending the codes to recipients.

See Usage for example usage.

Documentation

Documentation is available at https://hexdocs.pm/passwordless_auth

Installation

Add :passwordless_auth to your list of dependencies in mix.exs:

def deps do
  [
    {:passwordless_auth, "~> 0.3.0"}
  ]
end

Configuration

The following PasswordlessAuth config can be set in your config/config.exs file:

config :passwordless_auth,
  # How long codes are valid for
  verification_code_ttl: 300, # seconds; default: 300
  # Rate limiting: how many failed attempts are allowed before the timeout is applied
  num_attempts_before_timeout: 5, # default: 5
  # Rate limiting: how long to disallow attempts after the limit has been reached
  rate_limit_timeout_length: 60, # seconds; default: 60
  # How often to clear out expired codes
  garbage_collector_frequency: 30 # seconds; default: 30

Usage

Here's an example where the code is sent to a recipient's phone number using ExTwilio.

1. Generate a verification code for the recipient

User enters their phone number to request a verification code.

code = PasswordlessAuth.generate_code("+447123456789")
=> "123456"

2. Send the code to the recipient

This library doesn't deal with SMS or emails, so this bit is up to you.

ExTwilio.Message.create(%{
  to: "+447123456789",
  body: "Your code is #{code}"
})

3. Verify the code

Recipient receives a text message with their verification code. They enter it into your system and you verify that it is correct.

attempt_code = "123456" # The user's attempt at entering the correct verification code.
PasswordlessAuth.verify_code(
  "+447123456789",
  attempt_code
)

Returns true or false.

Once a code has been verified, you can remove it so that it can't be used again before it expires.

PasswordlessAuth.remove_code("+447123456789")

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory