@@ -10,6 +10,7 @@ import ch.derlin.bbdata.output.api.apikeys.ApikeyRepository
1010import ch.derlin.bbdata.output.security.SecurityConstants.HEADER_TOKEN
1111import ch.derlin.bbdata.output.security.SecurityConstants.HEADER_USER
1212import ch.derlin.bbdata.output.security.SecurityConstants.SCOPE_WRITE
13+ import org.slf4j.Logger
1314import org.slf4j.LoggerFactory
1415import org.springframework.beans.factory.annotation.Autowired
1516import org.springframework.beans.factory.annotation.Value
@@ -71,6 +72,7 @@ class AuthInterceptor : HandlerInterceptor {
7172 @Autowired
7273 lateinit var apikeyRepository: ApikeyRepository
7374
75+ private val log: Logger = LoggerFactory .getLogger(AuthInterceptor ::class .java)
7476
7577 override fun preHandle (request : HttpServletRequest , response : HttpServletResponse , handler : Any ): Boolean {
7678
@@ -110,12 +112,13 @@ class AuthInterceptor : HandlerInterceptor {
110112 bbuser.toIntOrNull()?.let { userId ->
111113 // check valid tokens
112114 val apikey = apikeyRepository.findValid(userId, bbtoken).orElseThrow {
115+ log.info(" wrong apikey for userId=$userId token='$bbtoken '" )
113116 BadApikeyException (" Access denied for user $userId : bad apikey" )
114117 }
115118 // check if write access is necessary
116119 if (apikey.readOnly && writeRequired) {
117120 // check write permissions
118- throw ForbiddenException (" Access denied for user $userId : this apikey is read-only" )
121+ throw ForbiddenException (" Access denied for user $userId : this apikey is read-only" )
119122 }
120123 // every checks passed !
121124 return true
0 commit comments