did:web endpoint builds the DID from the decoded request path, so DIDs with percent-encoded segments return 404
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start with DidWebParser.parse() in spi/did-spi/src/main/java/org/eclipse/edc/identityhub/spi/did/DidWebParser.java and DidWebParserTest. Check how the parser splits the request path and compare URI.getPath() with getRawPath() for the supplied encoded segments. Add the two parameterized cases from the issue and run DidWebParserTest; done when they preserve the encoded DID segments and existing cases pass.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Java
- Stars
- 46
- Forks
- 65
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 26
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from eclipse-edc/IdentityHub
-
triage
Difficulty 3/5 1-2 days Newbie friendliness 55/100
eclipse-edc/IdentityHub#1297 ·
Maintainers usually reply within 1 day
-
triage
Difficulty 4/5 1-2 days Newbie friendliness 48/100
eclipse-edc/IdentityHub#1286 · 1 comment ·
Maintainers usually reply within 1 day
-
Credential status check queries the status list before the expiry check, so expired credentials can end in ERRORPossibly taken @paullatzelsperger claimed this 6 days ago. Opentriage
Difficulty 3/5 1-2 days Newbie friendliness 42/100
eclipse-edc/IdentityHub#1282 · 4 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
question triage
Difficulty 5/5 Over a week Newbie friendliness 35/100
eclipse-edc/IdentityHub#1271 · 3 comments ·
Maintainers usually reply within 1 day
-
Issuer: add support for `issuancePolicies`May be free again @paullatzelsperger claimed this 545 days ago, and no pull request is open. Opendcp enhancement
eclipse-edc/IdentityHub#694 · 5 comments · 1 assignee ·
Maintainers usually reply within 1 day
All issues in eclipse-edc/IdentityHub
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
cloudfoundry/uaa#4194 ·
Maintainers usually reply within 1 day
-
area: ui priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
tetsuji16/microProject#1721 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
The engine's "loaded, but had errors" message leaves out which library and line each error is inOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
cqframework/clinical_quality_language#1980 ·
Maintainers usually reply within 3 days
-
windows-sys 0.101.0Open
Difficulty 2/5 1-3 hours Newbie friendliness 61/100