{"id":21819363,"url":"https://github.com/dflydev/dflydev-stack-firewall","last_synced_at":"2025-04-14T02:28:46.705Z","repository":{"id":56967316,"uuid":"11824693","full_name":"dflydev/dflydev-stack-firewall","owner":"dflydev","description":"Firewall Stack middleware","archived":false,"fork":false,"pushed_at":"2018-05-29T09:21:57.000Z","size":13,"stargazers_count":5,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T02:28:42.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dflydev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-01T18:40:20.000Z","updated_at":"2023-06-02T10:17:11.000Z","dependencies_parsed_at":"2022-08-21T09:50:35.589Z","dependency_job_id":null,"html_url":"https://github.com/dflydev/dflydev-stack-firewall","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-stack-firewall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-stack-firewall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-stack-firewall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-stack-firewall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dflydev","download_url":"https://codeload.github.com/dflydev/dflydev-stack-firewall/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248810780,"owners_count":21165180,"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":[],"created_at":"2024-11-27T16:18:41.460Z","updated_at":"2025-04-14T02:28:46.686Z","avatar_url":"https://github.com/dflydev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Firewall Authentication Middleware\n==================================\n\nA [Stack][0] middleware providing a simple, configurable firewall concept for\n[STACK-2 Authentication][1] compatible middlewares.\n\n\nInstallation\n------------\n\nThrough [Composer][2] as [dflydev/stack-firewall][3].\n\n\nUsage\n-----\n\nThe Firewall middleware is a thin layer over [dflydev/stack-authentication][4]\nbased STACK-2 Authentication middlewares.\n\nA **firewall** is defined as an array of associatve arrays representing paths\nfor which an authentication middleware should be concerned.\n\nIf a requested path does not match a firewalled path, the firewall delegates the\nrequest to the next layer immediately.\n\nIf a requested path matches and authentication is missing or invalid and\nanonymous requests are allowed, the request is allowed through the firewall\nwithout setting the `stack.authn.token`.\n\nIf a requested path matches and authentication is missing or invalid and\nanonymous requests are NOT allowed, the firewall will challenge immediately.\n\nIf no firewall is defined, the assumed configuration is:\n\n    [['path' =\u003e '/']]\n\nThis effectively means that by default the firewall will match all requests\nand will not allow anonymous requests resulting in returning a challenge.\n\n\n```php\n\u003c?php\n\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\HttpKernel\\HttpKernelInterface;\n\n// The firewall is an array of associative arrays containing the rules for which\n// the authentication middleware should be concerned.\n$firewall = [\n    ['path' =\u003e '/', 'anonymous' =\u003e true],\n    ['path' =\u003e '/protected'],\n];\n\n$challenge = function (Response $response) {\n    // Assumptions that can be made:\n    // * 401 status code\n    // * WWW-Authenticate header with a value of \"Stack\"\n    //\n    // Expectations:\n    // * MAY set WWW-Authenticate header to another value\n    // * MAY return a brand new response (does not have to be\n    //   the original response)\n    // * MUST return a response\n    return $response;\n};\n\n$authenticate = function (HttpKernelInterface $app, $anonymous) {\n    // Assumptions that can be made:\n    // * The $app can be delegated to at any time\n    // * The anonymous boolean indicates whether or not we\n    //   SHOULD allow anonymous requests through or if we\n    //   should challenge immediately.\n    // * Additional state, like $request, $type, and $catch\n    //   should be passed via use statement if they are needed.\n    //\n    // Expectations:\n    // * SHOULD set 'stack.authn.token' attribute on the request\n    //   when authentication is successful.\n    // * MAY delegate to the passed $app\n    // * MAY return a custom response of any status (for example\n    //   returning a 302 or 400 status response is allowed)\n    // * MUST return a response\n};\n\n$app = new Firewall($app, [\n    'challenge' =\u003e $challenge,\n    'authenticate' =\u003e $authenticate,\n    'firewall' =\u003e $firewall,\n]);\n```\n\n\nLicense\n-------\n\nMIT, see LICENSE.\n\n\nCommunity\n---------\n\nIf you have questions or want to help out, join us in the **#stackphp** or\n**#dflydev** channels on **irc.freenode.net**.\n\n\n[0]: http://stackphp.com/\n[1]: http://stackphp.com/specs/STACK-2/\n[2]: http://getcomposer.org\n[3]: https://packagist.org/packages/dflydev/stack-firewall\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflydev%2Fdflydev-stack-firewall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdflydev%2Fdflydev-stack-firewall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflydev%2Fdflydev-stack-firewall/lists"}