From 70c3e408f43d5b4299a6aa2351e67833d2f3b05e Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 31 Mar 2023 17:24:46 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20pubkey=E3=81=AE=E5=A0=B4=E6=89=80?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt | 4 ++-- .../dev/usbharu/hideout/service/ActivityPubUserService.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt index ed0eb615..8cd9cfdc 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt @@ -146,7 +146,7 @@ val httpSignaturePlugin = createClientPlugin("HttpSign", ::HttpSignaturePluginCo class KtorKeyMap(private val userAuthRepository: IUserAuthService) : KeyMap { override fun getPublicKey(keyId: String?): PublicKey = runBlocking { - val username = (keyId ?: throw IllegalArgumentException("keyId is null")).substringBeforeLast("/pubkey") + val username = (keyId ?: throw IllegalArgumentException("keyId is null")).substringBeforeLast("#pubkey") .substringAfterLast("/") val publicBytes = Base64.getDecoder().decode( userAuthRepository.findByUsername( @@ -159,7 +159,7 @@ class KtorKeyMap(private val userAuthRepository: IUserAuthService) : KeyMap { } override fun getPrivateKey(keyId: String?): PrivateKey = runBlocking { - val username = (keyId ?: throw IllegalArgumentException("keyId is null")).substringBeforeLast("/pubkey") + val username = (keyId ?: throw IllegalArgumentException("keyId is null")).substringBeforeLast("#pubkey") .substringAfterLast("/") val publicBytes = Base64.getDecoder().decode( userAuthRepository.findByUsername( diff --git a/src/main/kotlin/dev/usbharu/hideout/service/ActivityPubUserService.kt b/src/main/kotlin/dev/usbharu/hideout/service/ActivityPubUserService.kt index e4ff466d..4c2b0f82 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/ActivityPubUserService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/ActivityPubUserService.kt @@ -33,7 +33,7 @@ class ActivityPubUserService( publicKey = Key( type = emptyList(), name = "Public Key", - id = "$userUrl/pubkey", + id = "$userUrl#pubkey", owner = userUrl, publicKeyPem = userAuthEntity.publicKey ) @@ -45,7 +45,7 @@ class ActivityPubUserService( val person = webFingerService.fetchUserModel(actor) ?: throw IllegalArgumentException("actor is not found") val inboxUrl = person.inbox ?: throw IllegalArgumentException("inbox is not found") httpClient.postAp( - inboxUrl, "${follow.`object`!!}/pubkey", Accept( + inboxUrl, "${follow.`object`!!}#pubkey", Accept( name = "Follow", `object` = follow, actor = follow.`object`.orEmpty()