#!/usr/bin/env python # # This script requires the pytop module. # You can get it with "pip install pyotp" # Source: https://github.com/pyotp/pyotp # # This script generates a key for a user and stores the key in the Perforce server. import pyotp import os import re import sys import subprocess # This user should have at least admin access and an unlimited login p4admin = os.environ['P4USER'] # This is the Perforce server where user's password and keys are stored. authserver = "localhost:1667" domain = "company.com" user = sys.argv[1] key = pyotp.random_base32() os.system("p4 -u %s -p %s key %s %s" % (p4admin, authserver, user, key)) totp = pyotp.TOTP(key) uri = totp.provisioning_uri("%s@%s" % (user, domain)) print("http://chart.apis.google.com/chart?cht=qr&chs=250x250&chl=%s" % uri) print("Key: %s" % key)
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19278 | trina | "Forking branch Main of perforce-software-sdp to trina-sdp." | ||
//guest/perforce_software/sdp/main/Server/Unix/p4/common/bin/triggers/otpkeygen.py | |||||
#1 | 17315 | C. Thomas Tyler |
Released SDP/MultiArch/2016.1/17297 (2016/02/03). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/triggers/otpkeygen.py | |||||
#1 | 17250 | Russell C. Jackson (Rusty) |
Auth trigger and script to generate otp QR code for using Google Auth. Looks good to me. Not sure how to test in our existing test suite? |