self, username, password=None, email=None, registry=None,
              reauth=False, insecure_registry=False, dockercfg_path=None):
491126
def _request_auth(self, registry):
        
        if registry:
            if registry.auth:
                registry.auth.load_dockercfg()

            try:
                self._client_session.login(username=registry.auth.user,
                                           password=registry.auth.passwd,
                                           dockercfg_path=registry.auth.config_path,
                                           reauth=True if registry.auth.auth_type == 'registry_rubber' else False,
                                           registry=registry.auth.registry)
            except Exception:
                raise
        else:
            raise Exception("a registry is required when requesting auth.")
550008
def check_permissions():
    
    if (
        not grp.getgrnam('docker').gr_gid in os.getgroups()
        and not os.geteuid() == 0
    ):
        exitStr = """
        User doesn't have permission to use docker.
        You can do either of the following,
        1. Add user to the 'docker' group (preferred)
        2. Run command as superuser using either 'sudo' or 'su -c'
        """
        exit(exitStr)
675954
def read_login(collector, image, **kwargs):
    """"""
    docker_api = collector.configuration["harpoon"].docker_api
    collector.configuration["authentication"].login(docker_api, image, is_pushing=False, global_docker=True)
855313
def authenticate_with_email_and_pwd(user_email, user_password):
    '''
    
    '''
    if user_email is None or user_password is None:
        raise ValueError(
            'Could not authenticate user. Missing username or password')
    upload_token = uploader.get_upload_token(user_email, user_password)
    if not upload_token:
        print("Authentication failed for user name " +
              user_name + ", please try again.")
        sys.exit(1)
    user_key = get_user_key(user_name)
    if not user_key:
        print("User name {} does not exist, please try again or contact Mapillary user support.".format(
            user_name))
        sys.exit(1)
    user_permission_hash, user_signature_hash = get_user_hashes(
        user_key, upload_token)

    user_items["MAPSettingsUsername"] = section
    user_items["MAPSettingsUserKey"] = user_key

    user_items["user_upload_token"] = upload_token
    user_items["user_permission_hash"] = user_permission_hash
    user_items["user_signature_hash"] = user_signature_hash
    return user_items
1277862
def authenticate():
    

    client_ip     = request.environ['REMOTE_ADDR']
    repository    = request.headers['repository']
    if repository not in config['repositories']: return fail(no_such_repo_msg)

    # ==
    repository_path = config['repositories'][repository]['path']
    conn = auth_db_connect(cpjoin(repository_path, 'auth_transient.db')); gc_tokens(conn)
    gc_tokens(conn)

    # Allow resume of an existing session
    if 'session_token' in request.headers:
        session_token = request.headers['session_token']

        conn.execute("delete from session_tokens where expires < ?", (time.time(),)); conn.commit()
        res = conn.execute("select * from session_tokens where token = ? and ip = ?", (session_token, client_ip)).fetchall()
        if res != []: return success({'session_token'  : session_token})
        else:         return fail(user_auth_fail_msg)

    # Create a new session
    else:
        user       = request.headers['user']
        auth_token = request.headers['auth_token']
        signiture  = request.headers['signature']

        try:
            public_key = config['users'][user]['public_key']

            # signature
            pysodium.crypto_sign_verify_detached(base64.b64decode(signiture), auth_token, base64.b64decode(public_key))

            # check token was previously issued by this system and is still valid
            res = conn.execute("select * from tokens where token = ? and ip = ? ", (auth_token, client_ip)).fetchall()

            # Validate token matches one we sent
            if res == [] or len(res) > 1: return fail(user_auth_fail_msg)

            # Does the user have permission to use this repository?
            if repository not in config['users'][user]['uses_repositories']: return fail(user_auth_fail_msg)

            # Everything OK
            conn.execute("delete from tokens where token = ?", (auth_token,)); conn.commit()

            # generate a session token and send it to the client
            session_token = base64.b64encode(pysodium.randombytes(35))
            conn.execute("insert into session_tokens (token, expires, ip, username) values (?,?,?, ?)",
                         (session_token, time.time() + extend_session_duration, client_ip, user))
            conn.commit()
            return success({'session_token'  : session_token})

        except Exception: # pylint: disable=broad-except
            return fail(user_auth_fail_msg)
