{"id":17241708,"url":"https://github.com/j256/two-factor-auth","last_synced_at":"2025-04-05T00:10:20.523Z","repository":{"id":44437188,"uuid":"37153765","full_name":"j256/two-factor-auth","owner":"j256","description":"Two Factor Authentication Java code implementing the Time-based One-time Password Algorithm","archived":false,"fork":false,"pushed_at":"2022-12-09T22:18:26.000Z","size":120,"stargazers_count":302,"open_issues_count":2,"forks_count":109,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-05-01T23:46:11.458Z","etag":null,"topics":["java","password","security","totp"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/j256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"j256","patreon":"j256"}},"created_at":"2015-06-09T19:34:28.000Z","updated_at":"2024-04-23T02:51:51.000Z","dependencies_parsed_at":"2023-01-25T17:00:17.024Z","dependency_job_id":null,"html_url":"https://github.com/j256/two-factor-auth","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j256%2Ftwo-factor-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j256%2Ftwo-factor-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j256%2Ftwo-factor-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j256%2Ftwo-factor-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j256","download_url":"https://codeload.github.com/j256/two-factor-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208455,"owners_count":20901570,"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":["java","password","security","totp"],"created_at":"2024-10-15T06:10:42.027Z","updated_at":"2025-04-05T00:10:20.508Z","avatar_url":"https://github.com/j256.png","language":"Java","readme":"Two (2) Factor Authentication (2FA) Java Code\n=============================================\n\n2 Factor Authentication (2FA) Java code which used the Time-based One-time Password (TOTP) algorithm.\nYou can use this code with the Google Authenticator mobile app or the Authy mobile or browser app.\n\n* See the [wikipedia page about TOTP](https://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm).\t\n* Code available from the [git repository](https://github.com/j256/two-factor-auth).  [![CircleCI](https://circleci.com/gh/j256/two-factor-auth.svg?style=svg)](https://circleci.com/gh/j256/two-factor-auth) [![CodeCov](https://img.shields.io/codecov/c/github/j256/two-factor-auth.svg)](https://codecov.io/github/j256/two-factor-auth/)\n* Maven packages are published via [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.j256.two-factor-auth/two-factor-auth/badge.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/com.j256.two-factor-auth/two-factor-auth/) [![javadoc](https://javadoc.io/badge2/com.j256.two-factor-auth/two-factor-auth/javadoc.svg)](https://javadoc.io/doc/com.j256.two-factor-auth/two-factor-auth)\n\n## To get this to work you:\n\n1. Use `generateBase32Secret()` to generate a secret key in base-32 format for the user.  For example: `\"NY4A5CPJZ46LXZCP\"`\n2. Store the secret key in the database associated with the user account.\n3. Display the QR image URL returned by `qrImageUrl(...)` to the user.  Here's a sample which uses GoogleAPIs:  \n![Sample QR Image](https://chart.googleapis.com/chart?chs=200x200\u0026cht=qr\u0026chl=200x200\u0026chld=M|0\u0026cht=qr\u0026chl=otpauth://totp/user@j256.com%3Fsecret%3DNY4A5CPJZ46LXZCP)\n4. User uses the image to load the secret key into his authenticator application.\n\n## Whenever the user logs in:\n\n1. The user enters the number from the authenticator application into the login form on the web server.\n2. The web server reads the secret associated with the user account from the database.\n3. The server compares the user input with the output from `generateCurrentNumberString(...)`.\n4. If they are equal then the user is allowed to log in.\n\nFor more details, see the [example program](https://github.com/j256/two-factor-auth/blob/master/src/test/java/com/j256/twofactorauth/TwoFactorAuthExample.java).\n\n# Maven Configuration\n\n``` xml\n\u003cdependencies\u003e\n\t\u003cdependency\u003e\n\t\t\u003cgroupId\u003ecom.j256.two-factor-auth\u003c/groupId\u003e\n\t\t\u003cartifactId\u003etwo-factor-auth\u003c/artifactId\u003e\n\t\t\u003cversion\u003e1.3\u003c/version\u003e\n\t\u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n# ChangeLog Release Notes\n\nSee the [ChangeLog.txt file](src/main/javadoc/doc-files/changelog.txt).\n","funding_links":["https://github.com/sponsors/j256","https://patreon.com/j256"],"categories":["安全"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj256%2Ftwo-factor-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj256%2Ftwo-factor-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj256%2Ftwo-factor-auth/lists"}