{"id":20915299,"url":"https://github.com/oguzhan18/rust_mongodb_auth","last_synced_at":"2026-02-01T03:02:16.510Z","repository":{"id":231684619,"uuid":"782398985","full_name":"oguzhan18/rust_mongodb_auth","owner":"oguzhan18","description":"Simple Auth API written in Rust","archived":false,"fork":false,"pushed_at":"2024-04-05T08:36:59.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-07T21:18:08.713Z","etag":null,"topics":["authentication","authentication-backend","mongoatlas","mongodb","rust","rust-auth","rust-lang"],"latest_commit_sha":null,"homepage":"https://rust-mongodb-auth.onrender.com/register","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oguzhan18.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-04-05T08:16:11.000Z","updated_at":"2024-04-05T08:40:12.000Z","dependencies_parsed_at":"2024-04-05T10:49:16.165Z","dependency_job_id":null,"html_url":"https://github.com/oguzhan18/rust_mongodb_auth","commit_stats":null,"previous_names":["oguzhan18/rust_mongodb_auth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oguzhan18%2Frust_mongodb_auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oguzhan18%2Frust_mongodb_auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oguzhan18%2Frust_mongodb_auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oguzhan18%2Frust_mongodb_auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oguzhan18","download_url":"https://codeload.github.com/oguzhan18/rust_mongodb_auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246766091,"owners_count":20830227,"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","authentication-backend","mongoatlas","mongodb","rust","rust-auth","rust-lang"],"created_at":"2024-11-18T16:13:59.983Z","updated_at":"2026-02-01T03:02:16.473Z","avatar_url":"https://github.com/oguzhan18.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust MongoDB Auth API Documentation\n\nThis API provides endpoints for user registration and login using Actix web framework and MongoDB.\n\n## Endpoints\n\n### Register\n\nRegisters a new user with the provided username and password.\n\n- **URL**: `/register`\n- **Method**: `POST`\n- **Request Body**: JSON\n\n#### Request Body Parameters\n\n| Parameter | Type   | Description                |\n|-----------|--------|----------------------------|\n| `username`| string | User's username            |\n| `password`| string | User's password            |\n\n#### Responses\n\n- **200 OK**: User registered successfully\n- **500 Internal Server Error**: Failed to register user\n\n### Login\n\nAuthenticates a user with the provided username and password.\n\n- **URL**: `/login`\n- **Method**: `POST`\n- **Request Body**: JSON\n\n#### Request Body Parameters\n\n| Parameter | Type   | Description                |\n|-----------|--------|----------------------------|\n| `username`| string | User's username            |\n| `password`| string | User's password            |\n\n#### Responses\n\n- **200 OK**: Login successful\n- **401 Unauthorized**: Invalid credentials\n- **500 Internal Server Error**: Failed to login\n\n## Rust Code Overview\n\nThe API is implemented in Rust programming language using Actix web framework and MongoDB driver. Below are the key components of the Rust code:\n\n- **User Struct**: Represents a user with `username` and `password` fields.\n\n- **register Function**: Handles user registration by inserting user data into the MongoDB collection. It takes user data and the MongoDB collection as arguments and returns a HTTP response indicating the registration status.\n\n- **login Function**: Handles user login by verifying user credentials against the MongoDB collection. It takes user data and the MongoDB collection as arguments and returns a HTTP response indicating the login status.\n\n- **main Function**: Initializes the Actix web server, connects to the MongoDB database, selects the 'users' collection, and binds the routes for registration and login.\n\n## Usage\n\n1. Make sure Rust and MongoDB are installed on your system.\n2. Run `cargo run` to start the API server.\n3. Send POST requests to `/register` and `/login` endpoints using JSON body to register and login users.\n\n## MongoDB Configuration\n\nUpdate the MongoDB connection URI in the main function with your MongoDB Atlas credentials and cluster information.\n\n```rust\nlet client = Client::with_uri_str(\"mongodb+srv://\u003cusername\u003e:\u003cpassword\u003e@\u003ccluster\u003e/\u003cdatabase\u003e\")\n    .await\n    .expect(\"Failed to initialize MongoDB client\");\n```\n\nReplace `\u003cusername\u003e`, `\u003cpassword\u003e`, and \u003ccluster\u003e with your MongoDB Atlas credentials and cluster information.\n\n\n\n## For Support\nFor support, send an email to oguzhancart1@gmail.com or you are invited to our telegram channel https://t.me/vsform_tr  \n \n## Contact Me\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://codepen.io/oguzhan1881\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/codepen.svg\" alt=\"oguzhan1881\" height=\"50\" width=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://dev.to/oguzhan18\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/devto.svg\" alt=\"oguzhan18\" height=\"50\" width=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/oguzhancart\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/twitter.svg\" alt=\"oguzhancart\" height=\"50\" width=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://linkedin.com/in/o%c4%9fuzhan-%c3%a7art-b73405199/\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/linked-in-alt.svg\" alt=\"o%c4%9fuzhan-%c3%a7art-b73405199/\" height=\"50\" width=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://codesandbox.com/oguzhan18\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/codesandbox.svg\" alt=\"oguzhan18\" height=\"50\" width=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://instagram.com/oguzhan_cart\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/instagram.svg\" alt=\"oguzhan_cart\" height=\"50\" width=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://dribbble.com/cart188\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/dribbble.svg\" alt=\"cart188\" height=\"50\" width=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://hashnode.com/@oguzhancart\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/hashnode.svg\" alt=\"@oguzhancart\" height=\"50\" width=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.leetcode.com/oguzhan18/\" target=\"blank\"\u003e\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/leet-code.svg\" alt=\"oguzhan18/\" height=\"50\" width=\"50\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foguzhan18%2Frust_mongodb_auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foguzhan18%2Frust_mongodb_auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foguzhan18%2Frust_mongodb_auth/lists"}