Skip to content

janjaali/spray-jwt

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

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

About

JWT library for use with spray-json and akka-http

Resources

License

Stars

Watchers

Forks

Packages

No packages published