Return the currently-valid MFA token for this application.
185815
def get_mfa(self):
        """"""
        token = str(self.totp.now())
        # PyOTP doesn't pre-pad tokens shorter than 6 characters
        # ROTP does, so we have to.
        while len(token) < 6:
            token = '0{}'.format(token)
        return token
854098
def acquire_code(args, session, session3):
    """"""
    serial_number = find_mfa_for_user(args.serial_number, session, session3)
    if not serial_number:
        print("There are no MFA devices associated with this user.",
              file=sys.stderr)
        return None, None, USER_RECOVERABLE_ERROR

    token_code = args.token_code
    if token_code is None:
        while token_code is None or len(token_code) != 6:
            token_code = getpass.getpass("MFA Token Code: ")
    return serial_number, token_code, OK
108217
def sign(self):
        """"""
        self.verify_integrity()
        
        if session.get('u2f_sign_required', False):
            if request.method == 'GET':
                response = self.get_signature_challenge()

                if response['status'] == 'ok':
                    return jsonify(response), 200
                else:
                    return jsonify(response), 404

            elif request.method == 'POST':
                response = self.verify_signature(request.json)

                if response['status'] == 'ok':
                    return jsonify(response), 201
                else:
                    return jsonify(response), 400

        return jsonify({'status': 'failed', 'error': 'Unauthorized!'}), 401
850253
def authenticate(self):
        """"""
        if self.__token:
            try:
                resp = self._refresh_token()
            except exceptions.TVDBRequestException as err:
                # if a 401 is the cause try to login
                if getattr(err.response, 'status_code', 0) == 401:
                    resp = self._login()
                else:
                    raise
        else:
            resp = self._login()

        self.__token = resp.get('token')
        self._token_timer = timeutil.utcnow()
37272
def authenticate_credentials(self, token):
        '''
        
        '''
        msg = _('Invalid token.')
        token = token.decode("utf-8")
        for auth_token in AuthToken.objects.filter(
                token_key=token[:CONSTANTS.TOKEN_KEY_LENGTH]):
            if self._cleanup_token(auth_token):
                continue

            try:
                digest = hash_token(token, auth_token.salt)
            except (TypeError, binascii.Error):
                raise exceptions.AuthenticationFailed(msg)
            if compare_digest(digest, auth_token.digest):
                if knox_settings.AUTO_REFRESH and auth_token.expiry:
                    self.renew_token(auth_token)
                return self.validate_user(auth_token)
        raise exceptions.AuthenticationFailed(msg)
759053
def wallet(self):
        """"""
        if not hasattr(self, '_wallet'):
            wallet_resource = self.resource.default_wallet.get()
            self._wallet = Wallet(wallet_resource, self.client)
        return self._wallet
10455
def look(self):
        """"""
        old_token = next(self)
        result = self.current
        self.push(result)
        self.current = old_token
        return result
651244
def deactivate_mfa_device(self, user_name, serial_number):
        """"""
        user = self.get_user(user_name)
        if serial_number not in user.mfa_devices:
            raise IAMNotFoundException(
                "Device {0} not found".format(serial_number)
            )

        user.deactivate_mfa_device(serial_number)
997179
def get_csrf_token():
    """"""
    url = get_url("/simplecsrf/token.json")
    r = s.get(url=url, headers=DEFAULT_ORIGIN)
    return r.json()["token"]
562468
def _verify_auth(self):
        '''
        
        '''

        return self.token and bool(self.application.auth.get_tok(self.token))
332972
def auth_get_token(self, check_state=True):
		''
		res = self.auth_access_data_raw = yield self._auth_token_request()
		defer.returnValue(self._auth_token_process(res, check_state=check_state))
36843
def _get_csrf_token(self):
        """"""
        from bs4 import BeautifulSoup
        home_response = self.session.get(self.URLS['login'])
        self._log('Home', home_response)
        assert home_response.status_code == 200, \
            'Could not load Easyname login page.'

        html = BeautifulSoup(home_response.content, 'html.parser')
        self._log('Home', html)
        csrf_token_field = html.find('input', {'id': 'loginxtoken'})
        assert csrf_token_field is not None, 'Could not find login token.'
        return csrf_token_field['value']
379931
def access_token():
    """"""
    client = Client.query.filter_by(
        client_id=request.form.get('client_id')
    ).first()

    if not client:
        abort(404)

    if not client.is_confidential and \
            'client_credentials' == request.form.get('grant_type'):
        error = InvalidClientError()
        response = jsonify(dict(error.twotuples))
        response.status_code = error.status_code
        abort(response)

    # Return None or a dictionary. Dictionary will be merged with token
    # returned to the client requesting the access token.
    # Response is in application/json
    return None
276010
def authenticate(self):
        """"""
        if request.headers.get('Authorization', '').startswith('Negotiate '):
            in_token = base64.b64decode(request.headers['Authorization'][10:])

            try:
                creds = current_app.extensions['gssapi']['creds']
            except KeyError:
                raise RuntimeError('flask-gssapi not configured for this app')

            ctx = gssapi.SecurityContext(creds=creds, usage='accept')

            out_token = ctx.step(in_token)

            if ctx.complete:
                username = ctx._inquire(initiator_name=True).initiator_name
                return str(username), out_token

        return None, None
562810
def token(self):
        
        if self._token is None or \
           datetime.datetime.now() >= self._token_expires_on:
            if self._referer_url is None:
                self._generateForTokenSecurity(username=self._username,
                                           password=self._password,
                                           tokenUrl=self._token_url)
            else:
                self._generateForTokenSecurity(username=self._username,
                                               password=self._password,
                                               tokenUrl=self._token_url,
                                               client="referer")
        return self._token
1058144
def authenticated(f):
    """"""
    @wraps(f)
    def new_f(self, *args, **kwargs):
        if not self.nova_client.client.auth_token:
            self.authenticate()
        return f(self, *args, **kwargs)
    return new_f
724307
def get_user_token():
    """"""
    if not hasattr(stack.top, 'current_user'):
        return ''
    current_user = stack.top.current_user
    return current_user.get('token', '')