Skip to content

Commit

Permalink
fix: reorder authority hints to process trust anchors first
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmelati committed Oct 20, 2024
1 parent 2d638d2 commit 7830b0b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ class TrustChain(private val fetchService: IFetchCallbackService, private val cr

val authorityHints = entityStatement.authorityHints ?: return null

for (authority in authorityHints) {
val reorderedAuthorityHints = authorityHints.sortedBy { hint ->
if (trustAnchors.contains(hint)) 0 else 1
}

for (authority in reorderedAuthorityHints) {
val result = processAuthority(
authority,
entityIdentifier,
Expand Down Expand Up @@ -161,6 +165,7 @@ class TrustChain(private val fetchService: IFetchCallbackService, private val cr
// Check if the entity key exists in subordinate statement
val entityKeyExistsInSubordinateStatement = checkKidInJwks(keys, lastStatementKid)
if (!entityKeyExistsInSubordinateStatement) return null

// If authority is in trust anchors, return the completed chain
if (trustAnchors.contains(authority)) {
chain.add(subordinateStatementJwt)
Expand Down

0 comments on commit 7830b0b

Please sign in to comment.