Skip to content

Commit

Permalink
feat: adjust federation fetch endpoint to new spec without iss param
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmelati committed Oct 30, 2024
1 parent c12610c commit fb3fc6e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 44 deletions.
1 change: 1 addition & 0 deletions modules/federation-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
api(projects.modules.openapi)
api(projects.modules.openidFederationCommon)
api(projects.modules.persistence)
api(projects.modules.services)
implementation(libs.springboot.actuator)
implementation(libs.springboot.web)
implementation(libs.springboot.data.jdbc)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.sphereon.oid.fed.server.federation.controllers

import com.sphereon.oid.fed.persistence.Persistence
import com.sphereon.oid.fed.server.federation.services.SubordinateService
import com.sphereon.oid.fed.services.SubordinateService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
Expand Down Expand Up @@ -49,12 +49,12 @@ class FederationController {
}

@GetMapping("/fetch", produces = ["application/entity-statement+jwt"])
fun getRootSubordinateStatement(@RequestParam("iss") iss: String, @RequestParam("sub") sub: String): String {
return subordinateService.fetchSubordinateStatement(iss, sub)
fun getRootSubordinateStatement(@RequestParam("sub") sub: String): String {
return subordinateService.fetchSubordinateStatementByUsernameAndSubject("root", sub)
}

@GetMapping("/{username}/fetch", produces = ["application/entity-statement+jwt"])
fun getSubordinateStatement(@RequestParam("iss") iss: String, @RequestParam("sub") sub: String): String {
return subordinateService.fetchSubordinateStatement(iss, sub)
fun getSubordinateStatement(@PathVariable username: String, @RequestParam("sub") sub: String): String {
return subordinateService.fetchSubordinateStatementByUsernameAndSubject(username, sub)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,8 @@ paths:
tags:
- federation
summary: Fetch Subordinate Statement
description: Fetch the Subordinate Statement issued by a specified entity `iss` for a subordinate entity `sub``.
description: Fetch the Subordinate Statement for a subordinate entity `sub``.
parameters:
- name: iss
in: query
description: The issuer identifier (URI) of the entity that issues the Subordinate Statement.
required: true
schema:
type: string
format: uri
- name: sub
in: query
description: The subject identifier (URI) of the entity for whom the Subordinate Statement is created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,16 @@ class SubordinateService {

return deletedMetadata.toSubordinateMetadataDTO()
}

fun fetchSubordinateStatementByUsernameAndSubject(username: String, sub: String): String {
val account = accountQueries.findByUsername(username).executeAsOne()

val accountIss = accountService.getAccountIdentifier(account.username)

val subordinateStatement =
Persistence.subordinateStatementQueries.findByIssAndSub(accountIss, sub).executeAsOneOrNull()
?: throw IllegalArgumentException(Constants.SUBORDINATE_STATEMENT_NOT_FOUND)

return subordinateStatement.statement
}
}

0 comments on commit fb3fc6e

Please sign in to comment.