Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for passing an image parameter in the otpauth URL. #123

Merged
merged 1 commit into from May 11, 2023

Conversation

timw6n
Copy link

@timw6n timw6n commented May 11, 2023

Some authenticator applications (most notably FreeOTP) support this additional parameter in the otpauth URL.

This MR adds it using basically the same logic as is used for the issuer parameter.

issuer = issuer.replace(':', '')
label = '{}:{}'.format(issuer, label)
urlencoded_params += '&issuer={}'.format(
quote(issuer)
) # encode issuer as per RFC 3986, not quote_plus

image = self._read_str_from_settings('OTP_TOTP_IMAGE')
if image:
urlencoded_params += "&image={}".format(quote(image, safe=':/'))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inclusion of : in the safe characters set is to match the tested logic I'm currently using to append this parameter to the URL string before making a QR code.

@psagers psagers merged commit 7d61333 into django-otp:master May 11, 2023
1 check passed
@timw6n
Copy link
Author

timw6n commented May 11, 2023

Thank you. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants