{"id":19510010,"url":"https://github.com/permify/permify-go","last_synced_at":"2025-04-26T03:32:08.054Z","repository":{"id":65478344,"uuid":"587384465","full_name":"Permify/permify-go","owner":"Permify","description":"Permify Go Client","archived":false,"fork":false,"pushed_at":"2025-04-09T08:39:05.000Z","size":655,"stargazers_count":24,"open_issues_count":2,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T09:36:18.056Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Permify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-10T16:18:08.000Z","updated_at":"2025-04-09T08:39:06.000Z","dependencies_parsed_at":"2023-02-14T05:32:05.595Z","dependency_job_id":"3261b16d-2aa1-4ec5-adc5-9a48b516dcb5","html_url":"https://github.com/Permify/permify-go","commit_stats":{"total_commits":53,"total_committers":5,"mean_commits":10.6,"dds":"0.49056603773584906","last_synced_commit":"fd864a31f6e686c440a5ef8ed80710d4724dda62"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Permify%2Fpermify-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Permify%2Fpermify-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Permify%2Fpermify-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Permify%2Fpermify-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Permify","download_url":"https://codeload.github.com/Permify/permify-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250926859,"owners_count":21509050,"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","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":"2024-11-10T23:14:10.694Z","updated_at":"2025-04-26T03:32:08.048Z","avatar_url":"https://github.com/Permify.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/Permify/permify/raw/master/assets/logo-permify-dark.png\"\u003e\n    \u003cimg alt=\"Permify logo\" src=\"https://github.com/Permify/permify/raw/master/assets/logo-permify-light.png\" width=\"40%\"\u003e\n  \u003c/picture\u003e\n\u003ch1 align=\"center\"\u003e\n   Permify Golang Client\n\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/Permify/permify\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/package-json/v/permify/permify-node?style=for-the-badge\" alt=\"GitHub package.json version\" /\u003e\u003c/a\u003e\u0026nbsp;\n    \u003ca href=\"https://github.com/Permify/permify\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/license/Permify/permify?style=for-the-badge\" alt=\"Permify Licence\" /\u003e\u003c/a\u003e\u0026nbsp;\n    \u003ca href=\"https://discord.gg/MJbUjwskdH\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/discord/950799928047833088?style=for-the-badge\u0026logo=discord\u0026label=DISCORD\" alt=\"Permify Discord Channel\" /\u003e\u003c/a\u003e\u0026nbsp;\n\u003c/p\u003e\n\n# Installation\n\n```shell\ngo get buf.build/gen/go/permifyco/permify/protocolbuffers/go/base/v1\ngo get github.com/Permify/permify-go\n```\n\n# How to use\n\n### Import Permify.\n\n```go\nimport (\n\tpermify_payload \"buf.build/gen/go/permifyco/permify/protocolbuffers/go/base/v1\"\n\tpermify_grpc \"github.com/Permify/permify-go/grpc\"\n)\n```\n\n### Initialize the new Permify client.\n\n```go\n// generate new client\nclient, err := permify_grpc.NewClient(\n\tpermify_grpc.Config{\n\t\tEndpoint: `localhost:3478`,\n\t},\n\tgrpc.WithTransportCredentials(insecure.NewCredentials()),\n)\n```\n\n### Create a new tenant\n\n```go\nct, err := client.Tenancy.Create(context.Background(), \u0026permify_payload.TenantCreateRequest{\n\tId:   \"t1\",\n\tName: \"tenant 1\",\n})\n```\n\n### Write Schema\n\n```go\nsr, err: = client.Schema.Write(context.Background(), \u0026permify_payload.SchemaWriteRequest {\n    TenantId: \"t1\",\n    Schema: `\n        entity user {}\n            \n        entity document {\n    \n        relation viewer @user\n        action view = viewer\n    }`,\n})\n```\n\n### Write Relationships\n\n```go\n\nrr, err := client.Data.WriteRelationships(context.Background(), \u0026 permify_payload.RelationshipWriteRequest {\n    TenantId: \"t1\",\n    Metadata: \u0026 permify_payload.RelationshipWriteRequestMetadata {\n        SchemaVersion: sr.SchemaVersion, // sr --\u003e schema write response\n    },\n    Tuples: [] * permify_payload.Tuple {\n        {\n            Entity: \u0026 permify_payload.Entity {\n                Type: \"document\",\n                Id: \"1\",\n            },\n            Relation: \"viewer\",\n            Subject: \u0026 permify_payload.Subject {\n                Type: \"user\",\n                Id: \"1\",\n            },\n        }, {\n            Entity: \u0026 permify_payload.Entity {\n                Type: \"document\",\n                Id: \"3\",\n            },\n            Relation: \"viewer\",\n            Subject: \u0026 permify_payload.Subject {\n                Type: \"user\",\n                Id: \"1\",\n            },\n        }\n    },\n})\n```\n\n### Check\n\n```go\ncr, err := client.Permission.Check(context.Background(), \u0026 permify_payload.PermissionCheckRequest {\n    TenantId: \"t1\",\n\tMetadata: \u0026 permify_payload.PermissionCheckRequestMetadata {\n        SnapToken: rr.SnapToken, // rr --\u003e relationship write response\n        SchemaVersion: sr.SchemaVersion, // sr --\u003e schema write response\n        Depth: 50,\n    },\n    Entity: \u0026 permify_payload.Entity {\n        Type: \"document\",\n        Id: \"1\",\n    },\n    Permission: \"view\",\n    Subject: \u0026 permify_payload.Subject {\n        Type: \"user\",\n        Id: \"3\",\n    },\n})\n\nif (cr.can == PermissionCheckResponse_Result.RESULT_ALLOWED) {\n    // RESULT_ALLOWED\n} else {\n    // RESULT_DENIED\n}\n```\n\n### Streaming Calls\n\n```go\nstr, err := client.Permission.LookupEntityStream(context.Background(), \u0026 permify_payload.PermissionLookupEntityRequest {\n    TenantId: \"t1\",\n\tMetadata: \u0026 permify_payload.PermissionLookupEntityRequestMetadata {\n        SnapToken: rr.SnapToken, // rr --\u003e relationship write response\n        SchemaVersion: sr.SchemaVersion, // sr --\u003e schema write response\n        Depth: 50,\n    },\n    EntityType: \"document\",\n    Permission: \"view\",\n    Subject: \u0026 permify_payload.Subject {\n        Type: \"user\",\n        Id: \"1\",\n    },\n})\n\n// handle stream response\nfor {\n    res, err: = str.Recv()\n\n    if err == io.EOF {\n        break\n    }\n\n    // res.EntityId\n}\n```\n\nPermify is an **open-source authorization service** for creating and maintaining fine-grained authorizations across your individual applications and services.\n\n* [Permify website](https://permify.co)\n* [Permify documentation](https://docs.permify.co/docs/)\n* [Permify playground](https://play.permify.co)\n* [Permify GitHub Repository](https://github.com/Permify/permify)\n\n## Community \u0026 Support\n\nJoin our [Discord channel](https://discord.gg/MJbUjwskdH) for issues, feature requests, feedbacks or anything else. We love to talk about authorization and access control :heart:\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"https://discord.gg/MJbUjwskdH\"\u003e\n \u003cimg height=\"70px\" width=\"70px\" alt=\"permify | Discord\" src=\"https://user-images.githubusercontent.com/39353278/187209316-3d01a799-c51b-4eaa-8f52-168047078a14.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://twitter.com/GetPermify\"\u003e\n  \u003cimg height=\"70px\" width=\"70px\" alt=\"permify | Twitter\" src=\"https://user-images.githubusercontent.com/39353278/187209323-23f14261-d406-420d-80eb-1aa707a71043.png\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.linkedin.com/company/permifyco\"\u003e\n  \u003cimg height=\"70px\" width=\"70px\" alt=\"permify | Linkedin\" src=\"https://user-images.githubusercontent.com/39353278/187209321-03293a24-6f63-4321-b362-b0fc89fdd879.png\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermify%2Fpermify-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpermify%2Fpermify-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermify%2Fpermify-go/lists"}