django-otp-messagebird¶
This is a django-otp plugin that delivers tokens via MessageBird’s SMS service.
See django-otp for more information on the OTP framework.
Installation¶
django-otp-messagebird can be installed via pip:
pip install django-otp-messagebird
Once installed it should be added to INSTALLED_APPS after django_otp core:
INSTALLED_APPS = [
...
'django_otp',
'django_otp.plugins.otp_totp',
'django_otp.plugins.otp_hotp',
'django_otp.plugins.otp_static',
'otp_messagebird',
]
MessageBird SMS Devices¶
Admin¶
The following ModelAdmin
subclass is registered
with the default admin site. We recommend its use with custom admin sites as
well:
-
class
otp_messagebird.admin.
MessageBirdSMSDeviceAdmin
(model, admin_site)[source]¶ ModelAdmin
forMessageBirdSMSDevice
.
Settings¶
OTP_MESSAGEBIRD_ACCESS_KEY
Default: None
Your MessageBird API key.
OTP_MESSAGEBIRD_SMS_CHALLENGE_MESSAGE
Default: "Sent by SMS"
The message returned by
generate_challenge()
. This may contain
'{token}'
, which will be replaced by the token. This completely negates any
security benefit to the device, but it’s handy for development, especially in
combination with OTP_MESSAGEBIRD_NO_DELIVERY
.
OTP_MESSAGEBIRD_VOICE_CHALLENGE_MESSAGE
Default: "Phone call initiated"
The message returned by
generate_challenge()
. This may contain
'{token}'
, which will be replaced by the token. This completely negates any
security benefit to the device, but it’s handy for development, especially in
combination with OTP_MESSAGEBIRD_NO_DELIVERY
.
OTP_MESSAGEBIRD_FROM
Default: None
A string containing the sender of the SMS, with a maximum length of 11 characters.
OTP_MESSAGEBIRD_NO_DELIVERY
Default: False
Send tokens to the ‘otp_messagebird.models’ logger instead of delivering them by SMS. Useful for development.
OTP_MESSAGEBIRD_SMS_TOKEN_TEMPLATE
Default: "{token}"
A string template for generating the token SMS message. By default, this is just the
token itself, but you can customize it. The template will be rendered with
Python string formatting (template.format(token=token)
).
OTP_MESSAGEBIRD_VOICE_TOKEN_TEMPLATE
Default: "{token}"
A string template for generating the token voice message. By default, this is just the
token itself, but you can customize it. The template will be rendered with
Python string formatting (template.format(token=token)
).
OTP_MESSAGEBIRD_TOKEN_VALIDITY
Default: 30
The number of seconds for which a delivered token will be valid.
OTP_MESSAGEBIRD_THROTTLE_FACTOR
Default: 1
This controls the rate of throttling. The sequence of 1, 2, 4, 8… seconds is
multiplied by this factor to define the delay imposed after 1, 2, 3, 4…
successive failures. Set to 0
to disable throttling completely.
Changes¶
License¶
Copyright (c) 2012, Peter Sagerson Copyright (c) 2019, Arjan Schrijver All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.