{"id":27314624,"url":"https://github.com/sambego/fga-demo-api","last_synced_at":"2025-09-06T17:35:15.387Z","repository":{"id":83786879,"uuid":"541603262","full_name":"Sambego/fga-demo-api","owner":"Sambego","description":"A simple Google Drive style API, using OpenFGA, written in Go","archived":false,"fork":false,"pushed_at":"2024-04-02T17:24:11.000Z","size":4383,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-08T20:38:04.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sambego.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-26T13:32:41.000Z","updated_at":"2024-04-02T17:25:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"41b6d77f-b1c3-4c48-b787-0ba7cd3d0a17","html_url":"https://github.com/Sambego/fga-demo-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Sambego/fga-demo-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sambego%2Ffga-demo-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sambego%2Ffga-demo-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sambego%2Ffga-demo-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sambego%2Ffga-demo-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sambego","download_url":"https://codeload.github.com/Sambego/fga-demo-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sambego%2Ffga-demo-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273936262,"owners_count":25194140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-12T07:59:27.929Z","updated_at":"2025-09-06T17:35:15.344Z","avatar_url":"https://github.com/Sambego.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Google Drive style API, using OpenFGA, written in Go\n\n## Start your FGA Server\nMore info on [openfga.dev](https://openfga.dev)\n\nThe FGA Server needs to be running before this Go server, cause on start it will create a new model and populate it with the model in [`fga-model.json`](./fga-model.json).\n\n```\ndocker run -p 8080:8080 -p 8081:8081 -p 3000:3000 openfga/openfga run\n```\n## Add your environment variables\n```\ncp .env.sample .env\n```\n\n## Start your Go server\n```\ngo run main.go\n```\n\n## API Endpoints\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| `GET`     | `/documents/:id`       | Get a document |\n| `POST`    | `/documents`           | Create a new document, the JSON body accepts `name` and `content` |\n| `POST`    | `/documents/:id/share` | Share a document, the JSON body accepts `relation` and `user`. You can also use this endpoint to add a file to a parent folder by setting the `relation` to `parent` and the `user` to `folder:\u003cid\u003e` |\n| `GET`     | `/folders/:id`         | Get a folder |\n| `POST`    | `/folders`             | Create a new folder, the JSON body accepts `name` |\n| `POST`    | `/folderws/:id/share`  | Share a folder, the JSON body accepts `relation` and `user`. You can also use this endpoint to add a folder to a parent folder by setting the `relation` to `parent` and the `user` to `folder:\u003cid\u003e` |\n| `GET`    | `/documents` | Get all documents. This endpoint is included for debugging, no FGA check is done here |\n| `GET`    | `/folders`   | Get all folder. This endpoint is included for debugging, no FGA check is done here |\n\n## Test tokens (These don't work anywhere else).\nThe API uses the subject (`sub`) from the JWT formatted Access Token persented as Bearer token in the `Authorization` header. This is a demo, and therefor not all necessary checks are in place. Please don't use this in production!\n\n### Sam\n```\neyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzYW1Ab2t0YS5jb20iLCJuYW1lIjoiU2FtIEJlbGxlbiIsImlhdCI6MTUxNjIzOTAyMn0.UgLEipGU-69_dKuhgCsV7mrBcCvRJBV880kuMJbLBy8\n```\n\n### Chiara\n```\neyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjaGlhcmFAb2t0YS5jb20iLCJuYW1lIjoiQ2hpYXJhIiwiaWF0IjoxNTE2MjM5MDIyfQ.-mbo6VBG1xZzK-T7bEuKqUQR1B-eu-ACRIKrtai1JEU\n```\n\n## Test scenario\n### `1` Create a new document for user Sam\n`POST /documents/`\n```\n{\n  \"name\": \"Test document\",\n  \"content\": \"Test content\"\n}\n```\n### `2` User Sam should be able to see the document \n`GET /documents/:id`\n### `3` User Chiara should NOT be able to see the document \n`GET /documents/:id`\n### `4` Create a new folder for user Sam\n`POST /folders`\n```\n{\n  \"name\": \"Test Folder\",\n}\n```\n### `5` User Sam should be able to see the folder \n`GET /folders/:id`\n### `6` User Chiara should NOT be able to see the document\n`GET /folders/:id`\n### `7` Add the document to the folder for user Sam\n`POST /documents/:id/share`\n```\n{\n  \"relation\": \"parent\",\n  \"user\": \"folder:id\n}\n```\n### `8` Share the folder with user Chiara\n`POST /folders/:id/share`\n```\n{\n  \"relation\": \"viewer\",\n  \"user\": \"user:chiara@okta.com\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambego%2Ffga-demo-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsambego%2Ffga-demo-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambego%2Ffga-demo-api/lists"}