Controls the current user credentials, such as status, role, password hash...
195099
protected function controlAccessCredentials()
    {
        if (empty($this->current_user['hash']) || empty($this->current_user['status'])) {
            $this->session->delete();
            $this->url->redirect('login');
        }

        if (!gplcart_string_equals($this->current_user['hash'], $this->user->getSession('hash'))) {
            $this->session->delete();
            $this->url->redirect('login');
        }

        if ($this->current_user['role_id'] != $this->user->getRoleId()) {
            $this->session->delete();
            $this->url->redirect('login');
        }
    }
564676
def credentials=(string)
      user, pass = string.split(":")
      dcp = HtmlUnit::DefaultCredentialsProvider.new
      dcp.addCredentials(user, pass)
      @webclient.setCredentialsProvider(dcp)
    end
721157
def index(credentials=None):
        """"""
        user, oauth_access_token = parsecredentials(credentials)
        if not settings.ADMINS or user not in settings.ADMINS:
            return flask.make_response('You shall not pass!!! You are not an administrator!',403)

        usersprojects = {}
        totalsize = {}
        for f in glob.glob(settings.ROOT + "projects/*"):
            if os.path.isdir(f):
                u = os.path.basename(f)
                usersprojects[u], totalsize[u] = getprojects(u)
                usersprojects[u].sort()

        return withheaders(flask.make_response(flask.render_template('admin.html',
                version=VERSION,
                system_id=settings.SYSTEM_ID,
                system_name=settings.SYSTEM_NAME,
                system_description=settings.SYSTEM_DESCRIPTION,
                system_author=settings.SYSTEM_AUTHOR,
                system_version=settings.SYSTEM_VERSION,
                system_email=settings.SYSTEM_EMAIL,
                user=user,
                url=getrooturl(),
                usersprojects = sorted(usersprojects.items()),
                totalsize=totalsize,
                allow_origin=settings.ALLOW_ORIGIN,
                oauth_access_token=oauth_encrypt(oauth_access_token)
        )), "text/html; charset=UTF-8", {'allow_origin':settings.ALLOW_ORIGIN})
246903
def set_credentials(req, creds)
      return unless creds

      if String === creds
        req.add_field('Cookie', creds)
      elsif creds[:username] && creds[:password]
        req.basic_auth(creds[:username], creds[:password])
      end
    end
62687
def credentials(username, password, digest = false)
      self.username = username
      self.password = password
      self.digest = digest
    end
498561
def _store_credentials(self, username, password, remember=False):
        """"""
        if username and password and remember:
            CONF.set('main', 'report_error/username', username)
            try:
                keyring.set_password('github', username, password)
            except Exception:
                if self._show_msgbox:
                    QMessageBox.warning(self.parent_widget,
                                        _('Failed to store password'),
                                        _('It was not possible to securely '
                                          'save your password. You will be '
                                          'prompted for your Github '
                                          'credentials next time you want '
                                          'to report an issue.'))
                remember = False
        CONF.set('main', 'report_error/remember_me', remember)
904761
def _get_credentials():
    '''
    
    '''
    ret = {
        'user': False,
        'passwd': False
    }

    # Loop through opts, grains, and pillar
    # Return the first acceptable configuration found
    for item in ret:
        for struct in [__opts__, __grains__, __pillar__]:
            # Look for the config key
            # Support old-style config format and new
            for config_key in __valid_configs[item]:
                value = salt.utils.data.traverse_dict_and_list(
                    struct,
                    config_key,
                    None)
                if value:
                    ret[item] = value
                    break
    return ret['user'], ret['passwd']
1220969
def set_credentials(username, api_key=None, password=None, region=None,
        tenant_id=None, authenticate=True):
    
    global regions, services
    pw_key = password or api_key
    region = _safe_region(region)
    tenant_id = tenant_id or settings.get("tenant_id")
    identity.set_credentials(username=username, password=pw_key,
            tenant_id=tenant_id, region=region, authenticate=authenticate)
    regions = tuple(identity.regions)
    services = tuple(identity.services.keys())
    connect_to_services(region=region)
