spray-jwt


License

License

GroupId

GroupId

com.github.janjaali
ArtifactId

ArtifactId

spray-jwt_2.12
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

spray-jwt
spray-jwt
Project URL

Project URL

https://github.com/janjaali/spray-jwt
Project Organization

Project Organization

com.github.janjaali
Source Code Management

Source Code Management

https://github.com/janjaali/spray-jwt

Download spray-jwt_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.janjaali/spray-jwt_2.12/ -->
<dependency>
    <groupId>com.github.janjaali</groupId>
    <artifactId>spray-jwt_2.12</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.janjaali/spray-jwt_2.12/
implementation 'com.github.janjaali:spray-jwt_2.12:1.0.0'
// https://jarcasting.com/artifacts/com.github.janjaali/spray-jwt_2.12/
implementation ("com.github.janjaali:spray-jwt_2.12:1.0.0")
'com.github.janjaali:spray-jwt_2.12:jar:1.0.0'
<dependency org="com.github.janjaali" name="spray-jwt_2.12" rev="1.0.0">
  <artifact name="spray-jwt_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.janjaali', module='spray-jwt_2.12', version='1.0.0')
)
libraryDependencies += "com.github.janjaali" % "spray-jwt_2.12" % "1.0.0"
[com.github.janjaali/spray-jwt_2.12 "1.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.3
io.spray : spray-json_2.12 jar 1.3.3
org.bouncycastle : bcpkix-jdk15on jar 1.58

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.4

Project Modules

There are no modules declared in this project.

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

Versions

Version
1.0.0