Title: Add WebID-TLS authentication support · Issue #67 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub
Open Graph Title: Add WebID-TLS authentication support · Issue #67 · JavaScriptSolidServer/JavaScriptSolidServer
X Title: Add WebID-TLS authentication support · Issue #67 · JavaScriptSolidServer/JavaScriptSolidServer
Description: Summary Add WebID-TLS (mutual TLS / client certificate) authentication to JSS, enabling backend services, CLI tools, and automated agents to authenticate without user interaction. Background What is WebID-TLS? WebID-TLS is a decentralize...
Open Graph Description: Summary Add WebID-TLS (mutual TLS / client certificate) authentication to JSS, enabling backend services, CLI tools, and automated agents to authenticate without user interaction. Background What i...
X Description: Summary Add WebID-TLS (mutual TLS / client certificate) authentication to JSS, enabling backend services, CLI tools, and automated agents to authenticate without user interaction. Background What i...
Opengraph URL: https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/67
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add WebID-TLS authentication support","articleBody":"## Summary\n\nAdd WebID-TLS (mutual TLS / client certificate) authentication to JSS, enabling backend services, CLI tools, and automated agents to authenticate without user interaction.\n\n## Background\n\n### What is WebID-TLS?\n\nWebID-TLS is a decentralized authentication protocol that uses TLS client certificates:\n\n1. Client presents X.509 certificate during TLS handshake\n2. Certificate's `SubjectAlternativeName` (SAN) contains a WebID URI\n3. Server fetches the WebID profile document\n4. Server verifies the certificate's public key matches the one published in the profile\n\n```mermaid\nsequenceDiagram\n participant C as Client\n participant S as JSS Server\n participant P as WebID Profile\n \n C->>S: TLS Handshake + Client Cert\n Note over S: Extract WebID from SAN\n S->>P: Fetch WebID Profile\n P-->>S: Profile with cert:key\n Note over S: Match modulus + exponent\n S-->>C: Authenticated as WebID\n```\n\n### Why Now?\n\nThe W3C Linked Web Storage Use Cases group has [raised this need](https://github.com/w3c/lws-ucs/issues/40) for enterprise adoption:\n\n> *\"As a large tax advisory office, I want our existing backend services to authenticate themselves (without user interaction), such that these services can fetch and crunch private data from our clients.\"*\n\nKey drivers:\n- **Enterprise adoption**: Organizations with existing PKI/mTLS infrastructure want seamless LWS integration\n- **Backend services**: Server-to-server communication doesn't need browser UX\n- **IoT/Agents**: Automated systems need non-interactive authentication\n- **CLI tools**: Developers using `curl` or custom tools with client certs\n\n### Browser Support Note\n\nWhile browser support for in-browser certificate generation (`\u003ckeygen>`) has been [removed from Chrome](https://groups.google.com/a/chromium.org/g/blink-dev/c/pX5NbX0Xack/m/kmHsyMGJZAMJ) and deprecated in Firefox, this **does not affect server-side WebID-TLS**:\n\n- Server-to-server: Works perfectly with standard mTLS\n- CLI tools: `curl --cert` works fine\n- Browser workarounds: [YouID extension](https://vos.openlinksw.com/dataspace/owiki/wiki/VOS/WebIDTLSDelegationWhatWhyHow) available\n\n## Implementation Guide\n\n### Files to Create/Modify\n\n| File | Purpose |\n|------|---------|\n| `src/auth/webid-tls.js` | WebID-TLS authentication module |\n| `src/server.js` | Enable `requestCert` option on HTTPS server |\n| `src/config.js` | Add `--webid-tls` CLI flag |\n\n### Step 1: Server Configuration\n\nModify `src/server.js` to request client certificates:\n\n```javascript\n// In createServer, when SSL is enabled\nif (options.ssl && options.ssl.key && options.ssl.cert) {\n const httpsOptions = {\n key: options.ssl.key,\n cert: options.ssl.cert,\n // Enable WebID-TLS\n requestCert: options.webidTls || false, // Request client cert\n rejectUnauthorized: false // Don't reject self-signed (we verify via WebID)\n };\n // ... create HTTPS server\n}\n```\n\n### Step 2: Create WebID-TLS Auth Module\n\nCreate `src/auth/webid-tls.js`:\n\n```javascript\nimport { graph, SPARQLToQuery } from 'rdflib';\n\nconst SPARQL_QUERY = `\n PREFIX cert: \u003chttp://www.w3.org/ns/auth/cert#>\n SELECT ?webid ?m ?e WHERE {\n ?webid cert:key ?key .\n ?key cert:modulus ?m .\n ?key cert:exponent ?e .\n }\n`;\n\n/**\n * Extract WebID from client certificate's SubjectAlternativeName\n */\nexport function getWebIdFromCert(certificate) {\n if (!certificate?.subjectaltname) return null;\n \n const match = certificate.subjectaltname.match(/URI:([^,\\s]+)/);\n return match ? match[1] : null;\n}\n\n/**\n * Verify certificate public key matches WebID profile\n */\nexport async function verifyWebIdTls(certificate, webId) {\n if (!certificate.modulus || !certificate.exponent) {\n throw new Error('Certificate missing modulus or exponent');\n }\n \n // Fetch WebID profile\n const response = await fetch(webId, {\n headers: { 'Accept': 'text/turtle, application/ld+json' }\n });\n \n if (!response.ok) {\n throw new Error(`Failed to fetch WebID profile: ${response.status}`);\n }\n \n const body = await response.text();\n const contentType = response.headers.get('content-type')?.split(';')[0];\n \n // Parse profile and find matching key\n const g = graph();\n // ... parse RDF and run SPARQL query\n \n const certModulus = certificate.modulus.toLowerCase();\n const certExponent = parseInt(certificate.exponent, 16).toString();\n \n // Match modulus and exponent from profile\n // Return true if match found, false otherwise\n}\n\n/**\n * Middleware to authenticate via WebID-TLS\n */\nexport async function webIdTlsAuth(request) {\n const socket = request.raw?.socket || request.socket;\n \n if (!socket?.getPeerCertificate) {\n return null; // Not a TLS connection\n }\n \n const cert = socket.getPeerCertificate();\n if (!cert || Object.keys(cert).length === 0) {\n return null; // No client certificate\n }\n \n const webId = getWebIdFromCert(cert);\n if (!webId) {\n return null; // No WebID in certificate\n }\n \n const verified = await verifyWebIdTls(cert, webId);\n return verified ? webId : null;\n}\n```\n\n### Step 3: Integrate with Auth Flow\n\nIn `src/auth/token.js`, add WebID-TLS as authentication method:\n\n```javascript\nimport { webIdTlsAuth } from './webid-tls.js';\n\nexport async function getWebIdFromRequestAsync(request) {\n // Try bearer token first\n let webId = await getWebIdFromToken(request);\n \n // Fall back to WebID-TLS\n if (!webId) {\n webId = await webIdTlsAuth(request);\n }\n \n return { webId };\n}\n```\n\n### Step 4: CLI Configuration\n\nAdd to `src/config.js`:\n\n```javascript\n.option('--webid-tls', 'Enable WebID-TLS client certificate authentication')\n```\n\n## Testing\n\n### Manual Testing with curl\n\n```bash\n# Generate self-signed cert with WebID in SAN\nopenssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 \\\n -subj \"/CN=Test\" -addext \"subjectAltName=URI:https://example.com/profile/card#me\"\n\n# Test authentication\ncurl --cert cert.pem --key key.pem https://localhost:8443/private/resource\n```\n\n### Unit Tests\n\n```javascript\ndescribe('WebID-TLS Authentication', () => {\n it('should extract WebID from certificate SAN', () => {\n const cert = { subjectaltname: 'URI:https://alice.example/card#me' };\n expect(getWebIdFromCert(cert)).toBe('https://alice.example/card#me');\n });\n \n it('should verify certificate against WebID profile', async () => {\n // Mock profile with matching cert:key\n // Verify returns true\n });\n \n it('should reject mismatched certificate', async () => {\n // Mock profile with different key\n // Verify returns false\n });\n});\n```\n\n## WebID Profile Requirements\n\nFor WebID-TLS to work, the WebID profile must contain the certificate's public key:\n\n```turtle\n@prefix cert: \u003chttp://www.w3.org/ns/auth/cert#> .\n@prefix xsd: \u003chttp://www.w3.org/2001/XMLSchema#> .\n\n\u003c#me> cert:key [\n a cert:RSAPublicKey;\n cert:modulus \"abc123...\"^^xsd:hexBinary;\n cert:exponent 65537\n] .\n```\n\n## Use Cases Enabled\n\n1. **Backend Services**: Tax advisors fetching client data (W3C use case)\n2. **CLI Tools**: Developers using `curl` or custom scripts\n3. **IoT Devices**: Sensors/actuators with embedded certificates\n4. **Automated Agents**: Bots and crawlers with verifiable identity\n5. **Legacy Integration**: Organizations with existing PKI infrastructure\n\n## References\n\n- [WebID-TLS Spec](https://dvcs.w3.org/hg/WebID/raw-file/tip/spec/tls-respec.html)\n- [W3C LWS-UCS Issue #40](https://github.com/w3c/lws-ucs/issues/40) - Enterprise use case\n- [Solid Protocol - WebID-TLS](https://solidproject.org/TR/protocol#webid-tls)\n- [NSS WebID-TLS Implementation](https://github.com/nodeSolidServer/node-solid-server/blob/main/lib/api/authn/webid-tls.mjs)\n- [YouID Browser Extension](https://vos.openlinksw.com/dataspace/owiki/wiki/VOS/WebIDTLSDelegationWhatWhyHow)\n\n## Related\n\n- Solid-OIDC (current default auth) remains primary for browser-based apps\n- WebID-TLS would be an additional authentication method, not a replacement","author":{"url":"https://github.com/melvincarvalho","@type":"Person","name":"melvincarvalho"},"datePublished":"2026-01-08T20:28:33Z","url":"https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/67"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a4c20464-45ad-6b9c-cccb-2e8ca1f7b72e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C32:B4652:107B974:14EDF4F:6B0389D6 |
| html-safe-nonce | 1a8dc4ce235ae425c0546032b2d246256f0c820331e6a75864fda5f81db57bc9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzMyOkI0NjUyOjEwN0I5NzQ6MTRFREY0Rjo2QjAzODlENiIsInZpc2l0b3JfaWQiOiIzOTY5NjE4MTU2NDE0Mjc0MDA2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8330fd080a70d7a850ac0089aa4a9359c4194e7b31843ded2fd12458c33d560c |
| hovercard-subject-tag | issue:3794327135 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JavaScriptSolidServer/JavaScriptSolidServer/67/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a8714eb5e0e6073f7d7ffd6088d58ccbbf1c1c5bb3ccdb199c8d21568c3c0377/JavaScriptSolidServer/JavaScriptSolidServer/issues/67 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a8714eb5e0e6073f7d7ffd6088d58ccbbf1c1c5bb3ccdb199c8d21568c3c0377/JavaScriptSolidServer/JavaScriptSolidServer/issues/67 |
| og:image:alt | Summary Add WebID-TLS (mutual TLS / client certificate) authentication to JSS, enabling backend services, CLI tools, and automated agents to authenticate without user interaction. Background What i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | melvincarvalho |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/JavaScriptSolidServer/JavaScriptSolidServer git https://github.com/JavaScriptSolidServer/JavaScriptSolidServer.git |
| octolytics-dimension-user_id | 205442424 |
| octolytics-dimension-user_login | JavaScriptSolidServer |
| octolytics-dimension-repository_id | 958025407 |
| octolytics-dimension-repository_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 958025407 |
| octolytics-dimension-repository_network_root_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width