{"id":21801167,"url":"https://github.com/wpcodevo/2fa_fastapi","last_synced_at":"2025-10-17T10:06:26.184Z","repository":{"id":61262556,"uuid":"549837324","full_name":"wpcodevo/2fa_fastapi","owner":"wpcodevo","description":"This article will teach you how to secure a FastAPI app by implementing two-factor (2FA) authentication using TOTP tokens generated by an authenticator application like Chrome's Authenticator extension, Google Authenticator or Authy.","archived":false,"fork":false,"pushed_at":"2022-10-14T06:20:26.000Z","size":10,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T09:11:51.843Z","etag":null,"topics":["2fa","2fa-python","2factor","docker","docker-compose","fastapi","fastapi-2fa","fastapi-mongodb","mongodb","two-factor","two-factor-auth","two-factor-authentication"],"latest_commit_sha":null,"homepage":"https://codevoweb.com/two-factor-authentication-2fa-in-fastapi-and-python","language":"Python","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/wpcodevo.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}},"created_at":"2022-10-11T20:19:44.000Z","updated_at":"2025-01-02T16:06:26.000Z","dependencies_parsed_at":"2023-01-20T01:17:03.953Z","dependency_job_id":null,"html_url":"https://github.com/wpcodevo/2fa_fastapi","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/wpcodevo%2F2fa_fastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpcodevo%2F2fa_fastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpcodevo%2F2fa_fastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpcodevo%2F2fa_fastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wpcodevo","download_url":"https://codeload.github.com/wpcodevo/2fa_fastapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248760297,"owners_count":21157331,"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":["2fa","2fa-python","2factor","docker","docker-compose","fastapi","fastapi-2fa","fastapi-mongodb","mongodb","two-factor","two-factor-auth","two-factor-authentication"],"created_at":"2024-11-27T11:16:38.869Z","updated_at":"2025-10-17T10:06:21.148Z","avatar_url":"https://github.com/wpcodevo.png","language":"Python","readme":"# Two-factor Authentication (2FA) in FastAPI and Python\n\nThis article will teach you how to secure a FastAPI app by implementing two-factor (2FA) authentication using TOTP \ntokens generated by an authenticator application like Chrome's Authenticator extension, Google Authenticator or Authy. \n\n![Two-factor Authentication (2FA) in FastAPI and Python](https://codevoweb.com/wp-content/uploads/2022/10/Two-factor-Authentication-2FA-in-FastAPI-and-Python.webp)\n\n## Topics Covered\n\n- Run the 2FA FastAPI Project Locally\n- Run the 2FA React.js App Locally\n- Overview of Two-Factor Authentication in FastAPI\n- Setup the FastAPI Project\n- Setup the MongoDB with Docker\n- Create the Validation Schemas with Pydantic\n- Create the Path Operation Functions\n    - Register User Handler\n    - Login User Handler\n    - Generate TOTP Secret Key Handler\n    - Verify OTP Token Handler\n    - Verify OTP Token Handler\n    - Disable 2FA Feature\n- Configure CORS and Register the Routes\n\nRead the entire article here: [https://codevoweb.com/two-factor-authentication-2fa-in-fastapi-and-python](https://codevoweb.com/two-factor-authentication-2fa-in-fastapi-and-python)\n\nRelated articles:\n\n1. [How to Implement Two-factor Authentication (2FA) in React.js](https://codevoweb.com/two-factor-authentication-2fa-in-reactjs)\n2. [How to Implement (2FA) Two-factor Authentication in Golang](https://codevoweb.com/two-factor-authentication-2fa-in-golang)\n3. [How to Implement (2FA) Two-factor Authentication in Node.js](https://codevoweb.com/two-factor-authentication-2fa-in-nodejs)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpcodevo%2F2fa_fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwpcodevo%2F2fa_fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpcodevo%2F2fa_fastapi/lists"}