mirror of https://github.com/usbharu/Hideout.git
feat: 連合に失敗する問題を修正
This commit is contained in:
parent
ecd25436a4
commit
0021061aa2
|
@ -29,6 +29,9 @@ class UserRepositoryImpl(private val idGenerateService: IdGenerateService) :
|
|||
it[createdAt] = user.createdAt.toEpochMilli()
|
||||
it[publicKey] = user.publicKey
|
||||
it[privateKey] = user.privateKey
|
||||
it[keyId] = user.keyId
|
||||
it[following] = user.following
|
||||
it[followers] = user.followers
|
||||
}
|
||||
} else {
|
||||
Users.update({ Users.id eq user.id }) {
|
||||
|
@ -43,6 +46,9 @@ class UserRepositoryImpl(private val idGenerateService: IdGenerateService) :
|
|||
it[createdAt] = user.createdAt.toEpochMilli()
|
||||
it[publicKey] = user.publicKey
|
||||
it[privateKey] = user.privateKey
|
||||
it[keyId] = user.keyId
|
||||
it[following] = user.following
|
||||
it[followers] = user.followers
|
||||
}
|
||||
}
|
||||
return user
|
||||
|
|
|
@ -49,18 +49,18 @@ class APReceiveFollowServiceImpl(
|
|||
val person = apUserService.fetchPerson(actor, targetActor)
|
||||
val follow = objectMapper.readValue<Follow>(props[ReceiveFollowJob.follow])
|
||||
|
||||
val signer = userQueryService.findByUrl(actor)
|
||||
val signer = userQueryService.findByUrl(targetActor)
|
||||
|
||||
val urlString = person.inbox ?: throw IllegalArgumentException("inbox is not found")
|
||||
|
||||
apRequestService.apPost(
|
||||
urlString,
|
||||
Accept(
|
||||
url = urlString,
|
||||
body = Accept(
|
||||
name = "Follow",
|
||||
`object` = follow,
|
||||
actor = targetActor
|
||||
),
|
||||
signer
|
||||
signer = signer
|
||||
)
|
||||
|
||||
val targetEntity = userQueryService.findByUrl(targetActor)
|
||||
|
|
|
@ -16,6 +16,7 @@ import io.ktor.client.request.*
|
|||
import io.ktor.client.statement.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.util.*
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.annotation.Qualifier
|
||||
import org.springframework.stereotype.Service
|
||||
import java.net.URL
|
||||
|
@ -53,7 +54,7 @@ class APRequestServiceImpl(
|
|||
httpRequest = HttpRequest(
|
||||
url = u,
|
||||
headers = HttpHeaders(headers.toMap()),
|
||||
dev.usbharu.httpsignature.common.HttpMethod.GET
|
||||
HttpMethod.GET
|
||||
),
|
||||
privateKey = PrivateKey(
|
||||
keyId = "${signer.url}#pubkey",
|
||||
|
@ -102,6 +103,8 @@ class APRequestServiceImpl(
|
|||
val date = dateTimeFormatter.format(ZonedDateTime.now(ZoneId.of("GMT")))
|
||||
val u = URL(url)
|
||||
if (signer?.privateKey == null) {
|
||||
logger.debug("NOT SIGN Request: {}", url)
|
||||
logger.trace("{}", signer)
|
||||
return httpClient.post(url) {
|
||||
header("Accept", ContentType.Application.Activity)
|
||||
header("Date", date)
|
||||
|
@ -111,6 +114,8 @@ class APRequestServiceImpl(
|
|||
}.bodyAsText()
|
||||
}
|
||||
|
||||
logger.debug("SIGN Request: {}", url)
|
||||
|
||||
val headers = headers {
|
||||
append("Accept", ContentType.Application.Activity)
|
||||
append("Date", date)
|
||||
|
@ -123,7 +128,7 @@ class APRequestServiceImpl(
|
|||
u, HttpHeaders(headers.toMap()), HttpMethod.POST
|
||||
),
|
||||
privateKey = PrivateKey(
|
||||
keyId = "${signer.url}#pubkey",
|
||||
keyId = signer.keyId,
|
||||
privateKey = RsaUtil.decodeRsaPrivateKeyPem(signer.privateKey)
|
||||
),
|
||||
signHeaders = listOf("(request-target)", "date", "host", "digest")
|
||||
|
@ -134,10 +139,15 @@ class APRequestServiceImpl(
|
|||
headers {
|
||||
appendAll(headers)
|
||||
append("Signature", sign.signatureHeader)
|
||||
remove("Host")
|
||||
}
|
||||
}
|
||||
setBody(requestBody)
|
||||
contentType(ContentType.Application.Activity)
|
||||
}.bodyAsText()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(APRequestServiceImpl::class.java)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ spring:
|
|||
default-property-inclusion: always
|
||||
datasource:
|
||||
driver-class-name: org.h2.Driver
|
||||
url: "jdbc:h2:./test-dev2;MODE=POSTGRESQL"
|
||||
url: "jdbc:h2:./test-dev3;MODE=POSTGRESQL"
|
||||
username: ""
|
||||
password: ""
|
||||
data:
|
||||
|
|
Loading…
Reference in New Issue