feat: /.well-known/nodeinfoを作成

This commit is contained in:
usbharu 2025-02-24 23:42:46 +09:00
parent ac5dee2551
commit 4be93fea86
Signed by: usbharu
GPG Key ID: 8CB1087135660B8D
5 changed files with 32 additions and 4 deletions

View File

@ -0,0 +1,3 @@
package dev.usbharu.hideout.activitypub.application.nodeinfo
data class Nodeinfo2_0()

View File

@ -24,6 +24,7 @@ class ActivityPubSecurityConfig {
)
authorizeHttpRequests {
authorize(GET, "/.well-known/**", permitAll)
authorize(GET, "/nodeinfo/**", permitAll)
authorize(GET, "/error", permitAll)
authorize(POST, "/inbox", permitAll)
authorize(POST, "/users/{username}/inbox", permitAll)

View File

@ -0,0 +1,23 @@
package dev.usbharu.hideout.activitypub.interfaces.wellknown
import dev.usbharu.hideout.core.config.ApplicationConfig
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/.well-known")
class NodeinfoController(private val applicationConfig: ApplicationConfig) {
@GetMapping("/nodeinfo", produces = ["application/json"])
suspend fun nodeinfo(): XRD = XRD(
listOf(
Link(
"http://nodeinfo.diaspora.software/ns/schema/2.1",
href = applicationConfig.url.resolve("/nodeinfo/2.1").toString()
), Link(
"http://nodeinfo.diaspora.software/ns/schema/2.0",
href = applicationConfig.url.resolve("/nodeinfo/2.0").toString()
)
)
)
}

View File

@ -24,8 +24,9 @@ data class XRD(
data class Link(
@JacksonXmlProperty(localName = "rel", isAttribute = true) val rel: String,
@JsonInclude(JsonInclude.Include.NON_NULL)
@JacksonXmlProperty(localName = "template", isAttribute = true) val template: String?,
@JacksonXmlProperty(localName = "type", isAttribute = true) val type: String,
@JacksonXmlProperty(localName = "template", isAttribute = true) val template: String? = null,
@JsonInclude(JsonInclude.Include.NON_NULL)
@JacksonXmlProperty(localName = "href", isAttribute = true) val href: String?,
@JacksonXmlProperty(localName = "type", isAttribute = true) val type: String? = null,
@JsonInclude(JsonInclude.Include.NON_NULL)
@JacksonXmlProperty(localName = "href", isAttribute = true) val href: String? = null,
)

View File

@ -90,7 +90,7 @@ class SecurityConfig {
authorize("/error", permitAll)
authorize("/auth/sign_in", permitAll)
authorize(GET, "/.well-known/**", permitAll)
authorize(GET, "/nodeinfo/2.0", permitAll)
authorize(GET, "/nodeinfo/**", permitAll)
authorize(GET, "/auth/sign_up", hasRole("ANONYMOUS"))
authorize(POST, "/auth/sign_up", permitAll)