• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    Erlang
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

OpenId Connect client library in Erlang & Elixir
OpenID Connect Logo

oidcc

OpenID Connect client library for Erlang.

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 Documentation.


Erlang Ecosystem Foundation Logo

The refactoring for v3 and the certification is funded as an Erlang Ecosystem Foundation stipend entered by the Security Working Group.


Supported Features

Setup

Please note that the minimum supported Erlang OTP version is OTP26.

Erlang

directly

{ok, Pid} =
  oidcc_provider_configuration_worker:start_link(#{
    issuer => <<"https://accounts.google.com">>,
    name => {local, google_config_provider}
  }).

via supervisor

-behaviour(supervisor).

%% ...

init(_Args) ->
  SupFlags = #{strategy => one_for_one},
  ChildSpecs = [#{id => oidcc_provider_configuration_worker,
                  start => {oidcc_provider_configuration_worker, start_link, [
                    #{issuer => "https://accounts.google.com",
                      name => {local, myapp_oidcc_config_provider}}
                  ]},
                  shutdown => brutal_kill}],
  {ok, {SupFlags, ChildSpecs}}.

Elixir

directly

{:ok, _pid} =
  Oidcc.ProviderConfiguration.Worker.start_link(%{
  issuer: "https://accounts.google.com",
  name: Myapp.OidccConfigProvider
})

via Supervisor

Supervisor.init([
  {Oidcc.ProviderConfiguration.Worker, %{
    issuer: "https://accounts.google.com",
    name: Myapp.OidccConfigProvider
  }}
], strategy: :one_for_one)

Usage

Companion libraries

oidcc offers integrations for various libraries:

Erlang

%% Create redirect URI for authorization
{ok, RedirectUri} =
  oidcc:create_redirect_url(myapp_oidcc_config_provider,
                            <<"client_id">>,
                            <<"client_secret">>
                            #{redirect_uri: <<"https://example.com/callback"}),

%% Redirect user to `RedirectUri`

%% Retrieve `code` query / form param from redirect back

%% Exchange code for token
{ok, Token} =
  oidcc:retrieve_token(AuthCode,
                       myapp_oidcc_config_provider,
                       <<"client_id">>,
                       <<"client_secret">>,
                       #{redirect_uri => <<"https://example.com/callback">>}),

%% Load userinfo for token
{ok, Claims} =
  oidcc:retrieve_userinfo(Token,
                          myapp_oidcc_config_provider,
                          <<"client_id">>,
                          <<"client_secret">>,
                          #{}),

%% Load introspection for access token
{ok, Introspection} =
  oidcc:introspect_token(Token,
                         myapp_oidcc_config_provider,
                         <<"client_id">>,
                         <<"client_secret">>,
                         #{}),

%% Refresh token when it expires
{ok, RefreshedToken} =
  oidcc:refresh_token(Token,
                      myapp_oidcc_config_provider,
                      <<"client_id">>,
                      <<"client_secret">>,
                      #{}).

for more details, see https://hexdocs.pm/oidcc/oidcc.html

Elixir

# Create redirect URI for authorization
{:ok, redirect_uri} =
  Oidcc.create_redirect_url(
    Myapp.OidccConfigProvider,
    "client_id",
    "client_secret",
    %{redirect_uri: "https://example.com/callback"}
  )

# Redirect user to `redirect_uri`

# Retrieve `code` query / form param from redirect back

# Exchange code for token
{:ok, token} = Oidcc.retrieve_token(
  auth_code,
    Myapp.OidccConfigProvider,
  "client_id",
  "client_secret",
  %{redirect_uri: "https://example.com/callback"}
)

# Load userinfo for token
{:ok, claims} = Oidcc.retrieve_userinfo(
  token,
  Myapp.OidccConfigProvider,
  "client_id",
  "client_secret",
  %{expected_subject: "sub"}
)

# Load introspection for access token
{:ok, introspection} = Oidcc.introspect_token(
  token,
  Myapp.OidccConfigProvider,
  "client_id",
  "client_secret"
)

# Refresh token when it expires
{:ok, refreshed_token} = Oidcc.refresh_token(
  token,
  Myapp.OidccConfigProvider,
  "client_id",
  "client_secret"
)

for more details, see https://hexdocs.pm/oidcc/Oidcc.html

More Repositories

1

setup-beam

Set up your BEAM-based GitHub Actions workflow (Erlang, Elixir, Gleam, ...)
JavaScript
377
star
2

security-wg

Repo for the Security Working Group
Ruby
195
star
3

rebar3_hex

Rebar3 Hex library
Erlang
101
star
4

website

Erlang Ecosystem Foundation Website
Elixir
78
star
5

machine-learning-wg

Machine Learning Working Group
63
star
6

observability-wg

Project for tracking the work of the Observability Working Group
61
star
7

embedded-wg

Embedded Systems Working Group
20
star
8

build-and-packaging-wg

Build and Packaging Working Group
19
star
9

rosie

Robot Operating System in Erlang
Erlang
17
star
10

gsoc

Projects to participate to GSOC
15
star
11

libs-and-frameworks

To provide resources for library and framework authors to ensure that BEAM languages have a rich, vibrant ecosystem with a high degree of developer experience.
12
star
12

education-wg

Working Group for Education, Training, and Adoption
11
star
13

language-interop-wg

Language Interoperability Working Group Repository
10
star
14

documentation-wg

EEF Documentation Working Group
9
star
15

marketing-wg

Marketing Working Group - https://erlef.org/wg/marketing
7
star
16

phx_gen_oidcc

An OpenID Login Generator for Phoenix 1.7 Projects
Elixir
6
star
17

oidcc_plug

Plug Integration for the oidcc OpenID Connect Library
Elixir
6
star
18

infra-wg

ErlEF infrastructure working group
6
star
19

epc-wg

External Process Communication Working Group
5
star
20

erlang_snap

Snap packages for Erlang/OTP
Shell
4
star
21

otp_builds

Community-maintained pre-compiled Erlang/OTP for macOS
4
star
22

oidcc_cowboy

Cowboy OpenId Connect support by using oidcc
Erlang
3
star
23

setup-elp

A GitHub action to run ELP eqWAlizer in your CI pipelines
JavaScript
3
star
24

oidcc_conformance

OpenID Conformance Test Suite
Elixir
2
star
25

reports

1
star
26

gh-actions

1
star