JWT library for use with spray-json and akka-http
Switch branches/tags
Nothing to show
Clone or download
Latest commit 95fbad6 Nov 12, 2017

README.md

spray-jwt

JWT library to use with spray-json and akka-http.

Install

Add spray-jwt as dependency to your build.sbt:

libraryDependencies ++= Seq(
  "com.github.janjaali" %% "spray-jwt" % "1.0.0"
)

To encode a JsValue to a JWT token:

import org.janjaali.sprayjwt.Jwt
import org.janjaali.sprayjwt.algorithms.HS256

val payload = """{"sub":"1234567890","name":"John Doe","admin":true}"""
val jwtOpt = Jwt.encode(payload, "super_fancy_secret", HS256)

And vice versa to decode JWT token as a JsValue:

import org.janjaali.sprayjwt.Jwt
import org.janjaali.sprayjwt.algorithms.HS256

val token = "..."
val jsValueOpt = Jwt.decode(token, "super_fancy_secret")

Supported algorithms

  • HS256

  • HS384

  • HS512

  • RS256

  • RS384

  • RS512

Source Code Style

Check style via scalastyle:

sbt scalastyle