Package: open2fa
open2faopen2fa.liberfy.aiNOW LIVEOpen2FA is a 100% LIBRE tool for generating Two-Factor Authentication (2FA) (TOTP) codes, with optional, secure, remote sync/restore/etc capabilities, as well as optional webui 2FA code generation.All code can be found at:CLI repoAPI/WebUI repoFor information as to how the remote capabilities work, seeopen2fa.liberfi.aiSee thechangelogto follow ongoing development.FeaturesCLI 2FA Code Generation: Generate 2FA codes from the command line from TOTP secret keys stored either locally or remotely.Secure Remote Capabilitites: All remotely stored TOTP secrets are stored encrypted and are only decrypted client side.Easily restore TOTP secrets: Easily transfer and restore TOTP secrets from any device from only a UUIDWebUI 2FA Code Generation: Generate 2FA codes from the webui using the remotely stored encrypted TOTP secret keys from any device, even if the device does not have either the open2fa CLI or the TOTP secrets stored locally.Host your own API: You can easily choose to host your own open2fa server and use it with the open2fa CLI.Open Source: Open2FA is 100% open source and is both free as in freedom and free as in beer.InstallationInstall the CLI usingpip:pipinstallopen2faIf wanting to do development work, install with dev dependencies:pipinstall'open2fa[dev]'ConfigurationEnvironment Variables:OPEN2FA_DIR: The directory where TOTP secrets and the Open2FA UUID are stored. Defaults to.open2fain the user's home directory.OPEN2FA_API_URL: The URL of the Open2FA API instance to use. Defaults tohttps://open2fa.liberfy.ai.OPEN2FA_UUID(Optional): Instead of using theopen2fa.uuidfile stored inOPEN2FA_DIR, you can set theOPEN2FA_UUIDenvironment variable to the UUID you wish to use.Default File LocationsSecrets File: The TOTP secrets are stored inOPEN2FA_DIR/secrets.json.UUID File: The Open2FA UUID is stored inOPEN2FA_DIR/open2fa.uuid, but can also be set using theOPEN2FA_UUIDenvironment variable. This UUID is used to identify the user and encrypt/decrypt their remotely stored secrets.CLI Usage ( local )You can see the full list of commands and options by runningopen2fa -horopen2fa --help.Add a TOTP Secret:open2faaddI65VU7K5ZQL7WB4E-nTESTKEY123Delete a TOTP Secret:open2fadelete-nTESTKEY123List All TOTP Secrets:open2falistExample Output:Name         Secret
-------      -----
Secret1      I...E
Secret2      I...E
Secret3      A...BTo show the secret keys, use the-sflag:open2falist-s

NameSecret
-------------
Secret1I65VU7K5ZQL7WB4E
Secret2I65VU7K5ZQL7WB4E
Secret3I65VU7K5ZQL7WB4EGenerate 2FA Codes:Generate codes for keys saved inOPEN2FA_DIR/secrets.json:open2fa%py3-mopen2fa.clig-nTEST

NameCodeNext
------------------------------------------
aTESTTESTTESTTESTTESTTEST391951327.29
aTESTTESTTESTTESTTESTTEST3391951327.29
aTESTTESTTESTTESTTESTTEST33491951327.29
aTESTTESTTESTTESTTESTTEST334491951327.29
aTESTTESTTESTTESTTESTTEST33443491951327.29
TESTTESTTESTTESTTESTTEST91951327.29
TESTTESTTESTTESTTESTTEST291951327.29
TESTTESTTESTTESTTESTTEST291951327.29
TESTTESTTESTTESTTESTTEST291951327.29
TESTTESTTESTTESTTESTTEST291951327.29
TESTTESTTESTTESTTESTTEST291951327.29
TESTTESTTESTTESTTESTTEST291951327.29Tokens will continue to be generated until the user exits the program withCtrl+C.As of version 1.1.0, theopen2fa generatecommand will automatically adjust the height/width of the generated codes to fit the terminal window.Show Open2FA Info/Status/Secrets:open2fainfoExample Output:========== Open2FA INFO/STATUS ==========
(add -s to show uncensored secrets)

Open2FA Directory: /Users/mym2/.open2fa
Open2FA Remote API URL: http://localhost:8000/api/v1
Number of secrets: 11
Open2FA UUID: 0...
Open2FA ID: X...
Open2FA Secret: Q...CLI Usage ( remote )When initializing the remote capabilities of the open2fa CLI, a UUID will be generated and stored inOPEN2FA_DIR/open2fa.uuid. This UUID is used to identify the user and encrypt/decrypt their remotely stored secrets. As long as the user has access to this UUID, they can restore their TOTP secrets from any device, as well as generate 2FA codes from the webui.For usage with the webui, both the Open2FA ID and the Open2FA Secret are required. These can be determined fromopen2fa infoafter initializing the remote capabilities of the open2fa CLI.Initialize the Remote Capabilities of the Open2FA Client:open2fainitExample Output:open2fa remote init

Do you want to initialize remote capabilities of Open2FA? (y/n): y

Remote capabilities initialized with UUID: 0e4742ef-780b-406d-8651-7766cf67be3f
It is recommended to save this UUID somewhere safe and use as an environment variable OPEN2FA_UUID.

========== Open2FA INFO/STATUS ==========

Open2FA Directory: /Users/mym2/.open2fa
Open2FA Remote API URL: http://localhost:8000/api/v1
Number of secrets: 11
Open2FA UUID: 0e4742ef-780b-406d-8651-7766cf67be3f
Open2FA ID: XF1628BGJeibVv8C9UacG4
Open2FA Secret:QGcst74V9JXnyBnQmWSoCxIn this example:The Open2FA UUID is0e4742ef-780b-406d-8651-7766cf67be3fThe Open2FA ID isXF1628BGJeibVv8C9UacG4The Open2FA Secret isQGcst74V9JXnyBnQmWSoCxRemote CommandsPush TOTP Secrets to the remote server:open2fapushPull TOTP Secrets from the remote server:open2fapullDelete a TOTP Secret from the remote server:open2fadelete-nTESTKEY123TestingYou can run the tests by runningpytest tests.pyin the root directory of the project
or by running the vscode pytest launch configuration with f5.---------- coverage: platform darwin, python 3.11.7-final-0 ----------
Name                   Stmts   Miss  Cover   Missing
----------------------------------------------------
open2fa/__init__.py        3      0   100%
open2fa/cli.py           102      7    93%   230-231, 237-238, 286-287, 298
open2fa/cli_utils.py      63      0   100%
open2fa/common.py         70      1    99%   123
open2fa/config.py         12      0   100%
open2fa/ex.py             15      2    87%   3, 19
open2fa/main.py          203     22    89%   81, 114-118, 126, 180, 195-199, 243-244, 284, 327-328, 384-385, 388-390, 404
open2fa/msgs.py           21      0   100%
open2fa/totp.py           30      0   100%
open2fa/utils.py          31     14    55%   20-25, 28, 52-63
open2fa/version.py         1      0   100%
----------------------------------------------------
TOTAL                    551     46    92%

==================================================================== 21 passed in 2.29sThe tests are not complete, and need to be expanded.ContributingFeel free to open an issue or pull request. If you are opening a pull request, please make sure to run the tests and ensure that the coverage does not decrease, and any new code is covered by tests.Remember to update thechangelogwith any changes and to update the version inopen2fa/version.pyandpyproject.toml(can use theset_version.pyscript).LicenseMITContactccarterdev@gmail.com