Skip to content

WebDAV backend for persistence #2

@melvincarvalho

Description

@melvincarvalho

Summary

WebDAV is a natural fit for solidos-lite persistence. It treats HTML files as first-class resources - no translation needed between data islands and Turtle.

Why WebDAV?

  • GET - serve HTML with data island ✓
  • PUT - save entire HTML file back ✓
  • DELETE, MKCOL, COPY, MOVE - all just work ✓
  • Widely deployed (Apache, Nginx, Nextcloud, NAS devices)
  • Battle-tested protocol (RFC 4918)
  • Native OS support (mount as drive on macOS/Windows)
  • Much simpler than Solid's LDP semantics

Technical Findings

Browser Support

  • Browsers can make PUT requests via Fetch/XHR
  • Works for overwriting existing files
  • Creating new files triggers CORS preflight

CORS Challenge

  • Most WebDAV servers don't return CORS headers by default
  • Workarounds:
    • Configure server-side CORS headers (Apache/Nginx)
    • Same-origin deployment
    • Use a proxy

Authentication

Method Notes
Basic Auth Simple, needs HTTPS
Digest Auth Challenge-response
Bearer Token Modern, needs server support

JavaScript Libraries

  • webdav npm package (recommended, actively maintained)
  • Raw Fetch/XHR for simple cases

Implementation Approach

Phase 1: Basic PUT support

// Intercept writes, serialize HTML with updated data island
async function saveToWebDAV(url, htmlContent) {
  const response = await fetch(url, {
    method: 'PUT',
    headers: { 'Content-Type': 'text/html; charset=utf-8' },
    body: htmlContent
  });
  return response.ok;
}

Phase 2: Serialize data island

  1. Intercept fetcher.webOperation() for PUT/PATCH
  2. Serialize RDF store back to Turtle
  3. Update <script type="text/turtle"> in DOM
  4. PUT entire HTML document

Phase 3: Authentication UI

  • Prompt for WebDAV credentials
  • Store in sessionStorage
  • Add Authorization header to requests

Example Servers for Testing

  • Apache mod_dav
  • Nginx with dav_ext_module
  • Nextcloud (needs CORS config)
  • sabre/dav (PHP)
  • Simple Python: wsgidav

Benefits Over Solid Servers

  • No need for servers to understand data islands
  • HTML file IS the resource (no translation)
  • Simpler protocol, more deployment options
  • Can use existing infrastructure

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions