Package: django-phone-verify
A Django app to support phone number verification using the security code sent via SMS.Salient FeaturesLet’s devs verify phone numbers via SMS.Extensibility to provide tokens with varying lengths.Comes with Twilio and Nexmo already integrated.Set expiration time on tokens.Provides an interface for writing custom SMS sending backend for easy extensibility.Does not mess up with existingAUTH_USER_MODELat all.Can be used for several potential use-cases, and not just auth.Provides ready endpoints for sending SMS and verification (Seeapi_endpoints.rst).Installationpipinstalldjango-phone-verifyConfigurationAdd app toINSTALLED_APPS# In settings.py:# Add app to `INSTALLED_APPS`INSTALLED_APPS=[..."phone_verify",]Add settings for Phone Verify as you desire:# In settings.py# Add settings for phone_verify to workPHONE_VERIFICATION={"BACKEND":"phone_verify.backends.twilio.TwilioBackend","OPTIONS":{"SID":"fake","SECRET":"fake","FROM":"+14755292729","SANDBOX_TOKEN":"123456",},"TOKEN_LENGTH":6,"MESSAGE":"Welcome to{app}! Please use security code{security_code}to proceed.","APP_NAME":"Phone Verify","SECURITY_CODE_EXPIRATION_TIME":3600,# In seconds only"VERIFY_SECURITY_CODE_ONLY_ONCE":False,# If False, then a security code can be used multiple times for verification}UsageTo explore more about how to use, integrate and leverage the existing functionality ofDjango Phone Verify, have a look atusage.rstNote:Django Phone Verifyalso providesNexmoas a backend service other thanTwilio. To switch toNexmo, replaceBACKENDwithin yourPHONE_VERIFICATIONsetting withphone_verify.backends.nexmo.NexmoBackendand defineKEYwithinOPTIONSofPHONE_VERIFICATIONsetting, with your Nexmo API key, in place of already availableSID.CompatibilityPython 3.6+Django 2.1+Django REST Framework 3.9+ContributingNo code is bug-free and I’m sure this app will have bugs. If you find any bugs, please create an issue on GitHub.LicenceGPLv3Release Notes[3.0.0]AddedSupport for Django 4.x.Support for Django 3.2.ChangedMethodphone_verify.backends.nexmo.NexmoBackend.send_smschanges parameter name fromnumberstonumberto be consistent with rest of the inherited classes.[2.0.1]AddedSupport for Python 3.8 & Python 3.9.CI tests for Py{36,37,38,39}-Django{20,21,22,30,31}.ChangedFixed issuegenerate_session_tokento handle cases in Py38, Py39 when thesession_tokenis alreadystringinstead ofbytes.[2.0.0]NOTE: The previous version of this library provided thesecurity_codein the JWTsession_token. You would have to re-verifyphone_numbersinthisversion to ensure they are authentically verified.AddedTests added to provide 100% coverage on the package.Addnexmo.errors.ClientErroras exception class inphone_verify.backends.nexmo.NexmoBackend&phone_verify.backends.nexmo.NexmoSandboxBackend.ChangedMethod signature changed forphone_verify.backends.BaseBackend.generate_session_token. It now accepts onlyphone_numberinstead of combination ofphone_numberandsecurity_code.Remove thesecurity_codefrom JWTsession_tokento avoid leaking information.Add nonce insession_tokento generate unique tokens for eachphone_number.Fixes call tophone_verify.backends.nexmo.NexmoBackend.send_smsmethod.[1.1.0]AddedSupportNexmoas a backend service along withTwilio.Add docs for writing a custom backend.ChangedUpdatebackends.base.BaseBackend.validate_security_codeto usesave()instead ofupdate()to allow Django to emit itspost_save()signal.[1.0.0]AddedAdd coverage report throughcoveralls.Support for One-Time Passwords (OTP) usingVERIFY_SECURITY_CODE_ONLY_ONCEasTruein the settings.Script to support makemigrations for development.BaseBackendstatus now haveSECURITY_CODE_VERIFIEDandSESSION_TOKEN_INVALIDstatus to support new states.ChangedRenameTWILIO_SANDBOX_TOKENtoSANDBOX_TOKEN.Fix signature forsend_bulk_smsmethod inTwilioBackendandTwilioSandboxBackend.Response for/api/phone/registercontains keysession_tokeninstead ofsession_code.Request payload for/api/phone/verifynow expectssession_tokenkey instead ofsession_code.Response for/api/phone/verifynow sends additional response ofSecurity code is already verifiedin caseVERIFY_SECURITY_CODE_ONLY_ONCEis set toTrue.Renameotptosecurity_codein code and docs to be more consistent.RenameBaseBackendstatus fromVALID,INVALID,EXPIREDtoSECURITY_CODE_VALID,SECURITY_CODE_INVALID, andSECURITY_CODE_EXPIREDrespectively.Renamesession_codetosession_tokento be consistent in code and naming across the app.Rename servicesend_otp_and_generate_session_codetosend_security_code_and_generate_session_token.Rename methodBaseBackend.generate_tokentoBaseBackend.generate_security_code.Rename methodcreate_otp_and_session_tokentocreate_security_code_and_session_token.Rename methodBaseBackend.validate_tokentoBaseBackend.validate_security_codewith an additional parameter ofsession_token.[0.2.0]Addedpre-commit-configto maintain code quality using black and other useful tools.Docs for integration and usage inusage.rst.Tox for testing onpy{37}-django{20,21,22}.Travis CI for testing builds.ChangedConvert*.mddocs to reST Markup.Fix issue with installing required package dependencies viainstall_requires.[0.1.1]AddedREADME and documentation of API endpoints.setup.cfgto manage coverage.phone_verifyapp including backends, requirements, tests.Initial app setup.