コード例 #1
0
ファイル: authenticator.py プロジェクト: liang0/sentry-1
    def send_text(self, for_enrollment=False, request=None):
        ctx = {"code": self.make_otp().generate_otp()}

        if for_enrollment:
            text = _("%(code)s is your Sentry two-factor enrollment code. "
                     "You are about to set up text message based two-factor "
                     "authentication.")
        else:
            text = _("%(code)s is your Sentry authentication code.")

        if request is not None:
            text = u"%s\n\n%s" % (text, _("Requested from %(ip)s"))
            ctx["ip"] = request.META["REMOTE_ADDR"]

        return send_sms(text % ctx, to=self.phone_number)
コード例 #2
0
    def send_text(self, for_enrollment=False, request=None):
        ctx = {'code': self.make_otp().generate_otp()}

        if for_enrollment:
            text = _('%(code)s is your Sentry two-factor enrollment code. '
                     'You are about to set up text message based two-factor '
                     'authentication.')
        else:
            text = _('%(code)s is your Sentry authentication code.')

        if request is not None:
            text = u'%s\n\n%s' % (text, _('Requested from %(ip)s'))
            ctx['ip'] = request.META['REMOTE_ADDR']

        return send_sms(text % ctx, to=self.phone_number)
コード例 #3
0
ファイル: authenticator.py プロジェクト: zmyer/sentry
    def send_text(self, for_enrollment=False, request=None):
        ctx = {'code': self.make_otp().generate_otp()}

        if for_enrollment:
            text = _('%(code)s is your Sentry two-factor enrollment code. '
                     'You are about to set up text message based two-factor '
                     'authentication.')
        else:
            text = _('%(code)s is your Sentry authentication code.')

        if request is not None:
            text = u'%s\n\n%s' % (text, _('Requested from %(ip)s'))
            ctx['ip'] = request.META['REMOTE_ADDR']

        return send_sms(text % ctx, to=self.phone_number)
コード例 #4
0
    def send_text(self, for_enrollment=False, request=None):
        ctx = {"code": self.make_otp().generate_otp()}

        if for_enrollment:
            text = _(
                "%(code)s is your Sentry two-factor enrollment code. "
                "You are about to set up text message based two-factor "
                "authentication."
            )
        else:
            text = _("%(code)s is your Sentry authentication code.")

        if request is not None:
            text = u"%s\n\n%s" % (text, _("Requested from %(ip)s"))
            ctx["ip"] = request.META["REMOTE_ADDR"]

        return send_sms(text % ctx, to=self.phone_number)
コード例 #5
0
ファイル: sms.py プロジェクト: waterdrops/sentry
    def send_text(self, for_enrollment=False, request=None):
        ctx = {"code": self.make_otp().generate_otp()}

        if for_enrollment:
            text = _("%(code)s is your Sentry two-factor enrollment code. "
                     "You are about to set up text message based two-factor "
                     "authentication.")
        else:
            text = _("%(code)s is your Sentry authentication code.")

        if request is not None:
            text = "{}\n\n{}".format(text, _("Requested from %(ip)s"))
            ctx["ip"] = request.META["REMOTE_ADDR"]

        if request and request.user.is_authenticated:
            user_id = request.user.id
        elif self.authenticator:
            user_id = self.authenticator.user_id
        else:
            user_id = None

        logger.info(
            "mfa.twilio-request",
            extra={
                "ip":
                request.META["REMOTE_ADDR"] if request else None,
                "user_id":
                user_id,
                "authenticator_id":
                self.authenticator.id if self.authenticator else None,
                "phone_number":
                self.phone_number,
            },
        )

        return send_sms(text % ctx, to=self.phone_number)