Skip to content
AIDotNetPublic

About

Means 是一个面向应用文件与静态资源场景的、架构优先的自建分布式对象存储项目。

Resources

Stars

92 stars

Watchers

2 watching

Forks

Repository files navigation

Means

S3-Compatible Object Storage — Enterprise-Grade, Self-Deployable, .NET-Powered.

Means is a self-deployable S3-compatible object storage service built on ASP.NET Core. It uses the custom XlFs storage backend (inspired by MinIO's architecture — multi-disk layout, Cauchy MDS Reed-Solomon erasure coding, object manifest, quorum-based writes, automated repair/rebalance) powered by the self-developed MeansLogDb metadata engine, with built-in IAM/STS, SSE-S3/KMS, Object Lock, quotas, replication, Console RBAC, and structured observability.

This document reflects the current code state of the repository. See docs/README.md for the full documentation index.


Table of Contents


Architecture Overview

Layer Project Purpose
Host / API src/Means ASP.NET Core net11.0 application entry point, middleware pipeline, endpoints, DI composition
Protocol src/Means.Protocol.S3 S3-compatible address resolution, SigV4 signature validation, S3 XML response serialization
Storage Engine src/Means.Infrastructure.XlFs Default XlFs storage backend (multi-disk, manifest, quorum, MeansLogDb metadata)
Core Abstractions src/Means.Core Domain models, storage interfaces, policies, error definitions, placement strategies
Management src/Means/Endpoints/Console Cookie-authenticated Console JSON API
Web UI src/Means/wwwroot React-based management dashboard (built from web/)
SDK - C# SDKs/csharp Full-featured C# client SDK
SDK - TypeScript SDKs/typescript Browser-safe TS SDK + Node extension (SigV4)
Tests tests/ Unit, integration, and contract tests

Solution Structure (Means.slnx)

Means.slnx
├── src/
│   ├── Means/                  # Host application
│   ├── Means.Core/             # Core abstractions & domain
│   ├── Means.Infrastructure.XlFs/  # XlFs storage engine
│   └── Means.Protocol.S3/      # S3 protocol implementation
│
├── tests/
│   ├── Means.UnitTests/        # Unit tests
│   ├── Means.IntegrationTests/ # Integration tests
│   └── Means.ContractTests/    # SDK spec compliance tests
│
├── SDKs/
│   ├── csharp/                 # C# SDK
│   ├── typescript/             # TypeScript SDK
│   └── spec/                   # Machine-readable protocol spec
│
├── web/                        # React frontend (Vite)
└── docs/                       # Documentation site

Implemented Capabilities

S3 Data Plane

Category Operations Status
Service ListBuckets (tenant-scoped when using tenant credentials) ✅
Bucket CreateBucket (with x-amz-bucket-object-lock-enabled), HeadBucket, DeleteBucket, GetBucketLocation ✅
Object PutObject, GetObject, HeadObject, DeleteObject, DeleteObjects ✅
Listing ListObjects (marker) and ListObjectsV2 (continuation-token, start-after), plus prefix, delimiter, max-keys, encoding-type ✅
ACL ?acl on buckets and objects, owner-only canned ACLs ⚠️ Limited
Copy CopyObject (x-amz-copy-source, COPY/REPLACE metadata directive) ✅
Multipart Initiate, UploadPart, UploadPartCopy, Complete, Abort, ListParts, ListMultipartUploads ✅
Versioning ?versioning, ?versions, GET/HEAD/DELETE by versionId, delete markers ✅
Tagging ?tagging (current & specific version) ✅
Lifecycle ?lifecycle (expiration, noncurrent cleanup, AbortIncompleteMultipartUpload) ✅
CORS ?cors config CRUD, OPTIONS preflight ✅
Notification ?notification config persistence (event delivery worker reserved) ⚠️ Config only
Policy & Conditions ?policy CRUD, IAM/STS/Bucket policies with Condition operators (String*, IpAddress, Bool, Numeric*, Date*, Arn*, IfExists) ✅
Encryption (SSE) ?encryption, SSE-S3 (AES256) & SSE-KMS (aws:kms), chunked AES-256-GCM with O(1) Range GET ✅
Object Lock ?object-lock, ?retention, ?legal-hold, GOVERNANCE / COMPLIANCE, Legal Hold ON/OFF, bypass governance header ✅
Storage Class x-amz-storage-class (STANDARD, STANDARD_IA, ONEZONE_IA, GLACIER, DEEP_ARCHIVE, REDUCED_REDUNDANCY, INTELLIGENT_TIERING) ✅
Replication ?replication, cross-bucket & cross-cluster async replication, x-amz-replication-status (PENDING, COMPLETED, FAILED, REPLICA), backoff retry ✅
Pre-signed URL SigV4 pre-signed GET, PUT, multipart UploadPart (including X-Amz-Security-Token for STS credentials) ✅
Upload Integrity aws-chunked decoding, x-amz-decoded-content-length enforcement, Content-MD5 and x-amz-checksum-* (CRC32, CRC32C, CRC64NVME, SHA1, SHA256) verification ✅

Security, Governance & Storage Engine

Capability Highlights
IAM & STS POST /sts (AssumeRole, GetSessionToken, x-amz-security-token) and SigV4-authenticated /api/iam/... REST API for users, roles, managed policies, tenants, and RotateAccessKey
Multi-Tenancy Per-tenant isolation across IAM identities, access keys, STS sessions, and buckets (means:tenant condition key)
Server-Side Encryption Streaming chunked AES-256-GCM envelope encryption (SSE-S3 / SSE-KMS) with configurable MasterKeyBase64, named KmsKeys, and HKDF-SHA256 key derivation
WORM & Quotas Object Lock (GOVERNANCE/COMPLIANCE retention + Legal Hold) and hard/soft bucket & tenant byte/object quotas (QuotaExceeded)
Immutable Audit Log SHA-256 hash-chained audit trail with online verification (GET /api/console/audit/verify) and optional append-only NDJSON sink (AuditLogFilePath)
Erasure Coding & Rebalance Cauchy MDS Reed-Solomon erasure coding for PutObject and UploadPart, degraded read reconstruction, automated shard repair, and placement-driven rebalance
Structured Logging Means:Logging:Format=Json with request scopes (RequestId, TraceId, ClientIp, S3Operation, S3Bucket, S3Key)

Key Implementation Details

  • Address Resolution: Supports both path-style and virtual-hosted-style S3 addressing, plus same-origin /s3 alias.
  • Response Format: Unified S3-compatible XML (listings, errors, copy results).
  • Range Reads: Range header → 206 Partial Content; invalid ranges → 416 InvalidRange with Content-Range header (works transparently on SSE-encrypted objects).
  • Compression: Content-negotiated (br / gzip) streaming compression on responses; disabled for Range requests.
  • Atomic Writes: PutObject is atomic — objects become visible only after the metadata transaction commits.
  • Multipart Rules:
    • partNumber: 1–10000
    • Minimum part size (except last): 5 MiB
    • Final ETag: md5(concat(part-md5-bytes))-part-count
    • Means:RequestLimits:MaxUploadSizeBytes applies per-part, not total assembled size.
  • Concurrency Control: S3 PUT and multipart UploadPart share a global concurrency limit (default: 64). Exceeding returns 503 SlowDown with Retry-After: 1.
  • Checksum Verification: Disabled by default on reads to avoid double I/O for large objects. Enable via VerifyChecksumOnRead. Background scrub always checksums and enqueues repairs.

Console Management Plane

Built-in management API (/api/console, JSON) and web dashboard (React):

Feature Endpoint / Details
Authentication & RBAC Cookie-based login/logout/session check with 4 built-in roles (Admin, Operator, Auditor, ReadOnly), supporting Means:Console:Users and IAM console accounts
Bucket & Object Management Create, delete, browse objects/versions, copy, batch delete, presigned upload/download links
Governance & Security UI/API Bucket policy, versioning, lifecycle, default SSE encryption, bucket/tenant quotas, replication rules & manual task retry
Large File Upload Multipart from 5 MiB, 16 MiB parts, 3 concurrent
AccessKey & IAM Management Create, disable, delete, attach policies, rotate access keys, and manage IAM users/roles/policies/tenants
System Settings Configure max upload size
Immutable Audit & Metrics SHA-256 hash-chained audit log, chain verification (/api/console/audit/verify), hourly request statistics dashboard
Cluster Status Node/disk health, EC profiles, storage classes, diagnostics export (/api/console/cluster, /api/console/diagnostics)
Monitoring & Logging Prometheus /metrics, optional OpenTelemetry (OTLP), structured JSON request logging
Background Tasks Unified management with manual triggers — heartbeat, disk health, replica repair, EC repair, rebalance, lifecycle, scrub, metadata consistency, storage GC, replication worker
Rate Limiting Fixed-window limits for Console login, Console API, and S3 data plane

Current Boundaries

Milestones M1–M6 are implemented; the remaining boundaries are:

  • 🚧 M7 S3 Compatibility Matrix — Continuous client verification across AWS CLI, boto3, aws-sdk-js v3, rclone, mc, and s3fs-fuse (scripts/compatibility/run-s3-client-matrix.ps1)
  • 🔲 Shared Distributed Metadata Namespace — MeansLogDb is currently a node-local WAL/snapshot store (metadata.sharedNamespace=false); do not load-balance active-active S3 writes across independent nodes
  • 🔲 Bucket Notification Delivery Worker — ?notification configuration CRUD is implemented; outbound webhook/queue event delivery is reserved

Quick Start

1) Prerequisites

