{"id":19329860,"url":"https://github.com/zhongruoyu/webauth","last_synced_at":"2026-06-20T05:02:13.976Z","repository":{"id":153369529,"uuid":"464903903","full_name":"ZhongRuoyu/WebAuth","owner":"ZhongRuoyu","description":"An HTTPS-based authentication API.","archived":false,"fork":false,"pushed_at":"2022-03-03T13:44:37.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-24T06:46:47.593Z","etag":null,"topics":["api","authentication","cloudflare-workers","javascript"],"latest_commit_sha":null,"homepage":"","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/ZhongRuoyu.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":"2022-03-01T13:27:01.000Z","updated_at":"2022-03-03T18:23:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa04e29f-8e24-4194-ba94-68fb718c431b","html_url":"https://github.com/ZhongRuoyu/WebAuth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ZhongRuoyu/WebAuth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhongRuoyu%2FWebAuth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhongRuoyu%2FWebAuth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhongRuoyu%2FWebAuth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhongRuoyu%2FWebAuth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZhongRuoyu","download_url":"https://codeload.github.com/ZhongRuoyu/WebAuth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhongRuoyu%2FWebAuth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34557553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"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":["api","authentication","cloudflare-workers","javascript"],"created_at":"2024-11-10T02:31:23.540Z","updated_at":"2026-06-20T05:02:13.954Z","avatar_url":"https://github.com/ZhongRuoyu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebAuth\n\nWebAuth is an HTTPS-based authentication API which uses salted passwords with SHA-512 hashing to enhance security. It also provides basic support for session-based authentication.\n\n## Usage\n\nWebAuth can be incorporated into other web applications that require authentication. An example would be [LinkShortener](https://github.com/ZhongRuoyu/LinkShortener), a simple authorization-based URL shortener.\n\n### Requests\n\nThe API can be called with HTTPS requests with `POST` method. The following parameters are required:\n\n| Key            | Value                                                                                                                                                         |\n| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `request_type` | The type of the request to be made. It can be one of the following: `new_user`, `auth_user`, `change_password`, `delete_user`.                                |\n| `username`     | The username.                                                                                                                                                 |\n| `password`     | The password.                                                                                                                                                 |\n| `sessionId`    | The password.                                                                                                                                                 |\n| `ttl`          | (Optional, for `auth_user` with username and password only) The session timeout. If supplied, the request generates a new session with the specified timeout. |\n| `new_password` | (For `change_password` only) The new password.                                                                                                                |\n\nNote: the validity of `ttl` is not checked. If `ttl` is not a valid number, it is ignored. If it is less than 60, then the session created will still last for 60 seconds.\n\n### Responses\n\nOne of the following responses can be expected.\n\n| Response status code     | Body                  | Description                                                                                       |\n| ------------------------ | --------------------- | ------------------------------------------------------------------------------------------------- |\n| `200 OK`                 | `success`             | The request is handled successfully.                                                              |\n| `200 OK`                 | (Session ID)          | (For `auth_user` only) A new session is successfully created. The session ID is returned.         |\n| `400 Bad Request`        | `bad request`         | The request is malformed. This can happen due to missing parameters or an invalid `request_type`. |\n| `401 Unauthorized`       | `failure`             | (N/A for `new_user`) The credentials supplied are invalid.                                        |\n| `405 Method Not Allowed` | `method not allowed`  | The request uses a method other than `POST`. Only `POST` methods are accepted.                    |\n| `406 Not Acceptable`     | `user exists`         | (For `new_user` only) The new user cannot be created because the username already exists.         |\n| `406 Not Acceptable`     | `user does not exist` | (N/A for `new_user`) The user cannot be authorized/deleted because it does not exist.             |\n\nA session ID is a random 128-bit UUID in this format: `00112233-4455-6677-8899-aabbccddeeff`.\n\n## Deployment\n\nWebAuth is designed to deploy on [Cloudflare Workers](https://workers.cloudflare.com), but it can also be deployed on other platforms (or even your own server) with some adaptation. Below are instructions for deploying it on Cloudflare Workers.\n\n### Installing Wrangler\n\nIf you do not have Wrangler installed, install it first. To install with `npm`:\n\n```bash\nnpm i @cloudflare/wrangler -g\n```\n\nOther installation instructions can be found [here](https://developers.cloudflare.com/workers/cli-wrangler/install-update/). With Wrangler installed, you also need to authenticate yourself ([instructions](https://developers.cloudflare.com/workers/cli-wrangler/authentication/)).\n\n### Configuring KV Namespaces\n\nCloudflare Workers KV is a key-value data store, and it is used by WebAuth to store the session information as well as passwords (securely, for sure).\n\nCreate the following KV namespaces:\n\n```bash\nwrangler kv:namespace create \"AUTH\"\nwrangler kv:namespace create \"SESSIONS\"\n```\n\n`AUTH` is for storage of user data, and `SESSIONS` stores the information of all the active sessions.\n\nFor each namespace created, put its configuration into [`wrangler.toml`](wrangler.toml).\n\n### Publishing the Worker\n\nFinally, the Worker can be published:\n\n```bash\nwrangler publish\n```\n\n## License\n\nCopyright (c) 2022 Zhong Ruoyu. Licensed under [the MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhongruoyu%2Fwebauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhongruoyu%2Fwebauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhongruoyu%2Fwebauth/lists"}