{"id":13521236,"url":"https://github.com/authzed/connector-postgresql","last_synced_at":"2025-03-31T20:31:00.632Z","repository":{"id":46155964,"uuid":"420139593","full_name":"authzed/connector-postgresql","owner":"authzed","description":"Import PostgreSQL foreign key relationships into SpiceDB","archived":true,"fork":false,"pushed_at":"2021-11-10T16:16:36.000Z","size":118,"stargazers_count":9,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-02T06:12:11.118Z","etag":null,"topics":["authorization","authzed","database","fine-grained-access-control","fine-grained-authorization","go","golang","permissions","postgresql","spicedb","zanzibar"],"latest_commit_sha":null,"homepage":"https://docs.authzed.com","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/authzed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-22T14:57:41.000Z","updated_at":"2024-05-23T21:48:43.000Z","dependencies_parsed_at":"2022-09-08T11:50:32.051Z","dependency_job_id":null,"html_url":"https://github.com/authzed/connector-postgresql","commit_stats":null,"previous_names":["authzed/connector-postgres"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fconnector-postgresql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fconnector-postgresql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fconnector-postgresql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fconnector-postgresql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/authzed","download_url":"https://codeload.github.com/authzed/connector-postgresql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222679160,"owners_count":17021812,"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":["authorization","authzed","database","fine-grained-access-control","fine-grained-authorization","go","golang","permissions","postgresql","spicedb","zanzibar"],"created_at":"2024-08-01T06:00:31.250Z","updated_at":"2024-11-02T05:31:17.848Z","avatar_url":"https://github.com/authzed.png","language":"Go","readme":"# SpiceDB Postgres Connector - Under Construction\n\n[![GoDoc](https://godoc.org/github.com/authzed/connector-postgresql?status.svg \"Go documentation\")](https://godoc.org/github.com/authzed/connector-postgresql)\n[![Discord Server](https://img.shields.io/discord/844600078504951838?color=7289da\u0026logo=discord \"Discord Server\")](https://discord.gg/jTysUaxXzM)\n[![Twitter](https://img.shields.io/twitter/follow/authzed?color=%23179CF0\u0026logo=twitter\u0026style=flat-square \"@authzed on Twitter\")](https://twitter.com/authzed)\n\n`connector-postgresql` is a tool that translates data from postgres databases into SpiceDB relationships.\n\nNo guarantees are made for the stability of the CLI interface or the format of config files.\n\nSee [CONTRIBUTING.md] for instructions on how to contribute and perform common tasks like building the project and running tests.\n\n[CONTRIBUTING.md]: CONTRIBUTING.md\n\n## Getting Started\n\n`connector-postgresql import` will connect to postgres, generate an example schema and config to map postgres data into SpiceDB, and then attempt to sync that data into SpiceDB as relationships.\n\nBy default, it will dry-run to show you what would be synced.\n\nIt can also be run as two stages: one to generate an example schema and config, and one to actually import relationships based on that config.\n\n### Auto-Import\n\n```sh\n$ connector-postgresql import --dry-run=false --spicedb-endpoint=localhost:50051 --spicedb-token=somesecretkeyhere --spicedb-insecure=true \"postgres://postgres:secret@localhost:5432/mydb?sslmode=disable\"\n```\n- Prints out a zed schema + a config mapping from pg to SpiceDB \n- Appends the generated zed schema to SpiceDB's schema\n- Mirrors all relationships into SpiceDB according to that config\n\n### Dry-Run\n\n```sh\n$ connector-postgresql import --spicedb-endpoint=localhost:50051 --spicedb-token=somesecretkeyhere --spicedb-insecure=true \"postgres://postgres:secret@localhost:5432/mydb?sslmode=disable\"\n```\n- Prints out a zed schema + a config mapping from pg to SpiceDB\n- Logs relationships that would have been written to SpiceDB\n\n### Custom Config\n\n```sh\n$ connector-postgresql import --config=config.yaml --spicedb-endpoint=localhost:50051 --spicedb-token=somesecretkeyhere --spicedb-insecure=true \"postgres://postgres:secret@localhost:5432/mydb?sslmode=disable\"\n```\n- Uses the provided `config.yaml` to write relationships into SpiceDB\n- If the required schema is already in SpiceDB, skip appending it with `--append-schema=false`\n\n#### Example `config.yaml`\n\n```yaml\nschema: |2\n  definition customer {}\n\n  definition contact {\n      relation customer: customer\n  }\n\n  definition article {\n      relation tags: tags\n  }\n\n  definition tags {\n      relation article: article\n  }\ntables:\n# for each row in the contacts table\n- name: contacts\n  relationships:\n  # generate a relationship contact:\u003ccontact_id\u003e#customer@customer:\u003ccustomer_id\u003e_\u003ccustomer_name\u003e\n  - resource_type: contact\n    resource_id_cols:\n    - contact_id\n    relation: customer\n    subject_type: customer\n    subject_id_cols:\n    - customer_id\n    - customer_name\n# for each row in the article_tag table (a join table from articles \u003c-\u003e tags)\n- name: article_tag\n  relationships:\n  # generate a relationship article:\u003carticle_id\u003e#tags@tag:\u003ctag_id\u003e\n  - resource_type: article\n    resource_id_cols:\n    - article_id\n    relation: tags\n    subject_type: tags\n    subject_id_cols:\n    - tag_id\n  # generate a second relationship tags:\u003ctag_id\u003e#article@article:\u003carticle_id\u003e\n  - resource_type: tags\n    resource_id_cols:\n    - tag_id\n    relation: article\n    subject_type: article\n    subject_id_cols:\n    - article_id\n```\n\n## Connect Quickstart\n\n**WARNING**: This is exploratory, and the current implementation has [serious flaws](https://github.com/authzed/connector-postgresql/issues/1) that mean the connector should not be run in production.\n\nThe connector can be run continuously with `connector-postgresql run`. \nRunning the connector will first run a full import via `connector-postgresql import`, but then it will follow the postgres replication log and sync data as it changes.\n\n```sh\n$ connector-postgresql run --dry-run=false --spicedb-endpoint=localhost:50051 --spicedb-token=somesecretkeyhere --spicedb-insecure=true \"postgres://postgres:secret@localhost:5432/mydb?sslmode=disable\"\n```","funding_links":[],"categories":["Integrations"],"sub_categories":["Official Integrations"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauthzed%2Fconnector-postgresql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauthzed%2Fconnector-postgresql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauthzed%2Fconnector-postgresql/lists"}