in app/auth/BearerTokenAuth.scala [51:78]
def getIsMMCreator:Boolean = Option(s.getClaim("multimedia_creator").asInstanceOf[String]).exists(value => value.toLowerCase == "true")
}
}
/**
* this class implements bearer token authentication. It's injectable because it needs to access app config.
* You don't need to integrate it directly in your controller, it is required by the Security trait.
*
* A given bearer token must authenticate against the provided certificate to be allowed access, its expiry time
* must not be in the past and it must have at least one of the `validAudiences` in either the `aud` or `azp` fields.
* The token's subject field ("sub") is used as the username.
* Admin access is only granted if the token's field given by auth.adminClaim is a string that equates to "true" or "yes".
*
* So, in order to use it:
*
* class MyController @Inject() (controllerComponents:ControllerComponents, override bearerTokenAuth:BearerTokenAuth) extends AbstractController(controllerComponets) with Security { }
* @param config application configuration object. This is normally provided by the injector
*/
@Singleton
class BearerTokenAuth @Inject() (config:Configuration) {
import ClaimsSetExtensions._
private val logger = LoggerFactory.getLogger(getClass)
//see https://stackoverflow.com/questions/475074/regex-to-parse-or-validate-base64-data
//it is not the best option but is the simplest that will work here
private val authXtractor = "^Bearer\\s+([a-zA-Z0-9+/._-]*={0,3})$".r
var loadTime: Long = System.currentTimeMillis / 1000
private var maybeVerifiers = loadInKey() match {