Dependency Version Notes
.NET SDK 10.0 Required for building and running
Node.js 20+ Only needed for frontend development

2) Start the Service

# Restore dependencies
dotnet restore Means.slnx

# Build the solution
dotnet build Means.slnx

# Run with the 'http' launch profile
dotnet run --project src/Means/Means.csproj --launch-profile http

The development server starts at http://localhost:5178.

2.1) Docker Compose

Single-node (default XlFs):

docker compose up -d --build

Access: http://localhost:5178

Default credentials (override via .env or environment variables for production):

  • Console: meansadmin / meansadmin-local
  • S3: meansadmin / meansadmin-local-secret

Multi-node (experimental):

docker compose -f compose.multinode.yaml up -d --build
Node Address
means-node1 http://localhost:5181
means-node2 http://localhost:5182
means-node3 http://localhost:5183

⚠️ Important: The multi-node setup is for topology and operations page validation only. Each node has an independent XlFs namespace. Do not place a data-plane load balancer in front of these nodes until distributed metadata/RPC is implemented.

3) Access the Console

Open http://localhost:5178 and sign in with the default development credentials:

Field Value
Username admin
Password meansadmin

4) Local S3 Access Methods

Same-origin alias (development):

http://localhost:5178/s3/{bucket}/{key}

Standard host styles (requires DNS/hosts configuration):