171163
def check_auth(username, password):
    
    return (username == settings.PRIVATE_INDEX_USERNAME and
            settings.PRIVATE_INDEX_PASSWORD and
            password == settings.PRIVATE_INDEX_PASSWORD)
1116180
def finished_configuring
      Docker.options = @docker_options_for_cert.merge(docker_options)

      return self unless @docker_auth_needed
      Docker.authenticate! username: @docker_auth_user, password: @docker_auth_password, email: @docker_auth_email
      @docker_auth_needed = false
      self
    end
1195310
def authenticate():
    

    print LOGIN_INIT_MESSAGE

    username = raw_input('{0}: '.format(LOGIN_USER_MESSAGE))
    password = None

    while password is None:
        password = getpass('Password for {0}: '.format(username))

    gh = login(username, password=password)
    try:
        gh.user()
        instance = authorize(username, password, APP_SCOPE, APP_DESC, APP_URL)
    except Exception, e:
        raise e

    with open(credentials_file, 'w') as f:
        f.write(instance.token)

    return instance.token
1076931
def _auth(self):
        
        ts = datetime.datetime.now().strftime("%Y-%m-%d%H:%M:%S")
        hash_string = hashlib.md5("%s%s%s" % (ts, self.private_key, self.public_key)).hexdigest()
        return "ts=%s&apikey=%s&hash=%s" % (ts, self.public_key, hash_string)
1154949
def reset_password(server_context, email, container_path=None):
    
    url = server_context.build_url(security_controller, 'adminRotatePassword.api', container_path)

    return server_context.make_request(url, {
        'email': email
    })
930968
def _login_dockerhub():
    
    dockerhub_credentials = _get_dockerhub_credentials()

    logging.info('Logging in to DockerHub')
    # We use password-stdin instead of --password to avoid leaking passwords in case of an error.
    # This method will produce the following output:
    # > WARNING! Your password will be stored unencrypted in /home/jenkins_slave/.docker/config.json.
    # > Configure a credential helper to remove this warning. See
    # > https://docs.docker.com/engine/reference/commandline/login/#credentials-store
    # Since we consider the restricted slaves a secure environment, that's fine. Also, using this will require
    # third party applications which would need a review first as well.
    p = subprocess.run(['docker', 'login', '--username', dockerhub_credentials['username'], '--password-stdin'],
                       stdout=subprocess.PIPE, input=str.encode(dockerhub_credentials['password']))
    logging.info(p.stdout)
    logging.info('Successfully logged in to DockerHub')
1157699
def authenticate(self, request, username=None, password=None):
        
        if isinstance(username, basestring):
            username = username.encode('utf-8')

        if isinstance(password, basestring):
            password = password.encode('utf-8')

        server = self._get_server_from_settings()
        result = self._radius_auth(server, username, password)

        if result:
            return self.get_django_user(username, password)

        return None
171608
def get(self, server):
        
        if not isinstance(server, six.binary_type):
            server = server.encode('utf-8')
        data = self._execute('get', server)
        result = json.loads(data.decode('utf-8'))

        # docker-credential-pass will return an object for inexistent servers
        # whereas other helpers will exit with returncode != 0. For
        # consistency, if no significant data is returned,
        # raise CredentialsNotFound
        if result['Username'] == '' and result['Secret'] == '':
            raise errors.CredentialsNotFound(
                'No matching credentials in {}'.format(self.program)
            )

        return result
583660
def _connect_docker(spec):
    
    return {
        'method': 'docker',
        'kwargs': {
            'username': spec.remote_user(),
            'container': spec.remote_addr(),
            'python_path': spec.python_path(),
            'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
            'remote_name': get_remote_name(spec),
        }
    }
659476
public void auth() throws DockerException {
		try {
			client.resource(restEndpointUrl + "/auth")
					.header("Content-Type", MediaType.APPLICATION_JSON)
					.accept(MediaType.APPLICATION_JSON)
					.post(authConfig());
		} catch (UniformInterfaceException e) {
			throw new DockerException(e);
		}
	}
1017634
def authDomainUser(self, realmname, username, password, environ):
        """"""
        try:
            apikey = self.user_manager.get_user_api_key(username, create=None)
            return apikey is not None and password == apikey
        except:
            return False
1115453
def user_login(self, email=None, password=None):
        
        self._rpc_api = PiazzaRPC()
        self._rpc_api.user_login(email=email, password=password)