Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
710010e
Run Maven tests on every pull request.
Aug 27, 2026
15c596a
Add a Maven skeleton so CI can run server tests.
Aug 27, 2026
f26b370
Always run Maven tests, and pin GitHub Actions to SHAs.
Aug 27, 2026
b59cbda
Add server runtime configuration and metadata-store dependencies.
Sep 1, 2026
585f562
Default protocol-prefix to /opensharing.
Sep 1, 2026
447a113
Keep application.yml limited to Spring and server defaults.
Sep 1, 2026
d1b335c
Add Base Entity.
Sep 1, 2026
2bc6fd1
Add Object Names.
Sep 1, 2026
99eceaf
Add Error Codes.
Sep 1, 2026
c9f364c
Add Error Response.
Sep 1, 2026
be3b7d6
Add Api Exception.
Sep 1, 2026
2798753
Add Admin Json.
Sep 1, 2026
8e5eab0
Add Protocol Media Type.
Sep 1, 2026
7396481
Add List Response.
Sep 1, 2026
01d5421
Add Offset Pageable.
Sep 1, 2026
9ec4283
Add Offset Page.
Sep 1, 2026
02b5c49
Add Page Tokens.
Sep 1, 2026
d8c63f8
Add Protocol Action.
Sep 1, 2026
43a7d17
Add Metadata Action.
Sep 1, 2026
f33a2af
Add File Action.
Sep 1, 2026
83c844b
Add Change File Action.
Sep 1, 2026
d41b97f
Add End Stream Action.
Sep 1, 2026
c229c4d
Add Table Action.
Sep 1, 2026
1cdc092
Add Aws Credentials.
Sep 1, 2026
67ca73f
Add Azure User Delegation Sas.
Sep 1, 2026
8c9c63b
Add Gcp Oauth Token.
Sep 1, 2026
f9dd60f
Add R2 Credentials.
Sep 1, 2026
5685e8f
Add Get Share Response.
Sep 1, 2026
e4e5d35
Add Schema.
Sep 1, 2026
7e56bae
Add Share.
Sep 1, 2026
774b7c9
Add Table.
Sep 1, 2026
5697917
Add Profile File.
Sep 1, 2026
6490e13
Add Iceberg Config.
Sep 1, 2026
be80a46
Add Query Table Request.
Sep 1, 2026
fa95dc1
Add Temporary Credentials.
Sep 1, 2026
4208709
Add Temporary Credentials Request.
Sep 1, 2026
642209f
Add global error handling for protocol failures.
Sep 1, 2026
52bcd9a
Require a named principal on every CatalogCaller.
Sep 1, 2026
62003ab
Fold access-denied and auth failures into CatalogException.
Sep 1, 2026
340b5bf
Use one authorization subclass with a Reason enum.
Sep 1, 2026
be9a66c
Treat catalog access denied and auth failure as one case.
Sep 1, 2026
82a7b67
Keep PR 3 to generic HTTP error handling only.
Sep 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
server-test:
name: Server tests
runs-on: ubuntu-24.04
defaults:
run:
working-directory: server
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Java 21
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
with:
distribution: temurin
java-version: "21"
cache: maven
cache-dependency-path: server/pom.xml

- name: Run tests
run: mvn -B -ntp verify

- name: Upload test reports
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: surefire-reports
path: server/target/surefire-reports/
if-no-files-found: ignore
5 changes: 5 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target/
data/
*.db
*.mv.db
*.trace.db
10 changes: 10 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# OpenSharing Reference Server

