A proof of concept demonstrating how to create a small graph of objects (files, folders, users, organizations, and policies) that when put together look something like a rudimentary file system.
Neo4j feels like a natural choice for database, since our goal is to represent a file system tree and users' relationships to certain nodes in that tree.
In this model, organizations (red nodes) represent file system root. The blue nodes are the users. The yellow nodes are the folders. The green nodes are the files.
This guide expects your Neo4j password to be in the .env
file.
If you've never configured Neo4j, the default password should be neo4j
.
Set that in your .env
file:
$ cat .env
NEO_PASSWORD=neo4j
Command | Description |
---|---|
make |
Runs containers |
make rebuild |
Rebuilds images from scratch and runs containers |
make stop |
Stops running containers |
Once started, the Neo4j container will be accessible via http://localhost:7474.
Log in with the username neo4j
and whatever password you've configured (neo4j
is the default out-of-the-box password).
curl http://localhost:8080/user -H 'Origin: http://localhost:3000' -d '{"resourceID": 22, "emailAddress": "kevin.chen22@irisvr.com", "fullName": "Kevin Chen22"}'
curl http://localhost:8080/file/9c73cde3-d8f9-4048-bfd9-00e0484fdb89 -H 'Origin: http://localhost:3000'
curl -X POST http://localhost:8080/move -H 'Origin: http://localhost:3000' -d '{"sourceID": "7a1ced19-5396-4c44-bc30-4953d59453d5", "destinationID": "0871b5af-4954-4d21-9e1f-3781e269374a", "newName": "cloud-auth-moved"}'
We can test out our gRPC API on the command line with grpcurl.
It behaves like curl
, but it can process binary payloads.
To install it, run
go get github.com/fullstorydev/grpcurl
go install github.com/fullstorydev/grpcurl/cmd/grpcurl
There are some calls you can make to see what kinds of methods your API supports:
grpcurl -import-path ./src/pb -proto file.proto list
grpcurl -v -plaintext localhost:50051 list pb.FileService
grpcurl -v -plaintext -d '{"userID": "4", "fileID": "7a1ced19-5396-4c44-bc30-4953d59453d5"}' localhost:50052 pb.FileService/GetFile
grpcurl -v -plaintext -d '{"organization": {"id": 1}}' localhost:50051 pb.OrganizationService/GetOrganization
grpcurl -v -plaintext -d '{"organization": {"id": 2, "name": "My Custom Org"}}' localhost:50051 pb.OrganizationService/CreateOrganization