File tree Expand file tree Collapse file tree 6 files changed +22
-15
lines changed
src/main/kotlin/org/exploit/keeper Expand file tree Collapse file tree 6 files changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -2,15 +2,16 @@ package org.exploit.keeper.constant
2
2
3
3
object Permission {
4
4
private const val KEY_GET_PUBLICKEY = " bitkeeper.key.%s.public"
5
+
5
6
private const val KEY_SIGN = " bitkeeper.key.%s.sign"
7
+ private const val KEY_VERIFY = " bitkeeper.key.%s.verify"
6
8
7
9
private const val SYSTEM_UNSEAL = " bitkeeper.system.unseal"
8
10
private const val SYSTEM_SEAL = " bitkeeper.system.seal"
9
11
private const val SYSTEM_INIT = " bitkeeper.system.init"
12
+ private const val SYSTEM_STATUS = " bitkeeper.system.status"
10
13
11
14
private const val STORE_WRITE = " bitkeeper.storage.write"
12
- private const val STORE_READ = " bitkeeper.storage.read"
13
-
14
15
private const val GENERATE_KEY = " bitkeeper.dkg.generate"
15
16
16
17
fun systemUnseal (): String = SYSTEM_UNSEAL
@@ -21,11 +22,13 @@ object Permission {
21
22
22
23
fun storageWrite (): String = STORE_WRITE
23
24
24
- fun storageRead (): String = STORE_READ
25
-
26
25
fun generateKey () = GENERATE_KEY
27
26
27
+ fun systemStatus (): String = SYSTEM_STATUS
28
+
28
29
fun keyGetPublicKey (key : String ): String = KEY_GET_PUBLICKEY .format(key)
29
30
30
31
fun keySign (key : String ): String = KEY_SIGN .format(key)
32
+
33
+ fun keyVerify (key : String ): String = KEY_VERIFY .format(key)
31
34
}
Original file line number Diff line number Diff line change 1
- package org.exploit.keeper.controller.core
1
+ package org.exploit.keeper.controller.keeper
2
2
3
3
import io.smallrye.mutiny.Uni
4
4
import jakarta.ws.rs.GET
@@ -28,11 +28,11 @@ class CentralController(
28
28
@GET
29
29
@Path(" /publicKey" )
30
30
fun publicKey (@QueryParam(" keyId" ) keyId : String ): Uni <PublicKeyDto > {
31
+ policyChecker.ensureHasPermission(ctx, Permission .keyGetPublicKey(keyId))
32
+
31
33
if (! keeper.initialized())
32
34
throw SealedException ()
33
35
34
- policyChecker.ensureHasPermission(ctx, Permission .keyGetPublicKey(keyId))
35
-
36
36
return pub.getPublicKey(keyId).toUni()
37
37
}
38
38
}
Original file line number Diff line number Diff line change 1
- package org.exploit.keeper.controller.keygen
1
+ package org.exploit.keeper.controller.keeper
2
2
3
3
import io.smallrye.mutiny.Uni
4
4
import jakarta.ws.rs.POST
Original file line number Diff line number Diff line change 1
- package org.exploit.keeper.controller.core
1
+ package org.exploit.keeper.controller.keeper
2
2
3
3
import io.quarkus.arc.All
4
4
import io.smallrye.mutiny.Uni
@@ -36,11 +36,11 @@ class SignatureController(
36
36
@POST
37
37
@Path(" /sign" )
38
38
fun sign (body : Sign ): Uni <TSSResult > {
39
+ policyChecker.ensureHasPermission(ctx, Permission .keySign(body.keyId))
40
+
39
41
if (! keeper.initialized() || keeper.sealed())
40
42
throw SealedException ()
41
43
42
- policyChecker.ensureHasPermission(ctx, Permission .keySign(body.keyId))
43
-
44
44
return when (body.type) {
45
45
SessionType .GG20 -> gg20.sign(
46
46
sessionId = body.sessionId,
@@ -61,6 +61,8 @@ class SignatureController(
61
61
@POST
62
62
@Path(" /sign/verify" )
63
63
fun verify (body : Verify ): Uni <VerifyResult > {
64
+ policyChecker.ensureHasPermission(ctx, Permission .keyVerify(body.keyId))
65
+
64
66
if (! keeper.initialized() || keeper.sealed())
65
67
throw SealedException ()
66
68
Original file line number Diff line number Diff line change 1
- package org.exploit.keeper.controller.core
1
+ package org.exploit.keeper.controller.keeper
2
2
3
3
import jakarta.ws.rs.Path
4
4
import jakarta.ws.rs.container.ContainerRequestContext
Original file line number Diff line number Diff line change 1
- package org.exploit.keeper.controller.core
1
+ package org.exploit.keeper.controller.keeper
2
2
3
3
import jakarta.ws.rs.GET
4
4
import jakarta.ws.rs.POST
@@ -28,8 +28,10 @@ class SystemController(
28
28
29
29
@GET
30
30
@Path(" /status" )
31
- fun status (): StatusResponse =
32
- keeper.status()
31
+ fun status (): StatusResponse {
32
+ policyChecker.ensureHasPermission(ctx, Permission .systemStatus())
33
+ return keeper.status()
34
+ }
33
35
34
36
@PUT
35
37
@Path(" /unseal" )
You can’t perform that action at this time.
0 commit comments