Style URL Pattern
Path-style http(s)://api.means.local/{bucket}/{key}
Virtual-hosted-style http(s)://{bucket}.means.local/{key}

Configuration Reference

All configuration is in src/Means/appsettings.json under the Means section. See docs/reference/configuration.md for the complete reference.

S3 Settings

Key Default Description
Means:S3:ServiceHost api.means.local Path-style hostname
Means:S3:DomainSuffix means.local Virtual-hosted-style domain suffix
Means:S3:AliasPrefix /s3 Same-origin S3 alias prefix
Means:S3:Region us-east-1 Region reported by GetBucketLocation and x-amz-bucket-region

Storage & Replication Settings

Key Default Description
Means:Storage:ObjectsPath data/objects Single-disk directory (when Disks not configured)
Means:Storage:Disks /data/xlfs/disk1... XlFs multi-disk root directories; each gets .means.sys/format.json
Means:Storage:ErasureDataShards 2 Cauchy MDS Reed-Solomon data shards; used when online disks satisfy data+parity
Means:Storage:ErasureParityShards 2 Cauchy MDS Reed-Solomon parity shards; falls back to full-copy quorum when insufficient disks
Means:Storage:WriteQuorum 3 Minimum disks required for write success
Means:Storage:ReadQuorum 1 Minimum disks required for read success
Means:Storage:MetaSyncMode Always Metadata WAL flush strategy
Means:Storage:VerifyChecksumOnRead false Synchronous SHA256 verification on read (adds full I/O)
Means:Storage:DefaultAccessKey meansadmin Default S3 access key
Means:Storage:DefaultSecretKey meansadminsecret Default S3 secret key
Means:Storage:AuditLogFilePath (empty) Optional append-only NDJSON file sink for SHA-256 hash-chained audit entries
Means:Storage:MultipartUploadCleanupAgeHours 24 Age threshold for incomplete multipart upload cleanup
Means:Storage:MultipartUploadCleanupIntervalMinutes 60 Cleanup background task interval
Means:Storage:GarbageCollectionIntervalSeconds 3600 Orphan file GC scan interval
Means:Storage:GarbageCollectionBatchSize 1000 Max candidates per GC run
Means:Storage:GarbageCollectionTempFileAgeMinutes 60 Min age for temp/unreferenced file GC eligibility
Means:Storage:ReplicationIntervalSeconds 3600 Async replication worker polling interval (seconds)
Means:Storage:ReplicationBatchSize 100 Max pending replication tasks processed per run
Means:Storage:ReplicationMaxAttempts 5 Max attempts before marking a replication task FAILED
Means:Storage:ReplicationBaseRetryDelaySeconds 5 Base delay (seconds) for exponential backoff retries

