跳转到主要内容

类似于用Python编写的Google身份验证器。

项目描述

pyauthenticator

Python package Coverage Status Code style: black

类似于用Python编写的Google身份验证器。随着越来越多的服务需要两步验证,而不支持应用特定密码或其他形式的基于令牌的身份验证,这个Python包允许在命令行或Python中生成两步验证代码。

Preview of pyauthenticator

对于用户

安装

使用conda安装pyauthenticator

>>> conda install -c conda-forge pyauthenticator

或者,也可以通过pip安装pyauthenticator

>>> pip install pyauthenticator

命令行

使用pyauthenticator --help/-h选项获取如何使用pyauthenticator的帮助信息

>>> pyauthenticator --help

usage: pyauthenticator [-h] [-qr] [-a ADD] service

positional arguments:
  service            Service to generate optauth code for. Currently no
                     service is defined in the ~/.pyauthenticator config file.

options:
  -h, --help         show this help message and exit
  -qr, --qrcode      Generate qrcode as <service.png> file.
  -a ADD, --add ADD  Add service by providing the <qrcode.png> file as
                     additional argument.

google作为新服务添加到桌面上的Screenshot 2023-07-02 at 12.45.09.png二维码后

>>> pyauthenticator google --add ~/Desktop/Screenshot\ 2023-07-02\ at\ 12.45.09.png

The service 'google' was added, from file </Users/jan/Desktop/Screenshot 2023-07-02 at 12.45.09.png>

之后,可以使用以下方法为服务google生成新的认证代码:

>>> pyauthenticator google

087078

除了Google之外,pyauthenticator还可以适用于任何实现两步验证的服务。

如果您误输了服务名称,那么pyauthenticator将建议替代选项

>>> pyauthenticator googel

The service "googel" does not exist.

The config file ~/.pyauthenticator contains the following services:
  * google

Choose one of these or add a new service using:
  pyauthenticator --add <qr-code.png> <servicename>

支持

对于任何支持请求,请随时在Github上打开问题

对于开发者

Python接口

命令行上可用的相同功能也通过Python接口提供

from pyauthenticator import get_two_factor_code
get_two_factor_code(service)

因此,pyauthenticator可以集成到需要访问受两步验证保护资源的现有Python包中。

配置

配置存储在~/.pyauthenticator中,它以JSON格式编写。对于给定的服务如github,配置文件包含

{"google": "otpauth://totp/Google:<username>?secret=<secret>&issuer=Google"}

Google用户名<username>和相应的密钥<secret>包含在二维码中。

许可

pyauthenticator软件包根据BSD-3-Clause许可许可。

项目细节


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

pyauthenticator-0.2.0.tar.gz (23.3 kB 查看哈希值)

上传时间 源代码

构建分发

pyauthenticator-0.2.0-py3-none-any.whl (12.4 kB 查看哈希值)

上传时间 Python 3

支持