{"id":28498037,"url":"https://github.com/wallabag/guzzle-site-authenticator","last_synced_at":"2025-07-03T13:31:23.736Z","repository":{"id":3147326,"uuid":"48559349","full_name":"wallabag/guzzle-site-authenticator","owner":"wallabag","description":"A plugin for guzzle that authenticates, with credentials, to sites that require it.","archived":false,"fork":false,"pushed_at":"2023-08-21T14:34:33.000Z","size":132,"stargazers_count":4,"open_issues_count":5,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-08T13:41:27.660Z","etag":null,"topics":["authentication","guzzle","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wallabag.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-12-24T23:28:20.000Z","updated_at":"2022-03-02T21:03:18.000Z","dependencies_parsed_at":"2024-01-23T21:35:31.253Z","dependency_job_id":null,"html_url":"https://github.com/wallabag/guzzle-site-authenticator","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/wallabag/guzzle-site-authenticator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallabag%2Fguzzle-site-authenticator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallabag%2Fguzzle-site-authenticator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallabag%2Fguzzle-site-authenticator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallabag%2Fguzzle-site-authenticator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wallabag","download_url":"https://codeload.github.com/wallabag/guzzle-site-authenticator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallabag%2Fguzzle-site-authenticator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263335355,"owners_count":23450823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","guzzle","php"],"created_at":"2025-06-08T13:30:58.590Z","updated_at":"2025-07-03T13:31:23.724Z","avatar_url":"https://github.com/wallabag.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Guzzle site authenticator\n\n[![CI](https://github.com/wallabag/guzzle-site-authenticator/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/wallabag/guzzle-site-authenticator/actions/workflows/continuous-integration.yml)\n\nThis package is a plugin for [guzzle](http://packagist.org/packages/guzzlehttp/guzzle) 5.x. It provides a subscriber\nthat can authenticate requests by posting login information.\n\nIt comes up as a Symfony bundle and a generic php lib.\n\n## Installation\n\n### Using composer\nAdd the package to your requirements using composer: `composer require bdunogier/guzzle-site-authenticator`.\n\nIf you're using the Symfony fullstack, add `BD\\GuzzleSiteAuthenticatorBundle\\BDGuzzleSiteAuthenticatorBundle` to your\nkernel class.\n\n## Usage\nThe guzzle subscriber, `Guzzle\\AuthenticatorSubscriber`, must be attached to the Guzzle client. It is provided by the\nbundle as `@bd_guzzle_site_authenticator.authenticator_subscriber`:\n\n```php\n$client = new GuzzleHttp\\Client(['defaults' =\u003e ['cookies' =\u003e new FileCookieJar('/tmp/cookiejar.json')]]);\n$client-\u003egetEmitter()-\u003eattach(\n    $container-\u003eget('bd_guzzle_site_authenticator.authenticator_subscriber')\n);\n```\n\n### Cookies handling\nThe `CookieJar` passed to the guzzle client defaults is important: it will be used read/write cookies received by Guzzle,\nand is required for authentication to work.\n\nSend a request with Guzzle. If the request's host has a SiteConfig that requires configuration (see below), the plugin\nwill try to log in to the site if it does not have a cookie yet. After a request, if the response contains the not logged\nin text (matched by xpath), it tries to login again, and retries the request.\n\n## Site configuration\nLogin to sites configured via `SiteConfig` objects:\n\n```php\n$siteConfig = new BD\\GuzzleSiteAuthenticator\\SiteConfig\\SiteConfig([\n    'host' =\u003e 'example.com',\n    'loginUri' =\u003e 'http://example.com/login',\n    'usernameField' =\u003e 'username',\n    'passwordField' =\u003e 'password',\n    'extraFields' =\u003e ['action' =\u003e 'login'],\n    'notLoggedInXpath' =\u003e \"//div[@class='not-logged-in']\",\n    'username' =\u003e \"johndoe\",\n    'password' =\u003e \"unknown\",\n]);\n```\n\n`SiteConfig` objects are returned by a `SiteConfigBuilder`. The library comes with a default `ArraySiteConfigBuilder`,\nthat accepts a list of site config properties array, indexed by host. With the bundle, its contents can be configured\nusing the `bd_guzzle_site_authenticator.site_config` container variable:\n\n```yaml\n# config.yml\nparameters:\n    bd_guzzle_site_authenticator.site_config:\n        example.com:\n            host: \"example.com\"\n            loginUri: \"http://example.com/login\"\n            usernameField: \"username\"\n            passwordField: \"password\"\n            extraFields: {action: login}\n            notLoggedInXpath: \"//div[@class='not-logged-in']\"\n            username: \"johndoe\"\n            password: \"unknown\"\n        otherexample.com:\n            host: ...\n```\n\n## Implementations\nUsed by [wallabag](http://github.com/wallabag/wallabag), a read it later web application, to fetch content from sites that require a login.\n\nIt implements a custom `SiteConfigBuilder`, based on sites configuration provided by [j0k3r/graby](http://github.com/j0k3r/graby).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwallabag%2Fguzzle-site-authenticator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwallabag%2Fguzzle-site-authenticator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwallabag%2Fguzzle-site-authenticator/lists"}