FdsnPlugs.JWTAuthentication (fdsn_plugs v0.9.3)

View Source

Plug to authenticate requests via JWT bearer tokens from multiple authorities.

The plug passes through when:

  • conn.assigns.user is already set (e.g. HTTP Digest auth already handled it)
  • no Authorization header is present

Otherwise it tries each configured authority in order. On success it stores all token claims in conn.assigns.jwt_claims and the email claim in conn.assigns.user.

Usage

Add one FdsnPlugs.JwkStrategy per authority to your supervision tree:

children = [
  {FdsnPlugs.JwkStrategy,
   name: :authority1,
   jwks_url: "https://auth.example.com/jwks",
   first_fetch_sync: true}
]

Then plug into your pipeline:

plug FdsnPlugs.JWTAuthentication, authorities: [:authority1]

Summary

Functions

call(conn, opts)

init(opts)