{"id":21658151,"url":"https://github.com/tsirysndr/2fa-auth","last_synced_at":"2025-10-28T00:04:15.679Z","repository":{"id":57652525,"uuid":"264108969","full_name":"tsirysndr/2fa-auth","owner":"tsirysndr","description":"Two-factor authentication for Go. One-time passcode generator with support for Google Authenticator.","archived":false,"fork":false,"pushed_at":"2020-05-15T14:51:51.000Z","size":16,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-20T06:21:49.467Z","etag":null,"topics":["go","totp","twofactor"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsirysndr.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}},"created_at":"2020-05-15T05:58:48.000Z","updated_at":"2025-04-09T01:17:32.000Z","dependencies_parsed_at":"2022-08-25T20:12:17.867Z","dependency_job_id":null,"html_url":"https://github.com/tsirysndr/2fa-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tsirysndr/2fa-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsirysndr%2F2fa-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsirysndr%2F2fa-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsirysndr%2F2fa-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsirysndr%2F2fa-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsirysndr","download_url":"https://codeload.github.com/tsirysndr/2fa-auth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsirysndr%2F2fa-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281361348,"owners_count":26487881,"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-27T02:00:05.855Z","response_time":61,"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":["go","totp","twofactor"],"created_at":"2024-11-25T09:28:46.335Z","updated_at":"2025-10-28T00:04:15.657Z","avatar_url":"https://github.com/tsirysndr.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\u003ch1\u003e2fa-auth\u003c/h1\u003e\n\u003cp\u003e\n\u003c/p\u003e\n\n\u003e 2fa-auth is a one-time passcode (time-based) generator, ideal for use in two-factor authentication, that supports Google Authenticator and other two-factor devices.\n\n## Install\n\n```sh\ngo get github.com/tsirysndr/2fa-auth\n```\n\n## Usage\n\nLet's say you have a user that wants to enable two-factor authentication, and you intend to do two-factor authentication using an app like Google Authenticator, Duo Security, Authy, etc. This is a three-step process:\n\n1. Generate a secret\n2. Show a QR code for the user to scan in\n3. Authenticate the token for the first time\n\n### Generating a key\n\nThis will generate a secret key of length 16, which will be the secret key for the user.\n\n```go\nimport (\n  fmt\n  auth \"github.com/tsirysndr/2fa-auth\"\n)\n\n...\n\ng, _ := auth.GenerateSecret(\u0026auth.Options{\n  Length:     16,\n  Symbols:    true,\n  OtpauthURL: true,\n  Name:       name,\n  Issuer:     issuer,\n})\nsecret, _ := json.Marshal(g)\nfmt.Println(string(secret))\n```\n\n### Verifying the token\n\nAfter the user scans the QR code, ask the user to enter in the token that they see in their app. Then, verify it against the secret.\n\n```go\nimport (\n  fmt\n  auth \"github.com/tsirysndr/2fa-auth\"\n)\n\n...\n\nfmt.Println(auth.VerifyOTP(secret, code))\n```\n\n## Author\n\n👤 **Tsiry Sandratraina**\n\n* Website: https://tsiry-sandratraina.netlify.com\n* Github: [@tsirysndr](https://github.com/tsirysndr)\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsirysndr%2F2fa-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsirysndr%2F2fa-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsirysndr%2F2fa-auth/lists"}