-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54167d6
commit 2830a33
Showing
11 changed files
with
129 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
circe/src/main/scala/me/wojnowski/oidc4s/json/circe/CirceJsonSupport.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
circe/src/main/scala/me/wojnowski/oidc4s/json/circe/JwtHeaderCirceDecoder.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
package me.wojnowski.oidc4s.json.circe | ||
|
||
import io.circe.Decoder | ||
import pdi.jwt.JwtHeader | ||
import me.wojnowski.oidc4s.Algorithm | ||
import me.wojnowski.oidc4s.JwtHeader | ||
|
||
trait JwtHeaderCirceDecoder { | ||
|
||
private implicit val jwtAlgorithmCirceDecoder: Decoder[Algorithm] = | ||
Decoder[String].map(Algorithm.fromString) | ||
|
||
protected implicit val jwtHeaderCirceDecoder: Decoder[JwtHeader] = | ||
Decoder.forProduct1[JwtHeader, String]("kid") { kid => | ||
JwtHeader(keyId = Some(kid)) | ||
} | ||
Decoder.forProduct2[JwtHeader, String, Algorithm]("kid", "alg")(JwtHeader.apply) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package me.wojnowski.oidc4s | ||
|
||
import cats.Order | ||
import cats.data.NonEmptySet | ||
import cats.implicits._ | ||
|
||
sealed abstract class Algorithm(val name: String, val fullName: String) extends Product with Serializable | ||
|
||
// According to OIDC RFC, only RS256 should be supported | ||
object Algorithm { | ||
case object Rs256 extends Algorithm(name = "RS256", fullName = "SHA256withRSA") | ||
case object Rs384 extends Algorithm(name = "RS384", fullName = "SHA384withRSA") | ||
case object Rs512 extends Algorithm(name = "RS512", fullName = "SHA512withRSA") | ||
|
||
case class Other(override val name: String) extends Algorithm(name, fullName = name) | ||
|
||
implicit val order: Order[Algorithm] = Order.by(_.name) | ||
|
||
val supportedAlgorithms: NonEmptySet[Algorithm] = NonEmptySet.of(Rs256, Rs384, Rs512) | ||
|
||
def fromString(s: String): Algorithm = supportedAlgorithms.find(_.name === s).getOrElse(Other(s)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package me.wojnowski.oidc4s | ||
|
||
case class JwtHeader(keyId: String, algorithm: Algorithm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/test/scala/me/wojnowski/oidc4s/mocks/JsonSupportMock.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters