Coroidc is a core of an OpenID Connect Server. It does the heavy lifting for you so all you have to do is build the User Interface & implement the Coroidc.Server
behaviour callbacks.
It's using Plug so you can use it with any HTTP framework.
def deps do
[
{:coroidc, "~> 0.1.0"}
]
end
defmodule YourApp.OIDCServer do
@behaviour Coroidc.Server
## This module is the interface between Coroidc and your
## own application. Coroidc is using the callbacks defined
## in this module handle specific scenarios or to fetch
## data from your database.
##
## See Coroidc.Server for more details
end
config :coroidc, Coroidc.Server, YourApp.OIDCServer
get("/.well-known/openid-configuration", Coroidc.Endpoint.Discovery, :any)
get("/oauth2/authorize", Coroidc.Endpoint.Authorization, :any)
In some scenario, such as in the Authorization, you must give back the hand to Coroidc. The main module exposes function for this purpose:
def sign_in_success(conn, user) do
Coroidc.authorize_user(conn, user.id)
end
You can see a working example on https://github.com/dlacreme/oidcs