Configure Auth system

@param array $config
@return Auth
768815
public static function configure(array $config)
    {
        if (!is_null(static::$instance)) {
            return static::$instance;
        }

        static::$config = $config;

        static::$session = Session::getInstance();

        return static::$instance = new Auth($config[$config['default']]);
    }
428828
public static function factory($config = array())
    {
        $defaults = array();

        $required = array(
            'base_url',
            'login',
            'password'
        );

        $config = Collection::fromConfig($config, $defaults, $required);

        $client = new self($config['base_url'], $config);

        return $client;
    }
760701
protected function setupDefaultMachine(array $config)
	{

		// State function
		if ($this->state_select === null) {
			$this->state_select = '"Authenticated"'; // TODO
		}

		// Exists state only
		$this->states = [
			'Authenticated' => [
				'description' => _('User is authenticated and active.'),
				'color' => '#ddffcc',
			],
			'Prepared' => [
				'description' => _('Session token is waiting for user (i.e. to click login link sent via e-mail).'),
				'color' => '#ffffcc',
			],
			'Expired' => [
				'description' => _('Session has expired. Awaiting clean up.'),
				'color' => '#ffddcc',
			],
		];

		$this->access_policies = [
			'admin' => [
				'type' => 'nobody',
				'arrow_tail' => 'nonetee',
			],
			'owner' => [
				'type' => 'owner',
				'owner_property' => 'user_id',
				'arrow_tail' => 'dot',
			],
			'anonymous' => [
				'type' => 'anonymous',
				'arrow_tail' => 'odot',
			],
		];

		// Actions
		$this->actions = [
			'login' => [
				'description' => _('Login user using password.'),
				'color' => '#44aa00',
				'returns' => self::RETURNS_NEW_ID,
				'transitions' => [
					'' => [
						'targets' => [ '', 'Authenticated' ],
						'access_policy' => 'anonymous',
					],
				],
			],
			'useToken' => [
				'description' => _('Login user using prepared token'),
				'transitions' => [
					'Prepared' => [
						'targets' => [ 'Authenticated' ],
						'access_policy' => 'anonymous',
					],
				],
			],
			'logout' => [
				'description' => _('Logout user.'),
				'color' => '#aa4400',
				'transitions' => [
					'Authenticated' => [
						'targets' => [ '' ],
						'access_policy' => 'owner',
					],
					'Prepared' => [
						'targets' => [ '' ],
						'access_policy' => 'admin',
					],
					'Expired' => [
						'targets' => [ '' ],
						'access_policy' => 'owner',
					],
				],
			],
			'checkSession' => [
				'description' => _('Check whether the session is valid.'),
				'color' => '#aa88ff',
				'transitions' => [
					'' => [
						'targets' => [ '', 'Authenticated' ],
						'access_policy' => 'anonymous',
					],
				],
			],
			'prepare' => [
				'description' => _('Prepare session token for later use.'),
				'returns' => self::RETURNS_NEW_ID,
				'transitions' => [
					'' => [
						'targets' => [ 'Prepared' ],
					],
				],
			],
			'expire' => [
				'description' => _('Expire session. Timed transition.'),
				'color' => '#aaaaaa',
				'transitions' => [
					'Authenticated' => [
						'targets' => [ 'Expired' ],
					],
					'Prepared' => [
						'targets' => [ 'Expired' ],
					],
				],
			],
		];

		// Merge with config
		if (isset($config['actions'])) {
			$this->actions = array_replace_recursive($this->actions, $config['actions']);
		}
		if (isset($config['states'])) {
			$this->states = array_replace_recursive($this->states, $config['states']);
		}
		if (isset($config['access_policies'])) {
			$this->access_policies = array_replace_recursive($this->access_policies, $config['access_policies']);
		}
	}
657553
public function setConfig(array $config)
    {
        // Verify that method is provided
        if (!isset($config['method'])) {
            throw new InvalidAuthenticateMethod('Invalid authentification method, you must provide one');
        }

        // Verify that exists
        if (!in_array($config['method'], $this->methods)) {
            throw new UnknownAuthenticateMethod('Unknown authentification method');
        }

        // Create the url to request using base_url parameter
        if (!isset($config['base_url'][0])) {
            throw new \Exception('Error processing, invalid base url provided, it must be the first one parameter without index, at position [0]', 1);
        }

        $this->config = $config;

        return $this;
    }