Reference implementation of the [OpenSharing](https://github.com/OpenSharing-IO/OpenSharing) protocol.

## Build

```bash
cd server
mvn test
```
104 changes: 104 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.opensharing</groupId>
<artifactId>opensharing-server</artifactId>
<version>0.1.0-SNAPSHOT</version>

<name>OpenSharing Reference Server</name>
<description>Reference implementation of the OpenSharing protocol</description>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
<spring-boot.version>3.5.3</spring-boot.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
55 changes: 55 additions & 0 deletions server/src/main/java/io/opensharing/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package io.opensharing;

import jakarta.persistence.Column;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import java.time.Instant;
import java.util.UUID;

/** Server-assigned identity and audit columns shared by every stored entity. */
@MappedSuperclass
public abstract class BaseEntity {

@Id
@Column(name = "id", length = 36, nullable = false, updatable = false)
private String id = UUID.randomUUID().toString();

@Column(name = "created_at", nullable = false, updatable = false)
private Instant createdAt;

@Column(name = "updated_at", nullable = false)
private Instant updatedAt;

@PrePersist
void onPersist() {
this.createdAt = Instant.now();
this.updatedAt = this.createdAt;
}

@PreUpdate
void onUpdate() {
this.updatedAt = Instant.now();
}

public String getId() {
return id;
}

/**
* Adopts an id chosen elsewhere, for the entities whose identity is not the server's to invent. Only
* meaningful before the row is written: the column is not updatable.
*/
protected void setId(String id) {
this.id = id;
}

public Instant getCreatedAt() {
return createdAt;
}

public Instant getUpdatedAt() {
return updatedAt;
}
}
69 changes: 69 additions & 0 deletions server/src/main/java/io/opensharing/ObjectNames.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package io.opensharing;

import java.util.Locale;

/**
* Name rules from {@code spec/protocols/OVERVIEW.md}. Object names are compared case-insensitively,
* so callers persist {@link #normalize(String)} alongside the name as provided.
*/
public final class ObjectNames {

public static final int MAX_LENGTH = 255;

private ObjectNames() {}

/** Validates a share name. */
public static String validateShareName(String name) {
return validate(name, "share name", false);
}

/** Validates a schema name, which additionally disallows {@code .}. */
public static String validateSchemaName(String name) {
return validate(name, "schema name", true);
}

/** Validates a shared asset name, which additionally disallows {@code .}. */
public static String validateAssetName(String name) {
return validate(name, "asset name", true);
}

/** Validates a recipient name using the same rules as a share name. */
public static String validateRecipientName(String name) {
return validate(name, "recipient name", false);
}

/** Validates a principal name, which is often an email address and so may contain periods. */
public static String validatePrincipalName(String name) {
return validate(name, "principal name", false);
}

/** Lower-cases a name for case-insensitive lookups and uniqueness checks. */
public static String normalize(String name) {
return name == null ? null : name.toLowerCase(Locale.ROOT);
}

private static String validate(String name, String what, boolean rejectPeriod) {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(what + " must not be empty");
}
if (name.length() > MAX_LENGTH) {
throw new IllegalArgumentException(what + " must not exceed " + MAX_LENGTH + " characters");
}
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if (c == ' ') {
throw new IllegalArgumentException(what + " must not contain a space");
}
if (c == '/') {
throw new IllegalArgumentException(what + " must not contain a forward slash");
}
if (c <= 0x1F || c == 0x7F) {
throw new IllegalArgumentException(what + " must not contain control characters");
}
if (rejectPeriod && c == '.') {
throw new IllegalArgumentException(what + " must not contain a period");
}
}
return name;
}
}
12 changes: 12 additions & 0 deletions server/src/main/java/io/opensharing/OpenSharingServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.opensharing;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class OpenSharingServer {

public static void main(String[] args) {
SpringApplication.run(OpenSharingServer.class, args);
}
}
19 changes: 19 additions & 0 deletions server/src/main/java/io/opensharing/http/AdminJson.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.opensharing.http;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Marks a provider-admin request or response body. The admin API speaks snake_case, unlike the
* recipient-facing protocol, which is camelCase and must stay that way for Delta Sharing clients.
*/
@JacksonAnnotationsInside
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface AdminJson {}
54 changes: 54 additions & 0 deletions server/src/main/java/io/opensharing/http/ApiException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package io.opensharing.http;

import org.springframework.http.HttpStatus;

/** An error with an explicit protocol error code and HTTP status. */
public class ApiException extends RuntimeException {

private final HttpStatus status;
private final String errorCode;

public ApiException(HttpStatus status, String errorCode, String message) {
super(message);
this.status = status;
this.errorCode = errorCode;
}

public HttpStatus getStatus() {
return status;
}

public String getErrorCode() {
return errorCode;
}

public static ApiException notFound(String message) {
return new ApiException(HttpStatus.NOT_FOUND, ErrorCodes.RESOURCE_DOES_NOT_EXIST, message);
}

public static ApiException alreadyExists(String message) {
return new ApiException(HttpStatus.CONFLICT, ErrorCodes.RESOURCE_ALREADY_EXISTS, message);
}

/** The object exists, but its current state does not allow what was asked. */
public static ApiException conflict(String message) {
return new ApiException(HttpStatus.CONFLICT, ErrorCodes.RESOURCE_CONFLICT, message);
}

public static ApiException invalidParameter(String message) {
return new ApiException(HttpStatus.BAD_REQUEST, ErrorCodes.INVALID_PARAMETER_VALUE, message);
}

/** The caller is known, but is not allowed to do this. */
public static ApiException permissionDenied(String message) {
return new ApiException(HttpStatus.FORBIDDEN, ErrorCodes.PERMISSION_DENIED, message);
}

public static ApiException unauthenticated(String message) {
return new ApiException(HttpStatus.UNAUTHORIZED, ErrorCodes.UNAUTHENTICATED, message);
}

public static ApiException notImplemented(String message) {
return new ApiException(HttpStatus.NOT_IMPLEMENTED, ErrorCodes.NOT_IMPLEMENTED, message);
}
}
Loading