totp-cgi icon indicating copy to clipboard operation
totp-cgi copied to clipboard

Add "issuer" to the generated QRCODE

Open timwelch opened this issue 9 years ago • 1 comments

By default, the issuer field is not created, so when you look at your auth codes via the "google authenticator" application on a mobile device, it looks out of place. There is an option in the provisioning.conf file to add a Mask, but that also looks out of place and if the username is an email and a long one, it rolls off the screen. (screenshots of the before and after are attached). Is there a way to add these modifications to the codebase so that anyone can set the Issuer moving forward?

I have added the following variable to the /etc/totpcgi/provisioning.conf file:

# Added the Issuer variable to show properly in the Gauth application -TW
# Needs modifications to the index.cgi file as well
totp_issuer = PowerDMS_HQ

And then modified the /var/www/totpcgi-provisioning/index.cgi file like this, adding a line to retrieve the totp_issure variable, and a line to add the issuer field to the end of the URL that was generated. Obviously, it would be "nicer" to have this URL generated in the totp.provisioning_uri() function, but I didn't want to modify my production server that much:

def show_totp_page(config, user, gaus):
    # generate provisioning URI
    tpt = Template(config.get('secret', 'totp_user_mask'))
    totp_user = tpt.safe_substitute(username=user)
    totp_issuer = config.get('secret', 'totp_issuer')
    totp_qr_uri = gaus.totp.provisioning_uri(totp_user)
    totp_qr_uri = totp_qr_uri + "%26issuer=" + totp_issuer

This shows the use of the top_user_mask variable for PowerDMS_HQ in the config file.

img_2799

This shows the new variable for issuer and modified code used to create the real Issuer value for PowerDMS_HQ.

img_2800

timwelch avatar Apr 02 '15 15:04 timwelch

This was useful for a work project so I've opened pull request #37 for it

aaronknister avatar Aug 17 '15 23:08 aaronknister