Finalize authenticator with received SMS code

        :param activation_code: SMS code
        :type activation_code: str
        :raises: :class:`SteamAuthenticatorError`
549199
def finalize(self, activation_code):
        
        resp = self._send_request('FinalizeAddAuthenticator', {
            'steamid': self.backend.steam_id,
            'authenticator_time': int(time()),
            'authenticator_code': self.get_code(),
            'activation_code': activation_code,
        })

        if resp['status'] != EResult.TwoFactorActivationCodeMismatch and resp.get('want_more', False) and self._finalize_attempts:
            self.steam_time_offset += 30
            self._finalize_attempts -= 1
            self.finalize(activation_code)
            return
        elif not resp['success']:
            self._finalize_attempts = 5
            raise SteamAuthenticatorError("Failed to finalize authenticator. Error: %s" % repr(EResult(resp['status'])))

        self.steam_time_offset = int(resp['server_time']) - time()
157584
def receive_response(self, message, insecure=False):
		
		response = self.receive_message()
		if not response.is_response(message):
			raise OmapiError("received message is not the desired response")
		# signature already verified
		if response.authid != self.protocol.defauth and not insecure:
			raise OmapiError("received message is signed with wrong authenticator")
		return response
1104457
def registration_request_verify(registration_request):
    
    try:
        registration_request.verify()
    except MessageException as e:
        raise InvalidClientRegistrationRequest(str(e), registration_request, oauth_error='invalid_request') from e
813787
def _get_activation(self, inputs, activation, **kwargs):
        """"""
        if isinstance(activation, string_types):
            return symbol.Activation(inputs, act_type=activation, **kwargs)
        else:
            return activation(inputs, **kwargs)
1299798
def authorize(self, code):
        
        if self._authenticator.redirect_uri is None:
            raise InvalidInvocation("redirect URI not provided")
        self._request_token(
            code=code,
            grant_type="authorization_code",
            redirect_uri=self._authenticator.redirect_uri,
        )
571025
function(phoneAuthResult) {
        // Display the dialog that the code was sent.
        var container = component.getContainer();
        component.showProgressDialog(
            firebaseui.auth.ui.element.progressDialog.State.DONE,
            firebaseui.auth.soy2.strings.dialogCodeSent().toString());
        // Keep the dialog long enough to be seen before redirecting to code
        // entry page.
        var codeVerificationTimer = setTimeout(function() {
          component.dismissDialog();
          // Handle sign in with phone number code verification.
          component.dispose();
          firebaseui.auth.widget.handler.handle(
              firebaseui.auth.widget.HandlerName.PHONE_SIGN_IN_FINISH,
              app,
              container,
              phoneNumberValue,
              firebaseui.auth.widget.handler.RESEND_DELAY_SECONDS,
              phoneAuthResult);
        }, firebaseui.auth.widget.handler.SENDING_SUCCESS_DIALOG_DELAY);
        // On reset, clear timeout.
        app.registerPending(function() {
          // Dismiss dialog if still visible.
          if (component) {
            component.dismissDialog();
          }
          clearTimeout(codeVerificationTimer);
        });
      }
73332
def send_activation_email(self):
        
        context= {'user': self,
                  'protocol': get_protocol(),
                  'activation_days': defaults.ACCOUNTS_ACTIVATION_DAYS,
                  'activation_key': self.activation_key,
                  'site': Site.objects.get_current()}

        subject = ''.join(render_to_string(
                    'accounts/emails/activation_email_subject.txt',
                    context).splitlines())

        message = render_to_string(
                    'accounts/emails/activation_email_message.txt',
                    context)
        send_mail(subject,
                  message,
                  settings.DEFAULT_FROM_EMAIL,
                  [self.email,])
779797
def authenticate_token(self, load):
        '''
        
        '''
        token = self.get_tok(load['token'])

        # Bail if the token is empty or if the eauth type specified is not allowed
        if not token or token['eauth'] not in self.opts['external_auth']:
            log.warning('Authentication failure of type "token" occurred.')
            return False

        return token
977267
def validate_verification_code(self, device, code):
        
        device.update({
            'verificationCode': code,
            'trustBrowser': True
        })
        data = json.dumps(device)

        try:
            request = self.session.post(
                '%s/validateVerificationCode' % self._setup_endpoint,
                params=self.params,
                data=data
            )
        except PyiCloudAPIResponseError as error:
            if error.code == -21669:
                # Wrong verification code
                return False
            raise

        # Re-authenticate, which will both update the HSA data, and
        # ensure that we save the X-APPLE-WEBAUTH-HSA-TRUST cookie.
        self.authenticate()

        return not self.requires_2sa
1289002
def auth(self, encoded):
        
        message, signature = self.split(encoded)
        computed = self.sign(message)
        if not hmac.compare_digest(signature, computed):
            raise AuthenticatorInvalidSignature
462056
def send_activation(self, user, sender=None, **kwargs):
        
        if user.is_active:
            return False
        token = self.get_token(user)
        kwargs.update({"token": token})
        self.email_message(
            user, self.activation_subject, self.activation_body, sender, **kwargs
        ).send()