1236083
public function setConfig(array $config): EnvironmentConfigEvent
    {
        $this->config = array_replace_recursive($this->config, $config);

        return $this;
    }
1291547
public function connect(array $config)
    {
        $options = $this->getOptions($config);

        return $this->createConnection($this->getDsn($config), $config, $options);
    }
759597
public function configure(array $config)
    {
        return $this
            ->setGLSShipmentDeposit($config[Config::T8700])
            ->setCustomerCode($config[Config::T8915])
            ->setContactId($config[Config::T8914])
            ->clean();
    }
1284167
public function addConfig(array $config)
    {
        foreach ($config as $id => $entry) {
            $args = [];

            if (is_array($entry) && ! empty($entry)) {
                $values = array_values($entry);
                $entry = $values[0];

                if (isset($values[1])) {
                    $args = $values[1];
                }
            }

            $this->container[$id] = new Service($entry, $args);
        }

        return $this;
    }
5271
function configure($config = []) {
    $this->config = array_replace_recursive($this->config, $this->modes[@$config['mode'] ?: $this->config['mode']]);
    
    $this->config = array_replace_recursive($this->config, $config);
    
    return $this;
  }
312863
public function connect(array $config)
    {
        $ironConfig = ['token' => $config['token'], 'project_id' => $config['project']];

        if (isset($config['host'])) {
            $ironConfig['host'] = $config['host'];
        }

        $iron = new IronMQ($ironConfig);

        if (isset($config['ssl_verifypeer'])) {
            $iron->ssl_verifypeer = $config['ssl_verifypeer'];
        }

        $queue = new IronQueue($iron, $this->request, $config['queue'], $config['encrypt'], $config['timeout']);
        $queue->setEncrypter($this->crypt);

        return $queue;
    }
1155939
protected function prepareConfig(array $config)
    {
        $config = new Config($config);
        $config->setFallback($this->getConfig());

        return $config;
    }
117184
public function make(array $config): Facebook
    {
        $config = $this->getConfig($config);

        return $this->getClient($config);
    }
139425
protected function assignRole(array $config)
    {
        if (!($name = ArrayHelper::get($config, 'name')) || !($role  = $this->authManager->getRole($name))){
            return false;
        }
        if (!($child = ArrayHelper::get($config, 'child'))) {
            return $role;
        }
        if ($childRoles = ArrayHelper::get($child, 'roles')) {
            foreach ($childRoles as $name) {
                if ($roleChild = $this->authManager->getRole($name)) {
                    try {
                        $this->authManager->addChild($role, $roleChild);
                        $this->stdout("\tAssign child role: {$name} - success\n", Console::FG_GREEN);
                    } catch(\Exception $e) {
                        $this->stdout("\t- already exist\n");
                    }
                }
            }
        }
        if ($childPermissions = ArrayHelper::get($child, 'permissions')) {
            foreach ($childPermissions as $name) {
                if ($permissionChild = $this->authManager->getPermission($name)) {
                    try {
                        $this->authManager->addChild($role, $permissionChild);
                        $this->stdout("\tAssign child permission: {$name} - success\n", Console::FG_GREEN);
                    } catch(\Exception $e) {
                        $this->stdout("\t- already exist\n");
                    }
                }
            }
        }
        return $role;
    }
1275937
public function authenticate(array $config)
    {
        if (!$this->client) {
            throw new InvalidArgumentException('The client instance was not given to the token authenticator.');
        }

        if (!array_key_exists('token', $config)) {
            throw new InvalidArgumentException('The token authenticator requires a token.');
        }

        $this->client->authenticate($config['token'], Client::AUTH_HTTP_TOKEN);

        return $this->client;
    }
809673
protected function formatS3Config(array $config)
    {
        $config += ['version' => 'latest'];
        if ($config['key'] && $config['secret']) {
            $config['credentials'] = ArrayHelper::only($config, ['key', 'secret']);
        }
        return $config;
    }
1245811
public function config(array $config)
    {
        parent::config($config);

        if (array_key_exists('http_method', $config)) {
            $this->defaults->setHttpMethod($config['http_method']);
        }

        return $this;
    }
329565
private function configureAuthentication(array $config)
    {
        $config['keyFile'] = $this->getKeyFile($config);
        $this->projectId = $this->detectProjectId($config);

        return $config;
    }