{"id":16005257,"url":"https://github.com/madeorsk/nocsrf","last_synced_at":"2026-06-10T16:31:19.326Z","repository":{"id":62521585,"uuid":"266145470","full_name":"Madeorsk/nocsrf","owner":"Madeorsk","description":"CSRF protection library for PHP.","archived":false,"fork":false,"pushed_at":"2020-09-21T11:42:05.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T07:55:11.954Z","etag":null,"topics":["csrf","csrf-protection","csrf-tokens","php","standalone-library","standalone-php-library"],"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/Madeorsk.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":"2020-05-22T15:33:27.000Z","updated_at":"2020-09-21T11:40:33.000Z","dependencies_parsed_at":"2022-11-02T15:31:46.142Z","dependency_job_id":null,"html_url":"https://github.com/Madeorsk/nocsrf","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Madeorsk%2Fnocsrf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Madeorsk%2Fnocsrf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Madeorsk%2Fnocsrf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Madeorsk%2Fnocsrf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Madeorsk","download_url":"https://codeload.github.com/Madeorsk/nocsrf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"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":["csrf","csrf-protection","csrf-tokens","php","standalone-library","standalone-php-library"],"created_at":"2024-10-08T11:03:22.876Z","updated_at":"2026-06-10T16:31:19.148Z","avatar_url":"https://github.com/Madeorsk.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NoCSRF\n\nEasy as fuck CSRF protection library for PHP based on [OWASP recommandations](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html).\n\n## Installation\n\nUsing composer:\n\n```sh\ncomposer require madeorsk/nocsrf\n```\n\n## Getting started\n\nEasy example code:\n\n```php\n\nuse NoCSRF\\NoCSRF;\n\n// Creating a new NoCSRF instance, which manages anti-CSRF tokens.\n$nocsrf = new NoCSRF();\n\n// Get an anti-CSRF token (to add in a hidden input field or a request header).\n$token = $nocsrf-\u003egetToken();\n\n// Verify anti-CSRF token.\nif ($nocsrf-\u003everify($token))\n\techo \"Anti-CSRF token is VALID!\";\nelse\n\techo \"Anti-CSRF token is INVALID.\";\n\n```\n\n## Custom modules\n\nNoCSRF is made of three main components:\n\n- The `KeyGenerator`: generate a key, in the default implementation it is an OpenSSL random key generator.\n- The `KeyStorage` : store the key used in token generation / verification. The key storage need to keep the key in such a way that it is available for a specific session, but cannot be retrievable by the client.\n- The `TokenManager` : contain token generation / verification logic. The key is provided.\n\nYou can create custom classes for these three components. You can chose which module to use in the NoCSRF initialization:\n\n```php\n$nocsrf = new NoCSRF([\n\t\"keyGenerator\" =\u003e new OpensslKeyGenerator(16),\n\t\"keyStorage\" =\u003e new SessionKeyStorage(),\n\t\"tokenManager\" =\u003e new HMACTokenManager(),\n]);\n```\n\nThe components used in this example are the default values.\n\n## Full API documentation\n\nFull API documentation is available in GitHub wiki (WIP) or in code documentation.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeorsk%2Fnocsrf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadeorsk%2Fnocsrf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeorsk%2Fnocsrf/lists"}