Skip to content

erlef/phx_gen_oidcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
OpenID Connect Logo

Phx Gen Oidcc

An OpenID Login Generator for Phoenix 1.7 Projects

EEF Security WG project Main Branch Module Version Total Download License Last Updated Coverage Status


OpenID Connect Certified Logo

OpenID Certified by Jonatan Männchen at the Erlang Ecosystem Foundation of multiple Relaying Party conformance profiles of the OpenID Connect protocol: For details, check the Conformance Test Suite.


Erlang Ecosystem Foundation Logo

The development of the library and the certification is funded as an Erlang Ecosystem Foundation stipend entered by the Security Working Group.


This library has taken some inspiration from @aaronrenner's phx_gen_auth.

Overview

The purpose of phx.gen.oidcc is to generate a pre-built authentication system into a Phoenix 1.7 application that follows both security and elixir best practices. By generating code into the user's application instead of using a library, the user has complete freedom to modify the authentication system so it works best with their app.

Installation

After running mix phx.new, cd into your application's directory (ex. my_app).

  1. Add phx_gen_oidcc to your list of dependencies in mix.exs
    def deps do
      [
        {:phx_gen_oidcc, "~> 0.1.0", only: [:dev], runtime: false},
        ...
      ]
    end
  2. Install and compile the dependencies
    $ mix do deps.get, deps.compile
    

Running the generator

From the root of your phoenix app, you can install the authentication system with the following command

$ mix phx.gen.oidcc \
    MyApp.ConfigProviderName \
    "https://issuer.example.com" \
    "client_id" \
    "client_secret"

This creates the templates,views, and controllers on the web namespace, and starts a new Oidcc.ProviderConfiguration.Worker, in the application.

Next, let's install the dependencies

$ mix deps.get

Let's run the tests and make sure our new authentication system works as expected.

$ mix test

Finally, let's start our phoenix server and try it out.

$ mix phx.server

Learning more

To learn more about phx.gen.oidcc, run the following command.

$ mix help phx.gen.oidcc

You can also look up the mix task in hexdocs.