File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed
src/main/kotlin/org/exploit/keeper Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ object Permission {
11
11
private const val STORE_WRITE = " bitkeeper.storage.write"
12
12
private const val STORE_READ = " bitkeeper.storage.read"
13
13
14
+ private const val GENERATE_KEY = " bitkeeper.dkg.generate"
15
+
14
16
fun systemUnseal (): String = SYSTEM_UNSEAL
15
17
16
18
fun systemSeal (): String = SYSTEM_SEAL
@@ -21,6 +23,8 @@ object Permission {
21
23
22
24
fun storageRead (): String = STORE_READ
23
25
26
+ fun generateKey () = GENERATE_KEY
27
+
24
28
fun keyGetPublicKey (key : String ): String = KEY_GET_PUBLICKEY .format(key)
25
29
26
30
fun keySign (key : String ): String = KEY_SIGN .format(key)
Original file line number Diff line number Diff line change @@ -3,15 +3,24 @@ package org.exploit.keeper.controller.keygen
3
3
import io.smallrye.mutiny.Uni
4
4
import jakarta.ws.rs.POST
5
5
import jakarta.ws.rs.Path
6
+ import jakarta.ws.rs.container.ContainerRequestContext
6
7
import org.exploit.keeper.constant.KeeperCurve
8
+ import org.exploit.keeper.constant.Permission
7
9
import org.exploit.keeper.model.request.Generate
10
+ import org.exploit.keeper.service.auth.policy.MachinePolicyChecker
8
11
import org.exploit.keeper.service.keygen.starter.DKGenerator
9
12
10
13
@Path(" /v1/keeper/dkg" )
11
- class KeyGenController (private val dkg : DKGenerator ) {
14
+ class KeyGenController (
15
+ private val dkg : DKGenerator ,
16
+ private val policyChecker : MachinePolicyChecker ,
17
+ private val ctx : ContainerRequestContext
18
+ ) {
12
19
@POST
13
20
@Path(" /generate" )
14
21
fun generate (body : Generate ): Uni <Void > {
22
+ policyChecker.ensureHasPermission(ctx, Permission .generateKey())
23
+
15
24
return dkg.generateKey(
16
25
keyId = body.keyId,
17
26
curve = KeeperCurve .fromName(body.curve),
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ class MachineAuthFilter(
21
21
private val matchers = listOf (
22
22
AntPathMatcher .of(" /v1/keeper/sign/**" ),
23
23
AntPathMatcher .of(" /v1/keeper/publicKey/**" ),
24
- AntPathMatcher .of(" /v1/keeper/system/**" )
24
+ AntPathMatcher .of(" /v1/keeper/system/**" ),
25
+ AntPathMatcher .of(" /v1/keeper/dkg/**" )
25
26
)
26
27
27
28
override fun filter (ctx : ContainerRequestContext ) {
You can’t perform that action at this time.
0 commit comments