Below is a formal Functional Analysis suitable as a starting point for a software architecture / technical specification document. I’ll use Secure File Access Service (SFAS) as the working name.
The purpose of the Secure File Access Service (SFAS) is to centralize and secure access to filesystem resources used by applications, portals, batch procedures, and other consumers.
The service acts as the single controlled access point between consuming applications and the protected filesystem.
The solution provides:
- centralized file and directory operations;
- authentication and authorization of consumers;
- logical-to-physical resource resolution;
- protection against unauthorized filesystem access;
- transparent file encryption at rest;
- transparent decryption when authorized content is retrieved;
- auditability and traceability of file operations.
The underlying filesystem is considered an internal protected resource and must not be directly accessible by consuming applications.
The SFAS provides:
- File creation
- File reading
- File modification
- File deletion
- File copying
- File moving/renaming
- Directory creation
- Directory deletion
- Directory listing
- File metadata retrieval
- Authentication
- Authorization
- Logical path validation
- File encryption
- File decryption
- Cryptographic key management integration
- Audit logging
- Error handling
- Request correlation and traceability
- API versioning
The following are not responsibilities of the SFAS:
- business processing of file contents;
- interpretation of business-specific document formats;
- modification of document contents;
- business workflow management;
- user interface implementation;
- business-specific approval processes;
- general-purpose storage management.
The service manages access to files, not the business meaning of the files.
The solution is based on the following principles.
All filesystem operations must pass through the SFAS.
Application
|
| HTTPS
v
+----------------------+
| Secure File Access |
| Service |
+----------+-----------+
|
v
Protected File System
Consumer applications must not have operating-system permissions allowing direct access to the protected filesystem.
Each consumer must receive only the permissions required to perform its authorized operations.
Consumers should interact with logical resources rather than physical filesystem paths.
Files persisted on the protected filesystem may be stored encrypted.
Encryption and decryption should be transparent to authorized consumers.
Security-relevant file operations must be traceable to an authenticated consumer.
Represents any application requiring filesystem operations.
Examples:
- Web portal
- Backend application
- Batch process
- Integration service
- Document management application
Responsibilities:
- authenticate with SFAS;
- invoke authorized APIs;
- provide valid logical resources;
- process returned files.
Responsible for configuring the SFAS.
Typical activities:
- configure logical storage areas;
- configure authorization policies;
- configure consumers;
- configure encryption policies;
- configure retention/audit policies;
- monitor service status.
External authentication component.
Examples include:
- OAuth/OIDC provider;
- enterprise identity system;
- certificate infrastructure.
It establishes the identity of the requesting consumer.
External or internal cryptographic key-management component.
Responsibilities:
- key generation;
- key storage;
- key retrieval;
- key rotation;
- key lifecycle management.
The SFAS should preferably not store encryption keys as ordinary application configuration or alongside encrypted files.
The physical storage layer.
Examples:
- local filesystem;
- SAN;
- NAS;
- mounted storage.
It is an infrastructure component rather than an application actor.
Optional external system receiving audit and security events.
Examples:
- SIEM;
- centralized logging platform;
- security monitoring system.
The principal use cases are:
+----------------------+
| Secure File Access |
| Service |
| |
Consumer Application --->| Authenticate |
Consumer Application --->| Authorize |
Consumer Application --->| Create File |
Consumer Application --->| Read File |
Consumer Application --->| Update File |
Consumer Application --->| Delete File |
Consumer Application --->| Copy File |
Consumer Application --->| Move File |
Consumer Application --->| List Directory |
Consumer Application --->| Manage Directory |
Consumer Application --->| Get Metadata |
| |
| Encrypt File |
| Decrypt File |
| Audit Operation |
+----------------------+
|
+-------------+-------------+
| |
v v
Identity Provider Key Management
Establish the identity of the caller before allowing access to protected resources.
Consumer Application
Identity Provider
- Consumer is registered.
- Consumer possesses valid credentials/certificate/token.
- Consumer sends an HTTPS request.
- SFAS receives authentication credentials.
- SFAS validates the credentials.
- Identity Provider confirms the consumer identity.
- SFAS establishes the security context.
- Request processing continues.
A1 — Invalid credentials
- Authentication fails.
- SFAS rejects the request.
- No filesystem operation is performed.
- Security event is logged.
A2 — Expired credentials
- SFAS detects expired credentials.
- Request is rejected.
- Authentication failure is logged.
Determine whether an authenticated consumer can perform a specific operation on a specific logical resource.
- Consumer is authenticated.
- Requested resource exists or is valid for creation.
- SFAS extracts consumer identity.
- SFAS identifies requested operation.
- SFAS resolves the logical resource.
- Authorization policy is evaluated.
- Access is granted.
- Requested operation proceeds.
A1 — Access denied
- Authorization policy denies the operation.
- No filesystem operation is performed.
- SFAS returns an authorization error.
- Security event is logged.
Example:
Consumer: PORTAL-A
Resource: DOCUMENTS/customer123/*
Operation: READ
=> ALLOWED
while:
Consumer: PORTAL-A
Resource: SYSTEM/*
Operation: DELETE
=> DENIED
Create a new file in a logical storage area.
- Consumer sends a file creation request.
- SFAS authenticates the request.
- SFAS validates authorization.
- SFAS validates the logical resource identifier.
- SFAS resolves the logical resource to a physical location.
- SFAS receives file content.
- Encryption policy is evaluated.
- File is encrypted if required.
- Encrypted content is written to the filesystem.
- Operation is audited.
- Success response is returned.
Client
|
| plaintext
v
API
|
v
Authorization
|
v
Path Resolution
|
v
Encryption
|
v
Protected FS
A1 — Unauthorized
Operation terminates before filesystem access.
A2 — Invalid logical path
Request is rejected.
A3 — File already exists
Depending on policy:
- reject;
- overwrite;
- version;
- return conflict.
A4 — Encryption failure
File must not be persisted as plaintext.
Retrieve a file from the protected filesystem.
- Consumer requests a logical file.
- SFAS authenticates the consumer.
- Authorization is evaluated.
- Logical resource is validated.
- Physical location is resolved.
- File is retrieved from storage.
- SFAS determines whether decryption is required.
- File is decrypted.
- Plaintext content is returned through HTTPS.
- Operation is audited.
Protected FS
|
encrypted
v
File Access Service
|
decrypt
v
HTTPS
|
v
Consumer
A1 — File not found
Return Not Found.
A2 — Unauthorized
Return Forbidden.
A3 — Decryption failure
Do not return corrupted/invalid content.
A4 — Integrity verification failure
The operation is aborted and a security event is generated.
Replace or modify an existing file.
- Authenticate caller.
- Authorize WRITE operation.
- Validate resource.
- Resolve physical location.
- Encrypt new content.
- Persist encrypted content.
- Optionally perform atomic replacement.
- Audit operation.
The implementation should preferably avoid a state in which a partially written encrypted file is exposed.
For example:
temporary encrypted file
|
| successful write
v
atomic rename
|
v
final file
- Authenticate caller.
- Verify DELETE permission.
- Validate logical resource.
- Resolve physical resource.
- Delete file.
- Record audit event.
- Return result.
If the resource does not exist, behavior should be explicitly defined:
- idempotent success; or
404 Not Found.
The operation must remain internal to the SFAS.
The client should not need to know the physical filesystem path.
Logical Resource A
|
| MOVE
v
Logical Resource B
The SFAS performs the corresponding physical operation after authorization.
Retrieve the contents of an authorized logical directory.
- Authenticate.
- Authorize LIST operation.
- Validate logical directory.
- Resolve physical directory.
- Read directory metadata.
- Return logical resource information.
- Audit request.
The response should preferably expose logical identifiers, not physical filesystem paths.
Encryption is an internal service capability rather than normally an externally invoked use case.
- File content enters the service.
- Encryption policy is retrieved.
- Required key is obtained through the Key Management component.
- Content is encrypted.
- Integrity/authentication information is generated.
- Encrypted representation is persisted.
The preferred cryptographic design should use an authenticated encryption mechanism, rather than encryption alone, so that unauthorized modification can be detected.
- Encrypted file is retrieved.
- Encryption metadata is identified.
- Appropriate key is obtained.
- Integrity/authentication is verified.
- Content is decrypted.
- Plaintext is returned to the authorized caller.
If integrity verification fails, the content must not be returned.
Each relevant operation generates an audit event.
Example:
Timestamp
Correlation ID
Consumer ID
Operation
Logical Resource
Result
Authentication Context
Client Address
File Size
Error Code
For security reasons, the audit record should not contain the plaintext file contents.
The system shall expose filesystem operations through a secured HTTPS API.
The system shall authenticate every protected request.
The system shall authorize each filesystem operation according to the authenticated consumer and requested resource.
The system shall support creation of files.
The system shall support retrieval of files.
The system shall support modification/replacement of files.
The system shall support deletion of files.
The system shall support moving/renaming files.
The system shall support copying files where authorized.
The system shall support authorized directory creation, deletion and listing.
The system shall provide metadata associated with files and directories.
The system shall translate logical resource identifiers into physical storage locations.
The system shall prevent callers from accessing resources outside their authorized logical storage area.
The system shall support encryption of files before persistence.
The system shall decrypt encrypted files before returning them to an authorized caller.
The system shall obtain and manage cryptographic keys through a defined key-management mechanism.
The system shall detect unauthorized modification of encrypted files.
The system shall record security-relevant file operations.
The system shall assign a correlation identifier to requests to enable end-to-end traceability.
The API shall return standardized errors without exposing internal filesystem information.
For example, avoid returning:
C:\Server\ProtectedData\Customer\123\file.dat
Instead:
{
"code": "FILE_NOT_FOUND",
"message": "The requested resource was not found.",
"correlationId": "..."
}All communication between consumers and SFAS shall use HTTPS.
TLS shall be used for data transmitted between clients and the service.
For high-security environments, mutual TLS (mTLS) may be used for service-to-service authentication.
The SFAS operating-system identity shall have only the filesystem permissions required by its configured storage areas.
Consumer applications shall not have direct operating-system permissions to protected storage.
Files configured for encryption shall never be persisted as plaintext.
The system shall be able to detect unauthorized modification of encrypted files.
The service shall support the availability level defined by the applications depending on it.
File transfers shall support streaming where appropriate to avoid loading entire large files into application memory.
This is particularly important for large documents.
Bad:
File -> Memory -> Encrypt -> Disk
Preferred:
File Stream -> Encryption Stream -> Disk
and:
Disk -> Decryption Stream -> HTTPS Response
The service should be horizontally scalable where filesystem architecture permits it.
The system shall expose health, operational and security metrics.
Security events shall be retained according to the organization's audit/retention policies.
API contracts, encryption mechanisms and authorization policies shall be independently configurable where practical.
Errors shall not expose:
- physical paths;
- internal server structure;
- cryptographic information;
- operating-system details;
- sensitive file metadata.
I would divide the service into the following logical components:
┌───────────────────────────────────────────────────────────────┐
│ CONSUMER DOMAIN │
│ │
│ Portal Backend Batch Integration Service │
└───────────────────────────┬───────────────────────────────────┘
│
│ HTTPS
▼
┌───────────────────────────────────────────────────────────────┐
│ SECURE FILE ACCESS SERVICE │
│ │
│ ┌──────────────────────┐ │
│ │ API Gateway / │ │
│ │ REST API │ │
│ └──────────┬───────────┘ │
│ ▼ │
│ ┌──────────────────────┐ │
│ │ Authentication & │ │
│ │ Authorization │ │
│ └──────────┬───────────┘ │
│ ▼ │
│ ┌──────────────────────┐ │
│ │ File Operation │ │
│ │ Manager │ │
│ └───────┬───────┬──────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌────────────┐ ┌────────────────────┐ │
│ │ Resource │ │ Encryption / │ │
│ │ Resolver │ │ Decryption Engine │ │
│ └──────┬─────┘ └──────────┬─────────┘ │
│ │ │ │
│ │ ▼ │
│ │ ┌─────────────────┐ │
│ │ │ Key Management │ │
│ │ │ Adapter │ │
│ │ └────────┬────────┘ │
│ │ │ │
│ ▼ │ │
│ ┌──────────────────────┐ │ │
│ │ File System Adapter │ │ │
│ └──────────┬───────────┘ │ │
│ │ │ │
│ ┌──────────▼───────────┐ │ │
│ │ Audit / Logging │◄──┘ │
│ └──────────────────────┘ │
└──────────────┬────────────────────────────────────────────────┘
│
▼
┌─────────────────┐
│ Protected │
│ File System │
└─────────────────┘
External:
┌─────────────────┐
│ Identity │
│ Provider │
└─────────────────┘
┌─────────────────┐
│ KMS / HSM │
└─────────────────┘
┌─────────────────┐
│ SIEM / Logging │
└─────────────────┘
| Component | Responsibility |
|---|---|
| API Layer | HTTPS/API contract |
| Authentication | Establish caller identity |
| Authorization | Evaluate permissions |
| File Operation Manager | Orchestrate file operations |
| Resource Resolver | Logical → physical resource mapping |
| Encryption Engine | Encrypt/decrypt content |
| KMS Adapter | Interface with key management |
| Filesystem Adapter | Isolate OS/filesystem operations |
| Audit Manager | Generate audit events |
| Error Handler | Standardize errors and prevent information leakage |
The Filesystem Adapter is especially valuable architecturally.
It means that the rest of the application doesn't directly call:
java.io.File
System.IO
os.Open()
or equivalent APIs.
Instead:
File Operation Manager
|
v
File System Adapter
|
v
Physical FS
This creates a clean Storage Abstraction Layer.
A particularly important part of the architecture is:
Logical Storage
│
▼
Resource Resolver
│
▼
Physical Storage
Example:
Logical:
DOCUMENTS/customer123/invoice.pdf
Physical:
/protected/storage/tenant01/documents/customer123/invoice.pdf
The consumer should know only the first representation.
This provides:
- filesystem abstraction;
- path security;
- easier migration;
- tenant isolation;
- centralized authorization;
- reduced information leakage.
The SFAS should be explicitly documented as a Security Boundary.
UNTRUSTED / CONSUMER DOMAIN
Portal Batch Backend Integration
\ | | /
\ | | /
└─────────┴────────────┴────────────┘
|
HTTPS
|
▼
╔══════════════════════╗
║ SECURITY BOUNDARY ║
║ ║
║ Secure File Access ║
║ Service ║
║ ║
║ Auth ║
║ Authorization ║
║ Validation ║
║ Encryption ║
║ Audit ║
╚══════════╤═══════════╝
|
| OS-level access
▼
PROTECTED DOMAIN
┌─────────────────────┐
│ Encrypted Storage │
└─────────────────────┘
This is probably the strongest architectural characteristic of your proposal.
The authorization decision can conceptually be expressed as:
ALLOW =
Authenticated
AND
Authorized(Principal, Operation, Resource)
AND
ResourceValid
For example:
Principal = PORTAL_A
Operation = READ
Resource = DOCUMENTS/123/file.pdf
↓
Authentication ✓
Authorization ✓
Path validation ✓
Resource exists ✓
Integrity ✓
Decryption ✓
↓
ALLOW
Whereas:
Principal = PORTAL_A
Operation = DELETE
Resource = SYSTEM/config.xml
↓
Authentication ✓
Authorization ✗
↓
DENY
A recommended logical model is:
┌───────────────┐
│ KMS │
└───────┬───────┘
│
Encryption Key
│
▼
Client ──HTTPS──> Encryption Engine ──> Protected FS
│
│
Authenticated
Encryption
For modern implementations, use an authenticated encryption design, such as an AEAD construction, rather than merely encrypting bytes.
The encrypted representation should also carry sufficient metadata to determine:
- encryption version;
- algorithm/version;
- key identifier/version;
- nonce/IV;
- authentication tag;
- format version.
This allows future cryptographic migration and key rotation.
Key rotation should be explicitly considered as a functional/security requirement.
For example:
Key v1
|
| old files
v
Encrypted Files
Key v2
|
| new files
v
Encrypted Files
You can later define whether existing files are:
- re-encrypted immediately;
- re-encrypted asynchronously;
- re-encrypted on access;
- left under the old key until their lifecycle ends.
The important thing is that the file format must support identifying the appropriate key/version.
1. Consumer
|
| HTTPS + credentials
v
2. API Layer
|
v
3. Authentication
|
v
4. Authorization
|
v
5. Resource Validation
|
v
6. Logical → Physical Resolution
|
v
7. Encryption Engine
|
+----> KMS
|
v
8. Filesystem Adapter
|
v
9. Protected File System
|
v
10. Audit
|
v
11. Response
1. Consumer
|
| HTTPS
v
2. API Layer
|
v
3. Authentication
|
v
4. Authorization
|
v
5. Resource Validation
|
v
6. Logical → Physical Resolution
|
v
7. Filesystem Adapter
|
v
8. Encrypted File
|
v
9. Decryption Engine
|
+----> KMS
|
v
10. Integrity Verification
|
v
11. HTTPS Response
|
v
12. Audit
A fundamental design rule should be:
Security checks must occur before filesystem access.
For example:
Request
|
Authentication
|
+---- FAIL ──> DENY
|
Authorization
|
+---- FAIL ──> DENY
|
Path Validation
|
+---- FAIL ──> DENY
|
Filesystem Operation
Not:
Request
|
Filesystem
|
Authorization
because the latter potentially exposes information through filesystem behavior.
A standardized error model should be defined.
Example:
{
"code": "ACCESS_DENIED",
"message": "Access to the requested resource is not authorized.",
"correlationId": "a8c92f..."
}Possible codes:
| Code | Meaning |
|---|---|
AUTHENTICATION_REQUIRED |
Caller not authenticated |
AUTHENTICATION_FAILED |
Invalid authentication |
ACCESS_DENIED |
Insufficient permissions |
INVALID_RESOURCE |
Invalid logical resource |
FILE_NOT_FOUND |
Resource does not exist |
FILE_ALREADY_EXISTS |
Resource already exists |
INVALID_OPERATION |
Operation not permitted |
ENCRYPTION_ERROR |
Encryption failed |
DECRYPTION_ERROR |
Decryption failed |
INTEGRITY_ERROR |
File integrity verification failed |
STORAGE_ERROR |
Storage operation failed |
INTERNAL_ERROR |
Unexpected internal error |
One decision should be made explicitly in the architecture document:
Recommended model: yes.
SFAS Service Account
|
| READ / WRITE
v
Protected FS
while:
Portal Service Account ──X──> Protected FS
Batch Service Account ──X──> Protected FS
Backend Service Account ─X──> Protected FS
This is what actually enforces the architectural principle.
The security model should therefore exist at two levels:
Authentication
Authorization
Path validation
Audit
Filesystem ACL
Service account
Network isolation
Host permissions
The two layers should not be considered interchangeable.
For the formal document, I would standardize on these terms:
| Concept | Technical Name |
|---|---|
| Main service | Secure File Access Service (SFAS) |
| API | Secure File Management API |
| Filesystem access | Controlled File System Access |
| Logical path | Logical Resource Identifier |
| Physical path | Physical Storage Location |
| Mapping | Logical-to-Physical Resource Resolution |
| Security layer | Access Control Layer |
| Encryption | Transparent File Encryption |
| Encryption at rest | Data-at-Rest Encryption |
| Key handling | Cryptographic Key Management |
| Storage abstraction | File System Adapter |
| Logging | File Access Audit |
| Security perimeter | Security Boundary |
| Direct access prevention | No Direct File System Access |
| Permissions | Resource-Based Authorization |
| Path protection | Path Traversal Protection |
A concise statement for the beginning of an architecture document could be:
The Secure File Access Service (SFAS) provides a centralized security boundary for filesystem operations. All applications and technical processes requiring access to protected file resources shall interact exclusively with the SFAS through a secured HTTPS API. The service authenticates and authorizes each request, validates logical resource identifiers, resolves logical resources to physical storage locations, executes the requested filesystem operation through an isolated storage adapter, and provides transparent encryption and decryption of file content. The underlying filesystem is not directly accessible by consumer applications and is protected through operating-system and infrastructure-level access controls. All relevant operations are auditable and traceable through a correlation and security logging mechanism.