Nym (Nym v0.0.1-rc2)

View Source

Identity provider and authentication layer.

Nym is a minimal IndieAuth implementation providing an authorization endpoint, which serves two purposes:

  1. decentralised authentication using personal domain names as identity, following the IndieAuth specification.
  2. centralised authentication layer for in-house applications (similar to OAuth or SSO).

This library provides a Nym client for easily protecting Phoenix-based applications with centralised identity management.

Usage

import Nym

pipeline :browser do
  ...
  plug :fetch_session
  plug :fetch_current_user
end

scope "/protected" do
  pipe_through [:browser, :require_auth]

  get "/", PageController, :index

  live_session :default, on_mount: Nym do
    live "/hello", WorldLive, :hello
  end
end

Summary

Types

opts()

@type opts() :: [on: String.t(), scopes: [String.t()]]

Functions

fetch_current_user(conn, opts)

@spec fetch_current_user(Plug.Conn.t(), opts()) :: Plug.Conn.t()

require_auth(conn, opts)

@spec require_auth(Plug.Conn.t(), opts()) :: Plug.Conn.t()
@spec require_auth(Plug.Conn.t(), opts()) :: Plug.Conn.t()