{"id":15306848,"url":"https://github.com/kenjis/ci4-shield-test","last_synced_at":"2025-04-15T00:31:26.397Z","repository":{"id":142580904,"uuid":"585355145","full_name":"kenjis/ci4-shield-test","owner":"kenjis","description":"CodeIgniter4 Shield Test","archived":false,"fork":false,"pushed_at":"2024-09-06T01:21:10.000Z","size":928,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T12:37:41.373Z","etag":null,"topics":["codeigniter","codeigniter4"],"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/kenjis.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-05T00:42:27.000Z","updated_at":"2024-09-06T01:21:13.000Z","dependencies_parsed_at":"2023-11-16T03:29:51.842Z","dependency_job_id":"e68910cc-7c3a-478b-932a-cdfb0c00c948","html_url":"https://github.com/kenjis/ci4-shield-test","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/kenjis%2Fci4-shield-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjis%2Fci4-shield-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjis%2Fci4-shield-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjis%2Fci4-shield-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kenjis","download_url":"https://codeload.github.com/kenjis/ci4-shield-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248984235,"owners_count":21193713,"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":["codeigniter","codeigniter4"],"created_at":"2024-10-01T08:07:54.259Z","updated_at":"2025-04-15T00:31:26.059Z","avatar_url":"https://github.com/kenjis.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeIgniter4 Shield Test\n\nThis repository includes:\n\n- CodeIgniter v4.5.4\n- CodeIgniter Shield v1.1.0\n\n## Requirements\n\n- PHP 8.2 or later\n- `composer` command (See [Composer Installation](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos))\n- Git\n\n## How to Use\n\n### Install\n\n```console\n$ git clone https://github.com/kenjis/ci4-shield-test.git\n$ cd ci4-shield-test/\n$ composer install\n```\n\n### (Optional) Create Database\n\nBy default, this project uses SQLite3.\n\nIf you use MySQL, create a database:\n\n```mysql\nCREATE DATABASE `ci_shield` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;\nCREATE USER dbuser@localhost IDENTIFIED WITH mysql_native_password BY 'dbpasswd';\nGRANT ALL PRIVILEGES ON ci_shield.* TO dbuser@localhost;\n```\n\n### Configure\n\n```console\n$ cp env.sample .env\n```\n\nIf you use MySQL, change the configuration.\n\n### Run Database Migration\n\n```console\n$ php spark migrate --all\n```\n\n### Run Development Server\n\n```console\n$ php spark serve\n```\n\n### How to Test JSON Web Token (JWT) Authentication\n\n#### 1. Register a User\n\nNavigate to \u003chttp://localhost:8080/register\u003e.\n\n#### 2. Get a JWT\n\n```console\n$ curl --location 'http://localhost:8080/auth/jwt' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\"email\":\"admin@example.jp\",\"password\":\"passw0rd!\"}'\n```\n\n```console\n{\n    \"message\": \"User authenticated successfully\",\n    \"user\": {\n        \"id\": 1,\n        \"username\": \"admin\",\n        \"status\": null,\n        \"status_message\": null,\n        \"active\": true,\n        \"last_active\": {\n            \"date\": \"2023-04-18 05:41:44.000000\",\n            \"timezone_type\": 3,\n            \"timezone\": \"UTC\"\n        },\n        \"created_at\": {\n            \"date\": \"2023-04-14 00:17:00.000000\",\n            \"timezone_type\": 3,\n            \"timezone\": \"UTC\"\n        },\n        \"updated_at\": {\n            \"date\": \"2023-04-18 05:41:44.000000\",\n            \"timezone_type\": 3,\n            \"timezone\": \"UTC\"\n        },\n        \"deleted_at\": null\n    },\n    \"access_token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJTaGllbGQgVGVzdCBBcHAiLCJzdWIiOiIxIiwiaWF0IjoxNjgxODA1OTMwLCJleHAiOjE2ODE4MDk1MzB9.DGpOmRPOBe45whVtEOSt53qJTw_CpH0V8oMoI_gm2XI\"\n}\n```\n\n#### 3. Access with the JWT\n\n```console\n$ curl --location --request GET 'http://localhost:8080/jwt/api/users' \\\n--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJTaGllbGQgVGVzdCBBcHAiLCJzdWIiOiIxIiwiaWF0IjoxNjgxODA1OTMwLCJleHAiOjE2ODE4MDk1MzB9.DGpOmRPOBe45whVtEOSt53qJTw_CpH0V8oMoI_gm2XI'\n```\n\n### How to Test HMAC SHA256 Token Authentication\n\n#### 1. Register a User\n\nNavigate to \u003chttp://localhost:8080/register\u003e.\n\n#### 2. Get a HMAC Token\n\n```console\n$ curl --location 'http://localhost:8080/auth/hmac' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\"email\":\"admin@example.jp\",\"password\":\"passw0rd!\",\"token_name\":\"MacBook Air\"}'\n```\n\n```console\n{\n    \"message\": \"User authenticated successfully\",\n    \"user\": {\n        \"id\": 1,\n        \"username\": \"admin\",\n        \"status\": null,\n        \"status_message\": null,\n        \"active\": true,\n        \"last_active\": {\n            \"date\": \"2023-11-16 02:52:04.000000\",\n            \"timezone_type\": 3,\n            \"timezone\": \"UTC\"\n        },\n        \"created_at\": {\n            \"date\": \"2023-11-16 02:49:49.000000\",\n            \"timezone_type\": 3,\n            \"timezone\": \"UTC\"\n        },\n        \"updated_at\": {\n            \"date\": \"2023-11-16 02:52:04.000000\",\n            \"timezone_type\": 3,\n            \"timezone\": \"UTC\"\n        },\n        \"deleted_at\": null\n    },\n    \"hmac_token\": {\n        \"name\": \"MacBook Air\",\n        \"key\": \"9f6ea7ab9f78f33d3a3465d75bf76c16\",\n        \"secretKey\": \"Dg2g47PAfHQjlJYFYGHRt4MedNqNnSj5/u5zHyVu6jA=\"\n    }\n}\n```\n\n#### 3. Access with the HMAC Token\n\n```console\n$ php spark hmac:request 9f6ea7ab9f78f33d3a3465d75bf76c16 \\\nDg2g47PAfHQjlJYFYGHRt4MedNqNnSj5/u5zHyVu6jA= \\\nGET 'http://localhost:8080/hmac/api/users' ''\n```\n\n### Defined Routes\n\n```console\n+--------+-------------------------+--------------------+--------------------------------------------------------------------+----------------+---------------+\n| Method | Route                   | Name               | Handler                                                            | Before Filters | After Filters |\n+--------+-------------------------+--------------------+--------------------------------------------------------------------+----------------+---------------+\n| GET    | /                       | »                  | \\App\\Controllers\\Home::index                                       |                | toolbar       |\n| GET    | register                | »                  | \\CodeIgniter\\Shield\\Controllers\\RegisterController::registerView   |                | toolbar       |\n| GET    | login                   | »                  | \\CodeIgniter\\Shield\\Controllers\\LoginController::loginView         |                | toolbar       |\n| GET    | login/magic-link        | magic-link         | \\CodeIgniter\\Shield\\Controllers\\MagicLinkController::loginView     |                | toolbar       |\n| GET    | login/verify-magic-link | verify-magic-link  | \\CodeIgniter\\Shield\\Controllers\\MagicLinkController::verify        |                | toolbar       |\n| GET    | logout                  | »                  | \\CodeIgniter\\Shield\\Controllers\\LoginController::logoutAction      |                | toolbar       |\n| GET    | auth/a/show             | auth-action-show   | \\CodeIgniter\\Shield\\Controllers\\ActionController::show             |                | toolbar       |\n| GET    | jwt/api/users           | »                  | \\App\\Controllers\\Api\\User::index                                   | jwt            | jwt toolbar   |\n| GET    | hmac/api/users          | »                  | \\App\\Controllers\\Api\\User::index                                   | hmac           | hmac toolbar  |\n| POST   | register                | »                  | \\CodeIgniter\\Shield\\Controllers\\RegisterController::registerAction |                | toolbar       |\n| POST   | login                   | »                  | \\CodeIgniter\\Shield\\Controllers\\LoginController::loginAction       |                | toolbar       |\n| POST   | login/magic-link        | »                  | \\CodeIgniter\\Shield\\Controllers\\MagicLinkController::loginAction   |                | toolbar       |\n| POST   | auth/a/handle           | auth-action-handle | \\CodeIgniter\\Shield\\Controllers\\ActionController::handle           |                | toolbar       |\n| POST   | auth/a/verify           | auth-action-verify | \\CodeIgniter\\Shield\\Controllers\\ActionController::verify           |                | toolbar       |\n| POST   | auth/jwt                | »                  | \\App\\Controllers\\Auth\\LoginController::jwtLogin                    |                | toolbar       |\n| POST   | auth/hmac               | »                  | \\App\\Controllers\\Auth\\LoginController::hmacLogin                   |                | toolbar       |\n+--------+-------------------------+--------------------+--------------------------------------------------------------------+----------------+---------------+\n```\n\n## References\n\n- https://github.com/codeigniter4/CodeIgniter4\n- https://github.com/codeigniter4/shield\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenjis%2Fci4-shield-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkenjis%2Fci4-shield-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenjis%2Fci4-shield-test/lists"}