Resets the API key for the specified user, or if no user is specified,
        for the current user. Returns the newly-created API key.

        Resetting an API key does not invalidate any authenticated sessions,
        nor does it revoke any tokens.
432391
def reset_api_key(self, user=None):
        
        if user is None:
            user_id = utils.get_id(self)
        else:
            user_id = utils.get_id(user)
        uri = "users/%s/OS-KSADM/credentials/" % user_id
        uri += "RAX-KSKEY:apiKeyCredentials/RAX-AUTH/reset"
        resp, resp_body = self.method_post(uri)
        return resp_body.get("RAX-KSKEY:apiKeyCredentials", {}).get("apiKey")
1329176
def destroy_api_token
    unless current_user
      bounce_user
      return
    end

    api_token = Tokens::Api.where(user_id: current_user.id).first
    if api_token
      api_token.destroy
      respond_to do |format|
        format.html do
          redirect_to api_token_session_url,
                      notice: 'Your old API token has been revoked'
        end
        format.json { render json: {} }
      end
    else
      respond_to do |format|
        format.html do
          redirect_to api_token_session_url,
                      alert: 'You had no old API token to revoke'
        end
        format.json { head :not_found }
      end
    end
  end
980172
def reset!
      self.api_username = DEFAULT_API_USERNAME
      self.api_key      = DEFAULT_API_KEY
      self.adapter      = DEFAULT_ADAPTER
      self.endpoint     = DEFAULT_ENDPOINT
      self.user_agent   = DEFAULT_USER_AGENT
      self.raise_errors = DEFAULT_RAISE_ERRORS
      self
    end
455542
def authenticate(self, api_key):
        """"""
        self._api_key = api_key

        # Attach auth to session.
        self._session.auth = ('', self._api_key)

        return self._verify_api_key()
391013
def process_reset_session(session, connection_initialize = false)
      # set active command sequence info
      session[:cmd_sequence] = connection_initialize ? :CMD_HELO : :CMD_RSET
      # drop any auth challenge
      session[:auth_challenge] = {}
      # test existing of :ctx hash
      session[:ctx] || session[:ctx] = {}
      # reset server values (only on connection start)
      if connection_initialize
        # create or rebuild :ctx hash
        session[:ctx].merge!(
          server: {
            local_host: '',
            local_ip: '',
            local_port: '',
            local_response: '',
            remote_host: '',
            remote_ip: '',
            remote_port: '',
            helo: '',
            helo_response: '',
            connected: '',
            exceptions: 0,
            authorization_id: '',
            authentication_id: '',
            authenticated: '',
            encrypted: ''
          }
        )
      end
      # reset envelope values
      session[:ctx].merge!(
        envelope: {
          from: '',
          to: [],
          encoding_body: '',
          encoding_utf8: ''
        }
      )
      # reset message data
      session[:ctx].merge!(
        message: {
          received: -1,
          delivered: -1,
          bytesize: -1,
          headers: '',
          crlf: "\r\n",
          data: ''
        }
      )
    end
1042151
def reset_key(self):
        
        new_key = self.client.reset_app_key(self.get('uuid'))
        self.data['key'] = new_key
        return new_key
178217
def authenticate_key(api_key):
    
    user_model = Query()
    user = db.search(user_model.api_key == api_key)[0]
    if user:
        return user['username']
    return False
1161878
async def reset_user_password(self, username):
        
        user_facade = client.UserManagerFacade.from_connection(
            self.connection())
        entity = client.Entity(tag.user(username))
        results = await user_facade.ResetPassword([entity])
        secret_key = results.results[0].secret_key
        return await self.get_user(username, secret_key=secret_key)
142021
def current_api_key():
    
    if app.config.get('IGNORE_AUTH'):
        return models.ApiKey(
            id='anonymous_superuser',
            secret='',
            superuser=True)

    ops = _get_api_key_ops()
    api_key = ops.get()
    logging.debug('Authenticated as API key=%r', api_key.id)

    return api_key
1354687
def reset
      self.tap do |c|
        c.base_uri   = DEFAULT_BASE_URI
        c.endpoint   = DEFAULT_END_POINT
        c.api_secret = DEFAULT_API_SECRET
        c.api_key    = DEFAULT_API_KEY
      end
    end
109279
def reset_password(self, token):
        
        expired, invalid, user = \
            self.security_utils_service.reset_password_token_status(token)
        if invalid:
            self.flash(
                _('flask_unchained.bundles.security:flash.invalid_reset_password_token'),
                category='error')
            return self.redirect('SECURITY_INVALID_RESET_TOKEN_REDIRECT')
        elif expired:
            self.security_service.send_reset_password_instructions(user)
            self.flash(_('flask_unchained.bundles.security:flash.password_reset_expired',
                         email=user.email,
                         within=app.config.SECURITY_RESET_PASSWORD_WITHIN),
                       category='error')
            return self.redirect('SECURITY_EXPIRED_RESET_TOKEN_REDIRECT')

        spa_redirect = app.config.SECURITY_API_RESET_PASSWORD_HTTP_GET_REDIRECT
        if request.method == 'GET' and spa_redirect:
            return self.redirect(spa_redirect, token=token, _external=True)

        form = self._get_form('SECURITY_RESET_PASSWORD_FORM')
        if form.validate_on_submit():
            self.security_service.reset_password(user, form.password.data)
            self.security_service.login_user(user)
            self.after_this_request(self._commit)
            self.flash(_('flask_unchained.bundles.security:flash.password_reset'),
                       category='success')
            if request.is_json:
                return self.jsonify({'token': user.get_auth_token(),
                                     'user': user})
            return self.redirect('SECURITY_POST_RESET_REDIRECT_ENDPOINT',
                                 'SECURITY_POST_LOGIN_REDIRECT_ENDPOINT')

        elif form.errors and request.is_json:
            return self.errors(form.errors)

        return self.render('reset_password',
                           reset_password_form=form,
                           reset_password_token=token,
                           **self.security.run_ctx_processor('reset_password'))