Encryption (SSE-S3 / SSE-KMS)

Key Default Description
Means:Encryption:MasterKeyBase64 (empty) Optional 32-byte (256-bit) Base64 master KEK; auto-generates and persists a fallback key when omitted
Means:Encryption:DefaultKmsKeyId alias/means/s3 Default KMS key ID for aws:kms requests omitting a key ID
Means:Encryption:KmsKeys {} Named KMS key map (keyId -> Base64 32-byte key)
Means:Encryption:ChunkSizeBytes 65536 (64 KiB) Plaintext chunk size for streaming AES-256-GCM encryption (4096..4194304)

Structured Logging

Key Default Description
Means:Logging:Format Text Console log format: Text or Json
Means:Logging:IncludeScopes true Attach request scopes (RequestId, TraceId, Method, Path, ClientIp, S3Operation, S3Bucket, S3Key)
Means:Logging:LogRequests true Emit structured HTTP request completion/failure logs (Means.Http.Requests)
Means:Logging:UseUtcTimestamp true Format log timestamps in UTC (ISO-8601)

Request Limits

Key Default Description
Means:RequestLimits:MaxUploadSizeBytes 1073741824 (1 GiB) Max per-request upload size
Means:RequestLimits:MaxConcurrentUploadRequests 64 Global concurrency for PUT/UploadPart; returns 503 SlowDown when exceeded

Rate Limiting

Key Default Description
Means:RateLimits:Enabled true Enable fixed-window rate limiting
Means:RateLimits:ConsoleLoginPermitLimit 10 Requests per console login window
Means:RateLimits:ConsoleLoginWindowSeconds 60 Console login window (seconds)
Means:RateLimits:ConsoleApiPermitLimit 600 Requests per console API window
Means:RateLimits:ConsoleApiWindowSeconds 60 Console API window (seconds)
Means:RateLimits:S3PermitLimit 1200 Requests per S3 data plane window
Means:RateLimits:S3WindowSeconds 60 S3 data plane window (seconds)

Telemetry

