Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed: jsonpath lib used as ClaimName #453

Merged
merged 3 commits into from May 29, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

added: debug logs

  • Loading branch information...
coutoPL committed May 28, 2019
commit 78dc99eb744e30cfad55874739948c773e494a6a
@@ -18,6 +18,7 @@ package tech.beshu.ror.acl.utils

import eu.timepit.refined.types.string.NonEmptyString
import io.jsonwebtoken.Claims
import org.apache.logging.log4j.scala.Logging
import tech.beshu.ror.acl.domain.{ClaimName, Group, Header, User}
import tech.beshu.ror.acl.utils.ClaimsOps.ClaimSearchResult
import tech.beshu.ror.acl.utils.ClaimsOps.ClaimSearchResult._
@@ -26,7 +27,7 @@ import scala.collection.JavaConverters._
import scala.language.{implicitConversions, postfixOps}
import scala.util.Try

class ClaimsOps(val claims: Claims) extends AnyVal {
class ClaimsOps(val claims: Claims) extends AnyVal with Logging {

def headerNameClaim(name: Header.Name): ClaimSearchResult[Header] = {
Option(claims.get(name.value.value, classOf[String]))
@@ -42,7 +43,13 @@ class ClaimsOps(val claims: Claims) extends AnyVal {
case value: String => Found(User.Id(value))
case _ => NotFound
}
.getOrElse(NotFound)
.fold(
ex => {
logger.debug("JsonPath reading exception", ex)
NotFound
},
identity
)
}

def groupsClaim(claimName: ClaimName): ClaimSearchResult[Set[Group]] = {
@@ -60,7 +67,13 @@ class ClaimsOps(val claims: Claims) extends AnyVal {
case _ =>
NotFound
}
.getOrElse(NotFound)
.fold(
ex => {
logger.debug("JsonPath reading exception", ex)
NotFound
},
identity
)
}

private def toGroup(value: String) = {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.