410941
def jwt_get_secret_key(payload=None):
    
    User = get_user_model()  # noqa
    if api_settings.JWT_GET_USER_SECRET_KEY:
        user = User.objects.get(pk=payload.get('user_id'))
        key = str(api_settings.JWT_GET_USER_SECRET_KEY(user))
        return key

    return api_settings.JWT_SECRET_KEY
296070
def reset!
      @options = {}
      self.client_id     = DEFAULT_CLIENT_ID
      self.client_secret = DEFAULT_CLIENT_SECRET
      self.adapter       = DEFAULT_ADAPTER
      self.endpoint      = DEFAULT_ENDPOINT
      self.user_agent    = DEFAULT_USER_AGENT
      self.token_type    = DEFAULT_TOKEN_TYPE
      self.debug         = ENV['DEBUG']
      self
    end
1369100
public function resetAction(Request $request, $token)
    {
        if ($this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
            return new RedirectResponse($this->get('router')->generate('sonata_admin_dashboard'));
        }

        /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
        $formFactory = $this->get('fos_user.resetting.form.factory');
        /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
        $userManager = $this->get('fos_user.user_manager');
        /** @var $loginManager \FOS\UserBundle\Security\LoginManagerInterface */
        $loginManager = $this->get('fos_user.security.login_manager');

        $user = $userManager->findUserByConfirmationToken($token);

        $firewallName = $this->container->getParameter('fos_user.firewall_name');

        if (null === $user) {
            throw new NotFoundHttpException(sprintf('The user with "confirmation token" does not exist for value "%s"', $token));
        }

        if (!$user->isPasswordRequestNonExpired($this->container->getParameter('fos_user.resetting.token_ttl'))) {
            return new RedirectResponse($this->generateUrl('sonata_user_admin_resetting_request'));
        }

        $form = $formFactory->createForm();
        $form->setData($user);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $user->setConfirmationToken(null);
            $user->setPasswordRequestedAt(null);
            $user->setEnabled(true);

            $message = $this->get('translator')->trans('resetting.flash.success', [], 'FOSUserBundle');
            $this->addFlash('success', $message);
            $response = new RedirectResponse($this->generateUrl('sonata_admin_dashboard'));

            try {
                $loginManager->logInUser($firewallName, $user, $response);
                $user->setLastLogin(new \DateTime());
            } catch (AccountStatusException $ex) {
                // We simply do not authenticate users which do not pass the user
                // checker (not enabled, expired, etc.).
                if ($this->has('logger')) {
                    $this->get('logger')->warning(sprintf(
                        'Unable to login user %d after password reset',
                        $user->getId())
                    );
                }
            }

            $userManager->updateUser($user);

            return $response;
        }

        return $this->render('NetworkingInitCmsBundle:Admin:Security/Resetting/reset.html.twig', [
            'token' => $token,
            'form' => $form->createView(),
            'base_template' => $this->get('sonata.admin.pool')->getTemplate('layout'),
            'admin_pool' => $this->get('sonata.admin.pool'),
        ]);
    }
829060
def authenticate(self, username=None, password=None):
        
        data = api_client.authenticate(username, password)
        if not data:
            return

        return User(
            data.get('pk'), data.get('token'), data.get('user_data')
        )
20381
def reset
      self.user_agent         = DEFAULT_USER_AGENT
      self.environment        = DEFAULT_ENVIRONMENT
      self.api_version        = DEFAULT_API_VERSION
      self.server_url         = DEFAULT_SERVER_URL
      self.client_name        = DEFAULT_CLIENT_NAME
      self.client_key         = DEFAULT_CLIENT_KEY
      self.connection_options = DEFAULT_CONNECTION_OPTIONS
      self.middleware         = DEFAULT_MIDDLEWARE
      self.accept             = DEFAULT_ACCEPT
      self
    end
662544
def refresh_token(token, session=None):
    
    session = session or HTTP_SESSION
    refresh_data = dict(
        refresh_token=token.refresh_token,
        client_id=token.consumer_key,
        client_secret=token.consumer_secret,
        grant_type='refresh_token'
    )
    resp = session.post(REFRESH_TOKEN_URL, data=refresh_data)
    resp_json = resp.json()
    if 'error' in resp_json:
        message = resp_json['error']
        description = resp_json.get('error_description', '')
        if any(description):
            message = u'{}: {}'.format(message, description)
        raise OAuthTokenExpiredError(message)
    return OAuthToken(
        access_token=resp_json['access_token'],
        refresh_token=token.refresh_token,
        consumer_key=token.consumer_key,
        consumer_secret=token.consumer_secret
    )