Key Default Description
Means:Telemetry:Enabled false Enable OpenTelemetry tracing
Means:Telemetry:ServiceName Means Tracing resource service name
Means:Telemetry:OtlpEndpoint (empty) OTLP exporter endpoint
Means:Telemetry:SampleRatio 1.0 Trace sampling ratio [0, 1]

Cluster

Key Default Description
Means:Cluster:InternalAuthToken (empty) Inter-node shard RPC token; empty = /api/internal/cluster returns 404
Means:Cluster:MaxShardTransferBytes 5368709120 (5 GiB) Per-shard streaming transfer limit

Console

Key Default Description
Means:Console:AdminUser admin Admin username (Admin role)
Means:Console:AdminPassword meansadmin Admin password; minimum 12 characters outside Development
Means:Console:Users [] Additional Console RBAC accounts (UserName, Password, Role: Admin/Operator/Auditor/ReadOnly, Enabled, TenantId)
Means:Console:SessionHours 8 Session duration (hours)
Means:Console:MaxFailedAttemptsPerIp 10 Failed logins per source IP inside the window before lockout
Means:Console:MaxFailedAttemptsPerUser 20 Failed logins per user name before lockout; stops distributed attempts that rotate IPs
Means:Console:FailureWindowMinutes 15 Sliding window used for failed-attempt counters
Means:Console:InitialLockoutSeconds 30 First lockout duration; every further failure doubles it
Means:Console:MaxLockoutSeconds 900 Upper bound for exponential lockout
Means:Console:FailedAuthenticationDelayMilliseconds 250 Artificial delay applied to failed credential checks

Network (reverse proxy)

Key Default Description
Means:Network:TrustedProxies (empty) Proxy IP addresses allowed to supply X-Forwarded-* headers
Means:Network:TrustedNetworks (empty) CIDR ranges allowed to supply X-Forwarded-* headers
Means:Network:TrustAllProxies false Trust all forwarded headers; only enable behind an edge proxy that overwrites them

X-Forwarded-For/X-Forwarded-Host/X-Forwarded-Proto are ignored unless at least one trusted proxy or network is configured. This prevents clients from spoofing their source address to bypass login rate limits and lockouts. Set Means:Network:TrustAllProxies=true only when a trusted edge proxy always overwrites the headers.

Important Notes

  • Production security: The service refuses to start if default console credentials are detected, if the password is shorter than 12 characters, or if the password equals the user name. Always replace AdminUser/AdminPassword and DefaultAccessKey/DefaultSecretKey for production.
  • Login brute-force protection: The console login combines per-IP and per-user sliding-window lockouts with exponential backoff, constant-time credential comparison, and a security stamp that invalidates sessions when the password changes. Lockout counters are process-local, so multi-node deployments should also throttle at the edge.
  • Multipart cleanup: Background tasks automatically clean up incomplete upload metadata and part files. Frontend cancellation best-effort calls abort, but disk reclamation does not depend on browser request success.
  • Read verification: SHA256 verification is off by default on reads. Enable VerifyChecksumOnRead for strong verification. Background scrub always checksums.
  • Rate limiting responses: Console → JSON SlowDown; S3 → XML SlowDown; both include Retry-After header.
  • Prometheus: Scrape /metrics. Recommended alerting rules in docs/operations/deployment-observability.md.
  • OpenTelemetry: Disabled by default. Set Means:Telemetry:Enabled=true to collect ASP.NET Core and background task spans. Configure OtlpEndpoint for collector export.

Development & Testing

Running Tests

dotnet test Means.slnx
Test Project Focus
Means.UnitTests Address resolution, naming rules, policy evaluation, compression logic
Means.IntegrationTests S3 full-chain workflows, pre-signed URLs, Console API end-to-end
Means.ContractTests SDK protocol YAML spec vs. fixture completeness

Frontend Development

cd web
npm install
npm run dev
  • Vite dev server proxies /api and /s3 to http://localhost:5178.
  • Build for production: npm run build → outputs to src/Means/wwwroot.

