{"id":20297442,"url":"https://github.com/geggleto/securejwt","last_synced_at":"2025-04-11T12:14:37.884Z","repository":{"id":56982979,"uuid":"59846060","full_name":"geggleto/securejwt","owner":"geggleto","description":null,"archived":false,"fork":false,"pushed_at":"2016-06-01T13:48:20.000Z","size":5,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T08:38:23.946Z","etag":null,"topics":[],"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/geggleto.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}},"created_at":"2016-05-27T15:50:01.000Z","updated_at":"2023-11-15T05:25:04.000Z","dependencies_parsed_at":"2022-08-21T12:20:25.173Z","dependency_job_id":null,"html_url":"https://github.com/geggleto/securejwt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geggleto%2Fsecurejwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geggleto%2Fsecurejwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geggleto%2Fsecurejwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geggleto%2Fsecurejwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geggleto","download_url":"https://codeload.github.com/geggleto/securejwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248399099,"owners_count":21097295,"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-14T15:47:35.567Z","updated_at":"2025-04-11T12:14:37.859Z","avatar_url":"https://github.com/geggleto.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Encrypt your JSON Web Tokens\n\n\n## Pre-Req\n\nLibsodium is installed and configured in your environment. Our friends over at ParagonIE have a wonderful document to \nhelp you out. [Read it here](https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-libsodium).\n\n## Installation\n```php\ncomposer require geggleto/securejwt\n```\n\n## Usage\n\n1. Generate a security key [a script has been provided scripts/generateSecretKey.php] \n\n2. Encrypting your Tokens\n\n```php\n\n    $config = new \\Lcobucci\\JWT\\Builder(); // This object helps to simplify the creation of the dependencies\n    // instead of using \"?:\" on constructors.\n\n    $token = $config-\u003esetIssuer('http://example.com') // Configures the issuer (iss claim)\n        -\u003esetAudience('http://example.org') // Configures the audience (aud claim)\n        -\u003esetId('4f1g23a12aa', true) // Configures the id (jti claim), replicating as a header item\n        -\u003esetIssuedAt(time()) // Configures the time that the token was issue (iat claim)\n        -\u003esetNotBefore(time() + 60) // Configures the time that the token can be used (nbf claim)\n        -\u003esetExpiration(time() + 3600) // Configures the expiration time of the token (exp claim)\n        -\u003eset('uid', 1) // Configures a new claim, called \"uid\"\n        -\u003egetToken(); // Retrieves the generated token\n\n    $secureJwt = new \\SecureJwt\\SecureJwt('./sec/encryption.key');\n\n    $securedToken = $secureJwt-\u003eencryptToken((string)$token); //\u003c--- This is the encrypted token\n\n```\n\n3. Decrypting your tokens\n\n```php\n    $tokenString = $secureJwt-\u003edecryptToken($securedToken);\n\n    $newToken = (new \\Lcobucci\\JWT\\Parser())-\u003eparse($tokenString);\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeggleto%2Fsecurejwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeggleto%2Fsecurejwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeggleto%2Fsecurejwt/lists"}