did:web endpoint builds the DID from the decoded request path, so DIDs with percent-encoded segments return 404
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia con DidWebParser.parse() in spi/did-spi/src/main/java/org/eclipse/edc/identityhub/spi/did/DidWebParser.java e DidWebParserTest. Controlla come il parser suddivide il percorso della richiesta e confronta URI.getPath() con getRawPath() per i segmenti codificati forniti. Aggiungi i due casi parametrizzati dell’issue ed esegui DidWebParserTest; il lavoro è completato quando i segmenti DID codificati vengono preservati e i casi esistenti passano.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
Describe the Bug
DidWebParser (module spi/did-spi) maps the request URL of the did:web endpoint back to a DID. It uses
URI.getPath(), which percent-decodes the path. A DID with a percent-encoded path segment is stored in its encoded
form, for example did:web:example.com%3A8443:participants:acme%28EU%29. The parser produces
did:web:example.com%3A8443:participants:acme(EU). This DID is not in the store, so DidWebController answers 404.
The code is the same on v1.0.0-RC8 and on main.
This is one of three related issues about percent-encoded did:web path segments (see Context Information).
Expected Behavior
GET https://example.com:8443/participants/acme%28EU%29/did.json returns the published DID document of
did:web:example.com%3A8443:participants:acme%28EU%29.
Observed Behavior
The endpoint answers 404. The parser looks up did:web:example.com%3A8443:participants:acme(EU).
With %3F the parser produces a DID that contains ? (...:acme?beta). That is not a valid DID.
Steps to Reproduce
Steps to reproduce the behavior:
- Add this test to
DidWebParserTest:
@ParameterizedTest
@CsvSource({
"https://example.com:8443/participants/acme%28EU%29/did.json, did:web:example.com%3A8443:participants:acme%28EU%29",
"https://example.com:8443/participants/acme%3Fbeta/did.json, did:web:example.com%3A8443:participants:acme%3Fbeta"
})
void parse_keepsPercentEncodedPathSegments(String url, String expectedDid) {
assertThat(parser.parse(URI.create(url), StandardCharsets.UTF_8)).isEqualTo(expectedDid);
}
- Run it. Both cases fail:
expected: "did:web:example.com%3A8443:participants:acme%28EU%29"
but was: "did:web:example.com%3A8443:participants:acme(EU)"
expected: "did:web:example.com%3A8443:participants:acme%3Fbeta"
but was: "did:web:example.com%3A8443:participants:acme?beta"
- End to end: create a participant context with DID
did:web:<host>:participants:acme%28EU%29(the participant
manifest validator accepts it), publish the DID, then requesthttps://<host>/participants/acme%28EU%29/did.json.
The answer is 404.
Context Information
- Used version: EDC IdentityHub
1.0.0-RC8. Also present onmain(checked 2026-11-30). - OS: not OS-specific.
- Related issues: this is one of three issues about percent-encoded did:web path segments. All three must be
fixed for such DIDs to work end to end:- eclipse-edc/Connector#6293: Connector
WebDidUrlResolverdecodes path segments, andWebDidResolverdoes not
check the documentid(resolving side). - This issue: IdentityHub
DidWebParserbuilds the DID from the decoded request path (serving side). - eclipse-edc/IdentityHub#1297: IdentityHub
SelfIssuedTokenPrecheckrejects such DIDs (token verification).
- eclipse-edc/Connector#6293: Connector
- Affected code:
DidWebParser.parse(), line 63:var segments = pathSegments(url.getPath()); DidWebControllerpassescontext.getUriInfo().getAbsolutePath(). That URI keeps the escapes, so
getRawPath()returns/participants/acme%28EU%29/did.json.- We run EDC Connector and IdentityHub in a dataspace where each participant has a did:web DID. The last path
segment is the participant's identifier from an external registry. Such identifiers can contain characters outside
[A-Za-z0-9._-], for exampleacme(EU)oracme?beta, so the segment is percent-encoded (acme%28EU%29,
acme%3Fbeta).
Detailed Description
The current code on main:
public @Nullable String parse(URI url, Charset charset) {
var segments = pathSegments(url.getPath()); // decoded path
...
// ports must be percent-encoded:
var identifier = new StringBuilder(URLEncoder.encode(url.getAuthority(), charset));
segments.forEach(segment -> identifier.append(":").append(segment));
return "%s:%s".formatted(DidConstants.DID_WEB_METHOD, identifier);
}
The parser must be the inverse of did:web resolution. Resolution keeps path segments as they are.
Specification. DID Core 1.0, section 3.1 "DID Syntax" (https://www.w3.org/TR/did-1.0/#did-syntax):
method-specific-id = *( *idchar ":" ) 1*idchar
idchar = ALPHA / DIGIT / "." / "-" / "_" / pct-encoded
pct-encoded = "%" HEXDIG HEXDIG
did:web Method Specification, "Read (Resolve)" (https://w3c-ccg.github.io/did-method-web/#read-resolve):
- Replace ":" with "/" in the method specific identifier to obtain the fully qualified domain name and optional path.
- If the domain contains a port percent decode the colon.
Only the port colon is decoded. So did:web:example.com%3A8443:participants:acme%28EU%29 has the document URL
https://example.com:8443/participants/acme%28EU%29/did.json. The way back from that URL must give acme%28EU%29, not acme(EU).
RFC 3986, section 2.2 (https://www.rfc-editor.org/rfc/rfc3986#section-2.2): URIs that differ by replacing a reserved
character with its percent-encoded octet are not equivalent. So the decoded path is a different resource.
Why the parser decodes (history). We think it is not intended:
getPath()is in the first version of the parser (PR #198, local DID publisher).- PR #1214 (issue #1213) hardened the endpoint: one DID document under exactly three URLs, everything else 404.
It keptgetPath(). The issue and the PR do not discuss percent-encoding. - The Javadoc talks about encoding only for the authority ("URL-Encode the authority ... to clearly distinguish it
from the method separator"). The tests cover only the encoded port. No test covers an escape in a path segment. - In the same change (#1214),
ParticipantManifestValidatorstarted to accept DID Coreidchar(%XX) in did:web
DIDs. So IdentityHub lets a participant create such a DID, but its own endpoint cannot serve it.
Side effect. With the decoded path, an escaped / changes the segment list. The parser maps
/a%2Fb/did.json to did:web:<host>:a:b. That is a fourth URL for the document of did:web:<host>:a:b, which the
class Javadoc excludes. (The servlet container may reject %2F before the parser runs.) With the raw path,
a%2Fb stays one segment, and maps to the DID did:web:<host>:a%2Fb.
Possible Implementation
Use the raw path. Each DID then keeps exactly the URLs the Javadoc lists, in its own spelling.
--- a/spi/did-spi/src/main/java/org/eclipse/edc/identityhub/spi/did/DidWebParser.java
+++ b/spi/did-spi/src/main/java/org/eclipse/edc/identityhub/spi/did/DidWebParser.java
@@
public @Nullable String parse(URI url, Charset charset) {
- var segments = pathSegments(url.getPath());
+ // did:web keeps percent-encoded path segments as they are, only the port colon is encoded/decoded
+ var segments = pathSegments(url.getRawPath());
if (segments == null) {
return null;
}
The existing DidWebParserTest cases have no escapes in the path, so they still pass. Add the cases from
"Steps to Reproduce".
Optional: also reject a raw segment that is not DID Core 1*idchar (return null, so 404). A request such as
/participants/acme(EU)/did.json then gives no DID, instead of the invalid DID ...:acme(EU).
The client side has the matching problem: Connector WebDidUrlResolver decodes path segments when it builds the
URL (see eclipse-edc/Connector#6293). Both fixes are needed for such DIDs to work end to end.
- Lingua principale
- Java
- Stelle
- 46
- Fork
- 65
- Merge medio
- 1g 5h
- PR unite (30g)
- 26
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di eclipse-edc/IdentityHub
-
triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
eclipse-edc/IdentityHub#1297 ·
I maintainer di solito rispondono entro 1 giorno
-
triage
Difficoltà 4/5 1-2 giorni Idoneità per principianti 48/100
eclipse-edc/IdentityHub#1286 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Credential status check queries the status list before the expiry check, so expired credentials can end in ERRORForse già presa @paullatzelsperger l’ha presa 6 giorni fa. Apertatriage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
eclipse-edc/IdentityHub#1282 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
question triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
eclipse-edc/IdentityHub#1271 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Issuer: add support for `issuancePolicies`Forse di nuovo libera @paullatzelsperger l’ha presa 545 giorni fa e non c’è nessuna pull request aperta. Apertadcp enhancement
eclipse-edc/IdentityHub#694 · 5 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di eclipse-edc/IdentityHub
Issue simili
-
ui: 進捗状況線ダイアログが日本語表示で英語のままApertaarea: ui priority: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
tetsuji16/microProject#1721 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
The engine's "loaded, but had errors" message leaves out which library and line each error is inAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
cqframework/clinical_quality_language#1980 ·
I maintainer di solito rispondono entro 3 giorni
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 87/100
dedicatedcode/reitti#1445 ·
I maintainer di solito rispondono entro 1 giorno
-
fix: 页面 AI 小鲸未配置当前用户的租户请求头Apertabacklog kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
TencentBlueKing/bk-job#4642 ·
I maintainer di solito rispondono entro 1 giorno