{"id":23489917,"url":"https://github.com/davilhlapak/jwt-auth","last_synced_at":"2025-04-15T04:30:47.850Z","repository":{"id":57035194,"uuid":"254915872","full_name":"DaviLhlapak/jwt-auth","owner":"DaviLhlapak","description":"Biblioteca PHP para a manipulação de JWT","archived":false,"fork":false,"pushed_at":"2020-10-18T18:28:30.000Z","size":56,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T15:51:58.416Z","etag":null,"topics":["composer","hacktoberfest","jwt","jwt-auth","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DaviLhlapak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-11T17:07:24.000Z","updated_at":"2021-08-30T20:15:59.000Z","dependencies_parsed_at":"2022-08-24T14:11:07.838Z","dependency_job_id":null,"html_url":"https://github.com/DaviLhlapak/jwt-auth","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaviLhlapak%2Fjwt-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaviLhlapak%2Fjwt-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaviLhlapak%2Fjwt-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaviLhlapak%2Fjwt-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DaviLhlapak","download_url":"https://codeload.github.com/DaviLhlapak/jwt-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249006317,"owners_count":21197249,"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":["composer","hacktoberfest","jwt","jwt-auth","php"],"created_at":"2024-12-25T00:12:36.488Z","updated_at":"2025-04-15T04:30:47.831Z","avatar_url":"https://github.com/DaviLhlapak.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jwt-Auth\nA PHP library for JWT manipulation using native PHP.\n\n## Installation\n\nJwt-Auth is avaliable via Composer\n\n```bash\n\"pakpak/jwt-auth\": \"^2.1.4\"\n```\n\nor via terminal:\n\n```bash\ncomposer require pakpak/jwt-auth\n```\n\n## Documentation\n\n- To use JwtAuth in your code\n\n```php\nuse PakPak\\JwtAuth\\JwtAuth;\n```\n\n\n\n- Creating a JWT:\n\n```php\nuse PakPak\\JwtAuth\\JwtAuth;\nuse PakPak\\JwtAuth\\JwtPayload;\n\n$payload = new JwtPayload(\"localhost\",\"user_id\");\n$key = \"My-Secret-Key\";\n\n$jwtAuth = JwtAuth::createJwt($payload, $key);\n```\n\n- Creating a JWT from a token\n\n```php\nuse PakPak\\JwtAuth\\JwtAuth;\n\n$jwtToken = \"header.payload.sign\";\n\n$jwtAuth = JwtAuth::byJwt($jwtToken);\n```\n\n- Recovering data:\n```php\n// - Validates the token created using the access key\n$jwtAuth-\u003everifyJwt(\"My-Secret-Key\");\n\n// - Returns a String containing the JWT Token\n$jwtAuth-\u003egetJwt();\n\n// - Returns an array containing the Header\n$jwtAuth-\u003egetHeader();\n\n// - Returns an array containing the Payload\n$jwtAuth-\u003egetPayload();\n```\n\n- Creating a header using JwtFunctions:\n````php\nuse PakPak\\JwtAuth\\JwtFunctions;\n\n$header = JwtFunctions::createHeader();\n````\n\n- Creating a Payload:\n````php\nuse PakPak\\JwtAuth\\JwtPayload;\n\n//Token’s origin\n$issuer = \"www.meudominio.com\";\n//Token’s subject\n$subject = \"user_id\";\n\n$payload = new JwtPayload($issuer,$subject);\n````\n## JwtException\n\n- Error codes:\n\n| Code | Message          |\n| :---- | :-------------: |\n| 1 | \"Header cannot be empty\" |\n| 2 | \"Payload cannot be empty\" |\n| 3 | \"Secret Key cannot be empty\" |\n| 4 | \"Sign cannot be empty\" |\n| 5 | \"Invalid Token\" |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavilhlapak%2Fjwt-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavilhlapak%2Fjwt-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavilhlapak%2Fjwt-auth/lists"}