SDKs & Specification

Package Location Description
C# SDK SDKs/csharp Full-featured .NET client SDK (Means.Client.csproj)
TypeScript SDK SDKs/typescript/packages/sdk Browser-safe S3 client
TypeScript Node Extension SDKs/typescript/packages/sdk-node SigV4 signing & pre-signing for Node.js
Protocol Spec (YAML) SDKs/spec/means-sdk-v1.yaml Machine-readable API specification
Protocol Spec (Markdown) SDKs/spec/means-sdk-v1.md Human-readable protocol documentation
SDK Examples SDKs/examples/ Usage examples in C# and TypeScript

Project Map

Means/
├── CHANGELOG.md
├── IMPLEMENTATION_PLAN.md
├── Means.slnx                      # .NET solution file
├── compose.yaml                    # Single-node Docker Compose
├── compose.multinode.yaml          # Multi-node experimental Compose
├── README.md                       # This file (English)
├── README.zh.md                    # Chinese documentation
│
├── src/
│   ├── Means/                      # ASP.NET Core host
│   │   ├── Program.cs              # Application entry point
│   │   ├── Composition/            # DI composition & service registration
│   │   ├── Configuration/          # Configuration binding & validation
│   │   ├── Endpoints/              # HTTP API endpoints (Console, etc.)
│   │   ├── Middleware/             # ASP.NET Core middleware pipeline
│   │   ├── Services/               # Application services
│   │   ├── Security/               # Authentication & authorization
│   │   ├── Serialization/          # JSON serialization configuration
│   │   ├── Properties/             # Launch profiles, assembly info
│   │   └── wwwroot/                # Built frontend artifacts
│   │
│   ├── Means.Core/                 # Core domain & abstractions
│   │   ├── Abstractions/           # Storage interfaces & contracts
│   │   ├── Constants/              # Well-known constants
│   │   ├── Errors/                 # Domain error types
│   │   ├── Models/                 # Domain models
│   │   ├── Placement/              # Disk placement strategies
│   │   ├── Policies/               # Storage policies
│   │   └── Requests/               # Request model definitions
│   │
│   ├── Means.Infrastructure.XlFs/  # XlFs storage engine
│   │   ├── Store/                  # Core store implementation
│   │   ├── LogDb/                  # MeansLogDb metadata engine
│   │   ├── Models/                 # XlFs-specific models
│   │   └── XlFsOptions.cs          # Storage options
│   │
│   └── Means.Protocol.S3/         # S3 protocol layer
│       ├── Addressing/             # Path-style & vhost-style resolution
│       ├── Compression/            # Content negotiation & compression
│       ├── Serialization/          # S3 XML response serialization
│       ├── Signing/                # SigV4 signature validation
│       └── Validation/             # Request validation
│
├── tests/
│   ├── Means.UnitTests/
│   ├── Means.IntegrationTests/
│   └── Means.ContractTests/
│
├── SDKs/
│   ├── csharp/
│   ├── typescript/
│   ├── spec/
│   └── examples/
│
├── web/                            # React frontend (Vite + TypeScript)
│   ├── src/                        # React components & pages
│   ├── public/                     # Static assets
│   ├── vite.config.ts              # Vite configuration
│   └── package.json
│
├── docs/                           # Documentation (Markdown)
│   ├── README.md                   # Documentation index
│   ├── architecture/               # System architecture & storage consistency
│   ├── reference/                  # Configuration & S3 API compatibility
│   ├── operations/                 # Deployment, observability, RBAC & alerts
│   ├── sdk/                        # C#, TypeScript & Node SDK examples
│   └── development/                # Testing & milestone roadmap
│
└── scripts/                        # Utility scripts
    ├── benchmarks/                 # S3 benchmark scripts
    └── compatibility/              # S3 client compatibility matrix

License

MIT — see LICENSE for details.

About

Means 是一个面向应用文件与静态资源场景的、架构优先的自建分布式对象存储项目。

Resources

Stars

92 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages