Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def provisioning_uri(self, name, issuer_name=None):
"""
Returns the provisioning URI for the OTP
This can then be encoded in a QR Code and used
to provision the Google Authenticator app
@param [String] name of the account
@return [String] provisioning uri
"""
return utils.build_uri(self.secret, name, issuer_name=issuer_name)
def get(self, req, secret):
"""GET request."""
result = bytes()
otp_uri_kwargs = {
key: value for (key, value) in req.GET.items() if key in (
"name", "issuer_name"
)
}
otp_uri_kwargs.setdefault("name", _("Untitled"))
with BytesIO() as stream:
generate_qrcode(
build_otp_uri(secret, **otp_uri_kwargs), image_factory=svg
).save(stream)
result = stream.getvalue()
return HttpResponse(
result, content_type=("image/svg+xml; charset={}").format(
settings.DEFAULT_CHARSET
)