Log in as administrator

    You can use wither basic auth or form based login (via POST).

    :param username: The administrator's username
    :type username: string
    :param password: The administrator's password
    :type password: string
967526
def login():
    '''
    '''
    username = None
    password = None
    next = flask.request.args.get('next')
    auth = flask.request.authorization

    if flask.request.method == 'POST':
        username = flask.request.form['username']
        password = flask.request.form['password']

    if auth and auth.type == 'basic':
        username = auth.username
        password = auth.password

    if not flogin.current_user.is_active:
        error = 'You have to login with proper credentials'
        if username and password:
            if check_auth(username, password):
                user = _users.get(username)
                if user:
                    if flogin.login_user(user):
                        return flask.redirect(next or flask.url_for("user"))
                    error = 'Could not log in user.'
                else:
                    error = 'User not found.'
            else:
                error = 'Wrong username or password.'
        else:
            error = 'No username or password.'
        return flask.Response(
            'Could not verify your access level for that URL.\n {}'.format(error),
            401,
            {str('WWW-Authenticate'): str('Basic realm="Login Required"')})
    return flask.redirect(next or flask.url_for("user"))
1337028
def get_user(self, login):
        
        return youtrack.User(self._get("/admin/user/" + urlquote(login.encode('utf8'))), self)
795547
def encode_basic_auth(username, password):
    
    return "Basic {}".format(
        b64encode(
            "{}:{}".format(
                username,
                password,
            ).encode("utf-8")
        ).decode("utf-8")
    )
1125618
def build_basic_auth(username: str, password: str) -> str:
    
    # https://tools.ietf.org/html/rfc7617#section-2
    assert ":" not in username
    user_pass = f"{username}:{password}"
    basic_credentials = base64.b64encode(user_pass.encode()).decode()
    return "Basic " + basic_credentials
633189
def login(username=None, password=None):
    
    global user
    user = UserConfig()
    if username:
        user.username = username
    else:
        user.username = user.input_username()

    if password:
        user.password = password
    else:
        user.password = user.input_password()

    if (not ( user.username and user.password) ):
        logging.error("Username and password must be provided for login")
        return;
    user.retrieve_keycloak_token()
    user.apiclient = user.create_api_client()
    save()
35426
def auth(username, password):
    '''
    
    '''
    django_auth_path = __opts__['django_auth_path']
    if django_auth_path not in sys.path:
        sys.path.append(django_auth_path)
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', __opts__['django_auth_settings'])

    __django_auth_setup()

    if not is_connection_usable():
        connection.close()

    import django.contrib.auth  # pylint: disable=import-error,3rd-party-module-not-gated
    user = django.contrib.auth.authenticate(username=username, password=password)
    if user is not None:
        if user.is_active:
            log.debug('Django authentication successful')
            return True
        else:
            log.debug('Django authentication: the password is valid but the account is disabled.')
    else:
        log.debug('Django authentication failed.')

    return False
129029
def login(self, year, firstname, lastname, passwd, with_year=True):
        
        firstname = firstname.upper()
        lastname = lastname.upper()

        if with_year and not self.set_year(year):
            return False

        url = URLS['login']
        params = {
            'prenom': firstname,
            'nom': lastname,
            'pwd': passwd,
        }

        soup = self.post_soup(url, data=params)

        return not soup.select('font[color=red]')
759307
def _get_auth(username, password):
    '''
    
    '''
    if username and password:
        return requests.auth.HTTPBasicAuth(username, password)
    else:
        return None
356275
def authenticate(username, password, permission=None):
    
    try:
        author = Author.objects.get(
            **{'%s__exact' % Author.USERNAME_FIELD: username})
    except Author.DoesNotExist:
        raise Fault(LOGIN_ERROR, _('Username is incorrect.'))
    if not author.check_password(password):
        raise Fault(LOGIN_ERROR, _('Password is invalid.'))
    if not author.is_staff or not author.is_active:
        raise Fault(PERMISSION_DENIED, _('User account unavailable.'))
    if permission:
        if not author.has_perm(permission):
            raise Fault(PERMISSION_DENIED, _('User cannot %s.') % permission)
    return author
1363012
def authenticate_user(username, password):
    
    user_model = Query()
    user = db.get(user_model.username == username)

    if not user:
        logger.warning("User %s not found", username)
        return False

    if user['password'] == hash_password(password, user.get('salt')):
        return user['username']

    return False
796239
def _login(self, username, password):
        '''
        '''
        logger.debug('login in as user "%s"' % username)
        url = self._build_url('/auth')
        payload = {'username': username, 'password': password}
        res = self._session.post(url, json=payload)
        res.raise_for_status()
        self._access_token = res.json()['access_token']
        self._session.headers.update(
            {'Authorization': 'JWT %s' % self._access_token}
        )
1352581
def basic_auth(self, username, password):
        
        if not (username and password):
            return

        self.auth = (username, password)

        # Disable token authentication
        self.headers.pop('Authorization', None)
951817
def ldap_login(self, username, password):
        
        self.connect()

        if self.config.get('USER_SEARCH'):
            result = self.bind_search(username, password)
        else:
            result = self.direct_bind(username, password)
        return result
1365717
def login(username, password)
      params = { grant_type: "password", username: username, password: password }
      response = self['token'].get({ params: params })
      user_uuid = response.data['user']['uuid']
      user_access_token = response.data['access_token']
      Thread.current[:usergrid_user_id] = user_uuid
      Thread.current[:usergrid_auth_token] = user_access_token
      @current_user = self["/users/#{user_uuid}"].get.entity
      response
    end
1223067
function basicLogin(sock, data, cb) {
  if (data && _.isString(data.username) && !_.isEmpty(data.username)) {
    cb && cb(null, data.username);
  } else {
    cb && cb('invalid identifier ' + data);
  }
}
840386
def user(ctx, username, password):
    """"""

    ctx.obj['username'] = username
    ctx.obj['password'] = password
699531
def login(self, schema, username, password):
        
        self.schema = schema
        self.username = username
        self.password = password
        self.connection = schema