{"id":31575972,"url":"https://github.com/harperfast/cf-auth-oauth2","last_synced_at":"2025-10-05T17:05:52.407Z","repository":{"id":87860887,"uuid":"555409063","full_name":"HarperFast/cf-auth-oauth2","owner":"HarperFast","description":"A HarperDB Custom Function to integrate OAuth 2.0 authorization via major providers.","archived":true,"fork":false,"pushed_at":"2022-12-21T22:07:20.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-01T22:12:27.879Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/HarperFast.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-10-21T14:18:22.000Z","updated_at":"2025-10-01T12:20:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a875486-7fc6-416a-b332-7f25f99f389d","html_url":"https://github.com/HarperFast/cf-auth-oauth2","commit_stats":null,"previous_names":["harperfast/cf-auth-oauth2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HarperFast/cf-auth-oauth2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarperFast%2Fcf-auth-oauth2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarperFast%2Fcf-auth-oauth2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarperFast%2Fcf-auth-oauth2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarperFast%2Fcf-auth-oauth2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HarperFast","download_url":"https://codeload.github.com/HarperFast/cf-auth-oauth2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarperFast%2Fcf-auth-oauth2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278486308,"owners_count":25994945,"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-10-05T02:00:06.059Z","response_time":54,"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-10-05T17:05:04.074Z","updated_at":"2025-10-05T17:05:52.397Z","avatar_url":"https://github.com/HarperFast.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HarperDB OAuth2.0 Custom Function\n\nThis is a [HarperDB](https://harperdb.io/) Custom Function to integrate OAuth 2.0 authorization via major providers via [the Fastify-OAuth2 library](https://github.com/fastify/fastify-oauth2).\n\n## Setup\n\nThis [Custom Function](https://harperdb.io/docs/custom-functions/) can be deployed via the [HarperDB Studio](https://studio.harperdb.io/) or locally by cloning this repository into a directory inside the `/custom_functions/` directory (i.e `/custom_funtions/oauth`).\n\nConfigure the provider, OAuth keys and endpoints in the file .authConfig.json or with the following environment variables.\n\n```\nCLIENT_ID: '12134',\nCLIENT_SECRET: '12234',\nPROVIDER: GITHUB_CONFIGURATION,\nLOGINPATH: /login/github,\nCALLBACK: http://localhost:9926/oauth/callback,\nSCHEMA: hdb_auth,\nTABLE: sessions,\nSALT_ROUNDS: 5,\nLOGOUT: /logout\n```\n\n## How to Use\n**note: in the below examples, \"oauth\" is the given name of the Custom Function, and it's using the GitHub provider OAuth provider.\n\n1. Ensure the above config file or environment variables have been set.\n2. Create a GET request to [$HOST/oauth/setup]($HOST/oauth/setup) to create the auth schema and table.\n3. Visit [http://$HOST/oauth/login/github](http://$HOST/oauth/login/github) to be redirected to the GitHub authorization page to create a token.\n4. Save the return HDB Token for use in the Authorization header for the following requests. You should use the token in the Authorization header in the format `harperdb $token`\n5. With the HDB Token in the Authorization header, make a GET call to [http://$HOST/oauth/create/schema/:schema](http://$HOST/oauth/create/schema/:schema) to create a schema\n6. With the HDB Token in the Authorization header, make a GET call to [http://$HOST/oauth/create/table/:schema/:table](http://$HOST/oauth/create/table/:schema/:table) to create a table\n7. With the HDB Token in the Authorization header, make a POST call to [http://$HOST/oauth/:schema/:table](http://$HOST/oauth/:schema/:table) to insert records into the server (the request body can be an object or an array of objects).\n8. With the HDB Token in the Authorization header, make a GET call to [http://$HOST/oauth/create/table/:schema/:table/:id](http://$HOST/oauth/create/table/:schema/:table/:id) to retrieve a record from the table\n\n## Postman Collection\nThere's a Postman collection available in this repo - HarperDB OAuth.postman_collection\n\n## Structure and Updates\nThe majority of the functionality is contained in the helpers/authHelper.js file. Here the configuration is loaded and used to set up [the Fastify-OAuth2](https://github.com/fastify/fastify-oauth2) library](https://github.com/fastify/fastify-oauth2), which is a wrapper around the [Simple OAuth2.0 library](https://github.com/lelylan/simple-oauth2).\n\nRefer to the fastify-oauth2 doc for a list of providers and the simple-oauth2 documentation for additional configuration options.\n\n## Running Locally\nThere's a Makefile located in this repo that will start a containerized instance of HarperDB with the Custom Function mounted to the src directory.\n\n### To Start\nRun `make` to start the container.\n\n### To Restart the Custom Function\nRun `make cfr` to restart the Custom Functions server\n\n### To Stop\nRun `make down` to stop the container\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharperfast%2Fcf-auth-oauth2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharperfast%2Fcf-auth-oauth2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharperfast%2Fcf-auth-oauth2/lists"}