Shamrock: 实现鉴权操作

Signed-off-by: 白池 <whitechi73@outlook.com>
This commit is contained in:
白池 2024-03-10 16:05:20 +08:00
parent bbdfb7c04e
commit a528030cbb

View File

@ -7,6 +7,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.asExecutor import kotlinx.coroutines.asExecutor
import kritor.auth.AuthInterceptor
import kritor.service.* import kritor.service.*
import moe.fuqiuluo.shamrock.helper.LogCenter import moe.fuqiuluo.shamrock.helper.LogCenter
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
@ -16,6 +17,7 @@ class KritorServer(
): CoroutineScope { ): CoroutineScope {
private val server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create()) private val server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create())
.executor(Dispatchers.IO.asExecutor()) .executor(Dispatchers.IO.asExecutor())
.intercept(AuthInterceptor)
.addService(Authentication) .addService(Authentication)
.addService(ContactService) .addService(ContactService)
.build()!! .build()!!