@@ -7,24 +7,23 @@ import jakarta.ws.rs.container.ContainerRequestContext
7
7
import jakarta.ws.rs.container.ContainerRequestFilter
8
8
import jakarta.ws.rs.ext.Provider
9
9
import org.exploit.keeper.api.auth.KeeperAuthenticator
10
- import org.exploit.keeper.config.KeeperConfig
10
+ import org.exploit.keeper.filter.matcher.AntPathMatcher
11
11
import org.exploit.keeper.service.client.TKeeperClients
12
12
13
13
@Provider
14
14
@Priority(Priorities .AUTHENTICATION )
15
- class KeeperAuthFilter (
16
- private val config : KeeperConfig ,
17
- private val clients : TKeeperClients
18
- ) : ContainerRequestFilter {
15
+ class KeeperAuthFilter (private val clients : TKeeperClients ) : ContainerRequestFilter {
16
+ private val ignoreMatchers = listOf (
17
+ AntPathMatcher .of(" /v1/keeper/**" ),
18
+ AntPathMatcher .of(" /v1/integrity/**" )
19
+ )
19
20
20
21
override fun filter (p0 : ContainerRequestContext ) {
21
22
val path = p0.uriInfo.path
22
23
23
- if (path.startsWith(" /v1/keeper" ))
24
- return
25
-
26
- if (config.auth().allowAnonymous())
24
+ if (ignoreMatchers.any { it.matches(path) }) {
27
25
return
26
+ }
28
27
29
28
val instanceId = p0.getHeaderString(KeeperAuthenticator .HEADER_INSTANCE_ID )
30
29
?.toIntOrNull()
@@ -40,8 +39,9 @@ class KeeperAuthFilter(
40
39
try {
41
40
val client = clients.find(instanceId)
42
41
43
- if (! client.verifySignature(signature, path, timestamp))
42
+ if (! client.verifySignature(signature, path, timestamp)) {
44
43
throw NotAuthorizedException (" Signature verification failed" )
44
+ }
45
45
} catch (e: Exception ) {
46
46
throw NotAuthorizedException (" Signature verification failed" )
47
47
}
0 commit comments