437905
protected function set_default_credentials() {
		$running_servers = Singleton::get_instance( 'Base', $this )->get_running_git_servers();
		$set_credentials = false;
		if ( ! isset( static::$options['gitea_access_token'] ) ) {
			static::$options['gitea_access_token'] = null;
			$set_credentials                       = true;
		}
		if ( empty( static::$options['gitea_access_token'] ) &&
			in_array( 'gitea', $running_servers, true )
		) {
			$this->gitea_error_notices();
		}

		if ( $set_credentials ) {
			add_site_option( 'github_updater', static::$options );
		}
	}
804439
def change_password
    unless current_user
      bounce_user
      return
    end

    @credential = current_user.credentials.
                               where(type:  'Credentials::Password').first
    if @credential
      # An old password is set, must verify it.
      if @credential.check_password params[:credential][:old_password]
        success = @credential.update_attributes change_password_params
      else
        success = false
        flash[:alert] = 'Incorrect old password. Please try again.'
      end
    else
      @credential = Credentials::Password.new change_password_params
      @credential.user = current_user
      success = @credential.save
    end
    respond_to do |format|
      if success
        format.html do
          redirect_to session_url, notice: 'Password updated'
        end
        format.json { head :no_content }
      else
        format.html { render action: :password_change }
        format.json { render json: { error: :invalid } }
      end
    end
  end
1261189
def do_access_control(self):
        """"""
        from abilian.services import get_service

        if current_app.testing and current_app.config.get("NO_LOGIN"):
            # Special case for tests
            user = User.query.get(0)
            login_user(user, force=True)
            return

        state = self.app_state
        user = unwrap(current_user)

        # Another special case for tests
        if current_app.testing and getattr(user, "is_admin", False):
            return

        security = get_service("security")
        user_roles = frozenset(security.get_roles(user))
        endpoint = request.endpoint
        blueprint = request.blueprint

        access_controllers = []
        access_controllers.extend(state.bp_access_controllers.get(None, []))

        if blueprint and blueprint in state.bp_access_controllers:
            access_controllers.extend(state.bp_access_controllers[blueprint])

        if endpoint and endpoint in state.endpoint_access_controllers:
            access_controllers.extend(state.endpoint_access_controllers[endpoint])

        for access_controller in reversed(access_controllers):
            verdict = access_controller(user=user, roles=user_roles)
            if verdict is None:
                continue
            elif verdict is True:
                return
            else:
                if user.is_anonymous:
                    return self.redirect_to_login()
                raise Forbidden()

        # default policy
        if current_app.config.get("PRIVATE_SITE") and user.is_anonymous:
            return self.redirect_to_login()
299540
protected function setDataAccessSettings()
    {
        $access = $this->getData('settings.access');

        if (is_array($access)) {

            $string = '';

            foreach ($access as $role_id => $patterns) {
                foreach ($patterns as $pattern) {
                    $string .= "$role_id $pattern" . PHP_EOL;
                }
            }

            $this->setData('settings.access', trim($string));
        }
    }
325728
def update_credentials(self, password):
        
        data = {
            'Password': password,
        }
        self._conn.patch(self.path, data=data)
1260385
def setCredentialValues(self, username=None, password=None, public_key=None, private_key=None, new=False):
        """"""

        credentials_base = "disk.0.os.credentials."
        if new:
            credentials_base = "disk.0.os.credentials.new."

        if username:
            self.setValue(credentials_base + "username", username)
        if password:
            self.setValue(credentials_base + "password", password)
        if public_key:
            self.setValue(credentials_base + "public_key", public_key)
        if private_key:
            self.setValue(credentials_base + "private_key", private_key)
386279
def prompt_for_credentials(username):
    '''

    '''
    message = 'Enter password for user "{0}": '.format(username)
    password = getpass.getpass(message)
    if not password:
        raise ValueError(
            'No credentials provided for user "{0}"'.format(username)
        )
    return password
976691
def setUserKeyCredentials(self, username, public_key=None, private_key=None):
        """"""

        self.setCredentialValues(username=username, public_key=public_key, private_key=private_key)
493089
def check_credentials(self):
        
        if self.username is None or self.password is None:
            raise DistlibException('username and password must be set')
        pm = HTTPPasswordMgr()
        _, netloc, _, _, _, _ = urlparse(self.url)
        pm.add_password(self.realm, netloc, self.username, self.password)
        self.password_handler = HTTPBasicAuthHandler(pm)