{"id":20382755,"url":"https://github.com/alexandrevilain/postgrest-auth","last_synced_at":"2025-04-12T08:54:11.986Z","repository":{"id":104959191,"uuid":"159833526","full_name":"alexandrevilain/postgrest-auth","owner":"alexandrevilain","description":"Easily add authentication to your postgrest API","archived":false,"fork":false,"pushed_at":"2019-02-14T16:38:08.000Z","size":1380,"stargazers_count":22,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T08:54:02.613Z","etag":null,"topics":["authentication","email","golang","postgresql","postgrest","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexandrevilain.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-30T14:17:39.000Z","updated_at":"2024-12-25T16:32:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"365aa31a-8a52-4e4d-9988-5105866aec61","html_url":"https://github.com/alexandrevilain/postgrest-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrevilain%2Fpostgrest-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrevilain%2Fpostgrest-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrevilain%2Fpostgrest-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrevilain%2Fpostgrest-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexandrevilain","download_url":"https://codeload.github.com/alexandrevilain/postgrest-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248543883,"owners_count":21121838,"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":["authentication","email","golang","postgresql","postgrest","sql"],"created_at":"2024-11-15T02:18:55.420Z","updated_at":"2025-04-12T08:54:11.962Z","avatar_url":"https://github.com/alexandrevilain.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Postgrest-auth\n\nThis project is inspired of [postgrest-auth](https://www.npmjs.com/package/postgrest-auth). But it's writting in golang, it's actively maintained, and email are using the [hermes](https://github.com/matcornic/hermes) library to be prettier.\n\nThe goal of this project is to provide the whole authentication features for a postgrest-prowered API. It must be deployed alongside your API and share the same jwt secret with your postgrest instance.\n\n## Installation\n\nUsing docker:\n\n```bash\ndocker run -p 3001:3001 \\\n    -e POSTGREST_AUTH_DB_CONNECTIONSTRING=postgres://user:pass@localhost/db \\\n    -e POSTGREST_AUTH_EMAIL_AUTH_PASS=pass \\\n    [...]\n    alexandrevilain/postgrest-auth\n```\n\n## API\n\n#### Sign in\n\nPOST /signin\n\n```bash\ncurl -X POST http://localhost:3001/signin \\\n  -H 'Content-Type: application/json' \\\n  -d '{ \"email\": \"myemail@me.com\", \"password\": \"password\" }'\n```\n\n#### Sign up\n\nPOST /signup\n\n```bash\ncurl -X POST http://localhost:3001/signup \\\n  -H 'Content-Type: application/json' \\\n  -d '{ \"email\": \"myemail@me.com\", \"password\": \"password\" }'\n```\n\n#### Confirm email address\n\nGET /confirm/{id}?token={token}\n\n#### Ask for password reset\n\nPOST /reset\n\n```bash\ncurl -X POST http://localhost:3001/reset \\\n  -H 'Content-Type: application/json' \\\n  -d '{ \"email\": \"myemail@me.com\" }'\n```\n\n#### Reset password\n\nPOST /reset/:token\n\n```bash\ncurl -X POST http://localhost:3001/reset/{token} \\\n  -H 'Content-Type: application/json' \\\n  -d '{ \"password\": \"mynewpassword\" }'\n```\n\n#### Google Sign in\n\nPOST /provider/google\n\n```bash\ncurl -X POST \\\n  http://localhost:3001/provider/google \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n\t\"token\": \"\u003cgoogle access token\u003e\",\n\t\"state\":\"\u003cstate defined in config\u003e\"\n}'\n```\n\n#### Facebook Sign in\n\nPOST /provider/facebook\n\n```bash\ncurl -X POST \\\n  http://localhost:3001/provider/facebook \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n\t\"token\": \"\u003cfacebook access token\u003e\",\n\t\"state\":\"\u003cstate defined in config\u003e\"\n}'\n```\n\n## Configuration\n\nMany environment variables are availables to custom your postgrest-auth instance:\n\n| Name                               | Description                                                                                                                                      | Default                              |\n| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ |\n| POSTGREST_AUTH_API_PORT            | The listening port of the service                                                                                                                | 3001                                 |\n| POSTGREST_AUTH_API_TOKEN           | The secret used to create the reset password token                                                                                               | supersecret                          |\n| POSTGREST_AUTH_LINKS_RESET         | The reset password link sent by email (\"%v\" will be replaced with the token)                                                                     | http://localhost/reset/%v            |\n| POSTGREST_AUTH_LINKS_CONFIRM       | The confirm account link sent by email (The first %v will be replaced by the user's id and the second %v will be replaced by the confirm token ) | http://localhost/confirm/%v?token=%v |\n| POSTGREST_AUTH_JWT_EXP             | The token expiration (in hours)                                                                                                                  | X                                    |\n| POSTGREST_AUTH_JWT_SECRET          | The shared secret with postgrest                                                                                                                 | X                                    |\n| POSTGREST_AUTH_DB_CONNECTIONSTRING | Your dd connection string                                                                                                                        | X                                    |\n| POSTGREST_AUTH_DB_ROLES_ANONYMOUS  | The role for anonymous users                                                                                                                     | X                                    |\n| POSTGREST_AUTH_DB_ROLES_USER       | The role when users are authenticated                                                                                                            | X                                    |\n| POSTGREST_AUTH_APP_NAME            | The application's name where postgrest-auth is installed (your band name)                                                                        | X                                    |\n| POSTGREST_AUTH_APP_LINK            | Your appplication's website                                                                                                                      | X                                    |\n| POSTGREST_AUTH_APP_LOGO            | Your application's logo                                                                                                                          | X                                    |\n| POSTGREST_AUTH_EMAIL_FROM          |                                                                                                                                                  | X                                    |\n| POSTGREST_AUTH_EMAIL_HOST          |                                                                                                                                                  | X                                    |\n| POSTGREST_AUTH_EMAIL_PORT          |                                                                                                                                                  | X                                    |\n| POSTGREST_AUTH_EMAIL_AUTH_USER     |                                                                                                                                                  | X                                    |\n| POSTGREST_AUTH_EMAIL_AUTH_PASS     |                                                                                                                                                  | X                                    |\n| POSTGREST_AUTH_API_ALLOWEDDOMAINS  | The list of allowed email domains for signup (comma-separated)                                                                                   | X                                    |\n| POSTGREST_AUTH_OAUTH2_STATE        | Same state that you defined whene retrieving your access token                                                                                   | random-state                         |\n\n## Integration with postgreSQL\n\nThis service automatically creates a schema named \"auth\" and roles defined used environment variables.\nIt provides you an helper fonction `auth.current_user_id()` that you can for instance use in your POLICES:\n\n```sql\nCREATE POLICY questions_update ON questions FOR UPDATE\n    USING (user_id = auth.current_user_id())\n    WITH CHECK (user_id = auth.current_user_id());\n```\n\n## TODO\n\n- Unit tests\n\n## Contributing\n\nFeel free to send PRs!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrevilain%2Fpostgrest-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexandrevilain%2Fpostgrest-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrevilain%2Fpostgrest-auth/lists"}