Soft migrating to auth (#309)

This commit is contained in:
KirillPamPam
2023-09-27 14:32:01 +04:00
committed by GitHub
parent be97ba0aac
commit a2c5743fb2
2 changed files with 9 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ class AuthRpc(
Mono.error(it)
} else {
val message = "Internal error: ${it.message}"
log.error(message, it)
log.error(message)
Mono.error(
Status.INTERNAL
.withDescription(message)

View File

@@ -10,6 +10,8 @@ import io.emeraldpay.dshackle.auth.processor.SESSION_ID
import io.emeraldpay.dshackle.auth.processor.VERSION
import io.emeraldpay.dshackle.auth.service.RsaKeyReader
import io.emeraldpay.dshackle.config.AuthorizationConfig
import io.grpc.Status
import io.grpc.StatusRuntimeException
import reactor.core.publisher.Mono
import java.security.interfaces.RSAPrivateKey
import java.security.interfaces.RSAPublicKey
@@ -34,7 +36,12 @@ class GrpcUpstreamsAuth(
).map {
verify(it.providerToken, providerId)
}.onErrorResume {
Mono.just(AuthResult(false, "Error during auth - ${it.message}"))
if (it is StatusRuntimeException && it.status.code == Status.Code.UNIMPLEMENTED) {
Mono.just(AuthResult(true))
.also { grpcAuthContext.putTokenInContext(providerId, SESSION_ID) }
} else {
Mono.just(AuthResult(false, "Error during auth - ${it.message}"))
}
}
}