All Projects â†’ profunktor â†’ http4s-jwt-auth

profunktor / http4s-jwt-auth

Licence: other
🔒 Opinionated JWT authentication library for Http4s

Programming Languages

scala
5932 projects
Nix
1067 projects

Projects that are alternatives of or similar to http4s-jwt-auth

http4s-poc-api
POC: http4s http api on zio
Stars: ✭ 34 (-60%)
Mutual labels:  http4s
scala-functional-programming-tutorial
Functional Programming in Scala Tutorial
Stars: ✭ 23 (-72.94%)
Mutual labels:  http4s
zorechka-bot
Github bot for keeping your Bazel dependencies up-to-date and clean
Stars: ✭ 25 (-70.59%)
Mutual labels:  http4s
influencer-stats
Playground for measuring performance of functional programming tools in Scala. Gathers statistics about videos.
Stars: ✭ 24 (-71.76%)
Mutual labels:  http4s
http4s-laminar-stack
A complete example of a fullstack (I actually don't know what this means) Scala application, using http4s on the backend and Laminar and Scala.js on the frontend
Stars: ✭ 43 (-49.41%)
Mutual labels:  http4s
http4s-good-practices
Collection of what I consider good practices in Http4s (WIP)
Stars: ✭ 74 (-12.94%)
Mutual labels:  http4s
spotify-next
Small CLI app for filtering out music on Spotify.
Stars: ✭ 45 (-47.06%)
Mutual labels:  http4s
http4s-graal
An experiment running http4s as native image with Graal (+ Substrate)
Stars: ✭ 27 (-68.24%)
Mutual labels:  http4s
sbt-guardrail
Principled code generation from OpenAPI specifications
Stars: ✭ 24 (-71.76%)
Mutual labels:  http4s
dokusho
Simple Japanese reading stats tracker
Stars: ✭ 12 (-85.88%)
Mutual labels:  http4s
typelevel-stack.g8
📚 Unofficial Giter8 template for the Typelevel Stack (Http4s / Doobie / Circe / Cats Effect / Fs2) based on Cats v1.x.x
Stars: ✭ 63 (-25.88%)
Mutual labels:  http4s
http4s-finagle
Http4s on Finagle Server or Client
Stars: ✭ 12 (-85.88%)
Mutual labels:  http4s
http4s-tracer
📊 End-to-end tracing system for Http4s
Stars: ✭ 112 (+31.76%)
Mutual labels:  http4s
scala-http4s-realworld-example-app
Example of a RealWorld app backend powered by Scala + http4s
Stars: ✭ 35 (-58.82%)
Mutual labels:  http4s
tradeio
A disciplined way to purely functional domain models in Scala
Stars: ✭ 19 (-77.65%)
Mutual labels:  http4s
telegram-bot-fs2
Example telegram bot implementation using fs2 and http4s client (no akka)
Stars: ✭ 41 (-51.76%)
Mutual labels:  http4s
http4s-modules
Web modules built on Http4s
Stars: ✭ 31 (-63.53%)
Mutual labels:  http4s
http4s-dom
http4s, in a browser near you
Stars: ✭ 13 (-84.71%)
Mutual labels:  http4s
free-monads-functional-web-apps
Delving into Free Monads and using them to write pure functional web applications
Stars: ✭ 18 (-78.82%)
Mutual labels:  http4s
zio-http4s-example
For anyone who's struggling to put an http4s server together with ZIO
Stars: ✭ 19 (-77.65%)
Mutual labels:  http4s

http4s-jwt-auth

CI Status Gitter Chat Maven Central Cats friendly MergifyStatus Scala Steward badge

Opinionated JWT authentication library for http4s.

Dependencies

jwt-scala is being used to encode and decode JWT tokens.

Add the following dependency to your build.sbt (check latest version on the badge):

"dev.profunktor" %% "http4s-jwt-auth" % Version

Usage

import cats.effect.IO
import cats.implicits._
import dev.profunktor.auth._
import dev.profunktor.auth.jwt._
import pdi.jwt._
import org.http4s._

case class AuthUser(id: Long, name: String)

// i.e. retrieve user from database
val authenticate: JwtToken => JwtClaim => IO[Option[AuthUser]] =
  token => claim => AuthUser(123L, "joe").some.pure[IO]

val jwtAuth    = JwtAuth.hmac("53cr3t", JwtAlgorithm.HS256)
val middleware = JwtAuthMiddleware[IO, AuthUser](jwtAuth, authenticate)

val routes: AuthedRoutes[AuthUser, IO] = ???
val securedRoutes: HttpRoutes[IO] = middleware(routes)

Build microsite

If you only need jekyll for this, it is recommended to use nix-shell to avoid installing it globally:

nix-shell -p jekyll
sbt makeMicrosite
cd site/target/site && jekyll serve

Notes

This library is quite opinionated, use with caution. Examples and docs coming soon!

If you would like to see support for any other functionality come have a chat in the Gitter channel!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].