{"id":21906238,"url":"https://github.com/alfex4936/rust-actix-oauth2","last_synced_at":"2025-04-15T23:53:16.902Z","repository":{"id":186923553,"uuid":"675201955","full_name":"Alfex4936/rust-actix-oauth2","owner":"Alfex4936","description":"Google/Github/NAVER/Kakao OAuth2 login","archived":false,"fork":false,"pushed_at":"2023-08-23T11:13:28.000Z","size":655,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-12T13:22:48.515Z","etag":null,"topics":["api","google","jwt","kakao","login","naver","oauth","oauth2","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/Alfex4936.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":"2023-08-06T05:54:08.000Z","updated_at":"2024-11-03T07:57:47.000Z","dependencies_parsed_at":"2024-12-02T17:15:28.250Z","dependency_job_id":null,"html_url":"https://github.com/Alfex4936/rust-actix-oauth2","commit_stats":null,"previous_names":["alfex4936/rust-actix-oauth2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alfex4936%2Frust-actix-oauth2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alfex4936%2Frust-actix-oauth2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alfex4936%2Frust-actix-oauth2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alfex4936%2Frust-actix-oauth2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alfex4936","download_url":"https://codeload.github.com/Alfex4936/rust-actix-oauth2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249173061,"owners_count":21224481,"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":["api","google","jwt","kakao","login","naver","oauth","oauth2","rust"],"created_at":"2024-11-28T16:43:09.519Z","updated_at":"2025-04-15T23:53:16.882Z","avatar_url":"https://github.com/Alfex4936.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 OAuth2 Login Demo\n\n\u003cimg src=\"https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2\u0026fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbo7ZvX%2Fbtsp64YhCDP%2Fndp7pA0pKA2WkiNpH9yAL0%2Fimg.png\" width=\"300\" height=\"340\"\u003e\n\n![demo](https://github.com/Alfex4936/rust-actix-oauth2/assets/2356749/81ac3ea2-f934-4da6-a01d-4b729e147c1f)\n\n\nThis project serves as a demo for implementing OAuth2 login functionality using multiple providers like Kakao, Naver, Google, and GitHub. Along with OAuth authentication, it also demonstrates how to create users in the database after successful authentication.\n\n이 프로젝트는 카카오, 네이버, 구글, 깃허브와 같은 여러 제공업체를 사용하여 OAuth2 로그인 기능을 구현하기 위한 데모로 사용되었습니다.\n\nOAuth 인증 외에도 인증이 성공한 후 데이터베이스에 사용자를 생성하는 방법도 보여줍니다.\n\n## 📝 Features\n\n- **OAuth Authentication** with multiple providers:\n  - \u003cimg src=\"https://github.com/Alfex4936/Alfex4936/assets/2356749/dc097b7b-2756-4cf1-a306-23130377dd46\" width=\"20\" height=\"20\"\u003e GitHub (깃헙)\n  - \u003cimg src=\"https://github.com/Alfex4936/Alfex4936/assets/2356749/2c3ddcf4-36f7-40b6-b31e-832e608eb28e\" width=\"20\" height=\"20\"\u003e Google (구글)\n  - \u003cimg src=\"https://github.com/Alfex4936/Alfex4936/assets/2356749/a2fd5b2a-aa0a-40fe-a0b8-3a5bc490e6c9\" width=\"20\" height=\"20\"\u003e Kakao (카카오)\n  - \u003cimg src=\"https://github.com/Alfex4936/Alfex4936/assets/2356749/edafa506-8b43-4b61-ac60-551d369b6a15\" width=\"20\" height=\"20\"\u003e Naver (네이버)\n  - :)\n\n\n- **User Management**: Creating users in the database post-authentication.\n\n- **Token Management**: JWT-based token issuance and validation for authenticated users.\n\u003c!-- \n## 📦 Project Structure\n\n```\nsrc/\n|   main.rs\n|\n+---auth\n|   |   mod.rs\n|   |   token.rs\n|   |   token_guard.rs\n|   |\n|   \\---oauth\n|       |   github_oauth.rs\n|       |   google_oauth.rs\n|       |   kakao_oauth.rs\n|       |   mod.rs\n|       |   naver_oauth.rs\n|\n+---config\n|   |   env.rs\n|   |   mod.rs\n|\n+---handlers\n|   |   auth_handler.rs\n|   |   mod.rs\n|   |   oauth_handler.rs\n|\n+---models\n|   |   app_state.rs\n|   |   login_user_schema.rs\n|   |   mod.rs\n|   |   query_code.rs\n|   |   register_user_schema.rs\n|   |   token_claims.rs\n|   |   user.rs\n|\n\\---responses\n    |   filtered_user.rs\n    |   mod.rs\n    |   user_response.rs\n``` --\u003e\n\n## 🌱 Setup\n\n1. **Install mkcert**:\n\n   First, you need to install `mkcert` for creating a local certificate for HTTPS development.\n\n   **On Windows** (using [Chocolatey](https://chocolatey.org/)):\n\n   ```bash\n   choco install mkcert\n   ```\n\n   **On Linux**:\n\n   ```bash\n   sudo apt install libnss3-tools\n   wget -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.4.0/mkcert-v1.4.0-linux-amd64\n   chmod +x mkcert\n   sudo mv mkcert /usr/local/bin/\n   ```\n\n   Next, install the local CA:\n\n   ```bash\n   mkcert -install\n   ```\n\n   Finally, create a certificate for `localhost`:\n\n   ```bash\n   mkcert localhost\n   ```\n\n   This will generate two files: `localhost.pem` (the certificate) and `localhost-key.pem` (the private key). Remember the location of these files as you might need to reference them in your application for HTTPS.\n\n2. **Clone the Repository**:\n\n   ```bash\n   git clone https://github.com/Alfex4936/rust-actix-oauth2.git\n   cd rust-actix-oauth2\n   ```\n\n3. **Setup Environment Variables**:\n\n   Copy the sample `.env` content and set the appropriate values for your OAuth application:\n\n   ```env\n   CLIENT_ORIGIN=http://localhost:3001\n   JWT_SECRET=your_secret\n   ...\n   # Fill other values accordingly.\n   ```\n\n4. **Run the Application**:\n\n   ```bash\n   cargo install cargo-watch\n   \n   cargo watch -q -c -w src/ -x run\n   ```\n\n   Hosted at `https://localhost:8080`. (**Not on `http://`**)\n\n---\n\n**Note**: Ensure that your application is configured to use the generated `localhost.pem` and `localhost-key.pem` files when serving via HTTPS. This can often be done in the web framework's settings or configuration.\n\n## 🔍 Example: Naver OAuth2\n\nTo get an insight into how the OAuth flow works, here's a snippet for Naver OAuth:\n\n```rust\n// ... [snip] ...\n\npub async fn get_naver_oauth_token(\n    authorization_code: \u0026str,\n    data: \u0026web::Data\u003cAppState\u003e,\n) -\u003e Result\u003cBasicOauthToken, Box\u003cdyn Error\u003e\u003e {\n    // ... [snip] ...\n}\n\npub async fn get_naver_user(access_token: \u0026str) -\u003e Result\u003cNaverUserResult, Box\u003cdyn Error\u003e\u003e {\n    // ... [snip] ...\n}\n```\n\n## 🙌 Contributions\n\nLet's make authentication easy for everyone!\n\n## 📜 License\n\nThis project is licensed under the MIT License - see the [LICENSE](MIT.md) file for details.\n\n---","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfex4936%2Frust-actix-oauth2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falfex4936%2Frust-actix-oauth2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfex4936%2Frust-actix-oauth2/lists"}