864317
def activate(request, activation_key=None):
    
    utils.activate_user(activation_key)
    # if not activated
    success_url = utils.get_settings('REGISTRATION_API_ACTIVATION_SUCCESS_URL')
    if success_url is not None:
        return HttpResponseRedirect(success_url)
1045618
def close_authenticator(self):
        """"""
        _logger.info("Shutting down CBS session on connection: %r.", self._connection.container_id)
        try:
            _logger.debug("Unlocked CBS to close on connection: %r.", self._connection.container_id)
            self._cbs_auth.destroy()
            _logger.info("Auth closed, destroying session on connection: %r.", self._connection.container_id)
            self._session.destroy()
        finally:
            _logger.info("Finished shutting down CBS session on connection: %r.", self._connection.container_id)
970492
def activate(self, target=None, **options):
        """"""
        log.debug("initiator options: {0}".format(options))

        self.did = options.get('did', None)
        self.nad = options.get('nad', None)
        self.gbi = options.get('gbi', '')[0:48]
        self.brs = min(max(0, options.get('brs', 2)), 2)
        self.lri = min(max(0, options.get('lri', 3)), 3)
        if self._acm is None or 'acm' in options:
            self._acm = bool(options.get('acm', True))

        assert self.did is None or 0 <= self.did <= 255
        assert self.nad is None or 0 <= self.nad <= 255

        ppi = (self.lri << 4) | (bool(self.gbi) << 1) | int(bool(self.nad))
        did = 0 if self.did is None else self.did
        atr_req = ATR_REQ(os.urandom(10), did, 0, 0, ppi, self.gbi)
        psl_req = PSL_REQ(did, (0, 9, 18)[self.brs], self.lri)
        atr_res = psl_res = None
        self.target = target

        if self.target is None and self.acm is True:
            log.debug("searching active communication mode target at 106A")
            tg = nfc.clf.RemoteTarget("106A", atr_req=atr_req.encode())
            try:
                self.target = self.clf.sense(tg, iterations=2, interval=0.1)
            except nfc.clf.UnsupportedTargetError:
                self._acm = False
            except nfc.clf.CommunicationError:
                pass
            else:
                if self.target:
                    atr_res = ATR_RES.decode(self.target.atr_res)
                else:
                    self._acm = None

        if self.target is None:
            log.debug("searching passive communication mode target at 106A")
            target = nfc.clf.RemoteTarget("106A")
            target = self.clf.sense(target, iterations=2, interval=0.1)
            if target and target.sel_res and bool(target.sel_res[0] & 0x40):
                self.target = target

        if self.target is None and self.brs > 0:
            log.debug("searching passive communication mode target at 212F")
            target = nfc.clf.RemoteTarget("212F", sensf_req=b'\0\xFF\xFF\0\0')
            target = self.clf.sense(target, iterations=2, interval=0.1)
            if target and target.sensf_res.startswith(b'\1\1\xFE'):
                atr_req.nfcid3 = target.sensf_res[1:9] + b'ST'
                self.target = target

        if self.target and self.target.atr_res is None:
            try:
                atr_res = self.send_req_recv_res(atr_req, 1.0)
            except nfc.clf.CommunicationError:
                pass
            if atr_res is None:
                log.debug("NFC-DEP Attribute Request failed")
                return None

        if self.target and atr_res:
            if self.brs > ('106A', '212F', '424F').index(self.target.brty):
                try:
                    psl_res = self.send_req_recv_res(psl_req, 0.1)
                except nfc.clf.CommunicationError:
                    pass
                if psl_res is None:
                    log.debug("NFC-DEP Parameter Selection failed")
                    return None
                self.target.brty = ('212F', '424F')[self.brs-1]

            self.rwt = (4096/13.56E6
                        * 2**(atr_res.wt if atr_res.wt < 15 else 14))
            self.miu = (atr_res.lr-3 - int(self.did is not None)
                        - int(self.nad is not None))
            self.gbt = atr_res.gb
            self.pni = 0

            log.info("running as " + str(self))
            return self.gbt
849010
def send_verification_code(self, device):
        
        data = json.dumps(device)
        request = self.session.post(
            '%s/sendVerificationCode' % self._setup_endpoint,
            params=self.params,
            data=data
        )
        return request.json().get('success', False)
531374
async def _registration_completed(self, message):
        
        if not self.registered:
            # Re-enable throttling.
            self.registered = True
            self.connection.throttle = True

            target = message.params[0]
            fakemsg = self._create_message('NICK', target, source=self.nickname)
            await self.on_raw_nick(fakemsg)
1187881
def authenticate_identify(self, api_token, override=True):
        
        if (self.context.has_auth_params('Gem-Identify') and not override):
            raise OverrideError('Gem-Identify')

        if (not api_token or
            not self.context.authorize('Gem-Identify', api_token=api_token)):
            raise AuthUsageError(self.context, 'Gem-Identify')

        return True