https://github.com/phpnomad/firebase-jwt-integration
Integrates Firebase JWT with PHPNomad's JWTStrategy
https://github.com/phpnomad/firebase-jwt-integration
Last synced: 16 days ago
JSON representation
Integrates Firebase JWT with PHPNomad's JWTStrategy
- Host: GitHub
- URL: https://github.com/phpnomad/firebase-jwt-integration
- Owner: phpnomad
- License: gpl-3.0
- Created: 2024-11-10T11:27:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-17T20:07:34.000Z (about 1 year ago)
- Last Synced: 2025-12-28T07:55:09.514Z (5 months ago)
- Language: PHP
- Size: 42 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# phpnomad/firebase-jwt-integration
[](https://packagist.org/packages/phpnomad/firebase-jwt-integration)
[](https://packagist.org/packages/phpnomad/firebase-jwt-integration)
[](https://packagist.org/packages/phpnomad/firebase-jwt-integration)
[](https://packagist.org/packages/phpnomad/firebase-jwt-integration)
Integrates the [firebase/php-jwt](https://github.com/firebase/php-jwt) library with `phpnomad/auth`'s `JwtStrategy` interface. It provides a single concrete strategy that encodes payloads into HS256-signed JSON Web Tokens and decodes them back into arrays, translating firebase/php-jwt's exception types into `PHPNomad\Auth\Exceptions\JwtException` so the rest of your application only has to catch one thing.
## Installation
```bash
composer require phpnomad/firebase-jwt-integration
```
## What This Provides
- A `FirebaseJwt` strategy class that implements `PHPNomad\Auth\Interfaces\JwtStrategy` using `firebase/php-jwt`, with HS256 for both encoding and verification.
- Exception translation that maps `ExpiredException`, `SignatureInvalidException`, `BeforeValidException`, and the standard PHP value errors into `PHPNomad\Auth\Exceptions\JwtException` with descriptive messages.
## Requirements
- `phpnomad/auth ^1.0` for the `JwtStrategy` interface and its `JwtException` type.
- `firebase/php-jwt ^6.10` as the underlying JWT library.
## Usage
Bind `FirebaseJwt` to the `JwtStrategy` interface inside one of your bootstrapper initializers. Any service that depends on `JwtStrategy` will then receive this implementation without knowing which library is wired in behind it.
```php
JwtStrategy::class,
];
}
}
```
With that binding in place, a service can take `JwtStrategy` as a constructor dependency and call `$jwt->encode($payload, $secret)` or `$jwt->decode($token, $secret)` without ever referencing `FirebaseJwt` directly.
## Documentation
See the bootstrapping and strategy binding guides at [phpnomad.com](https://phpnomad.com). For details on the underlying library, configuration options, and supported algorithms, see [firebase/php-jwt](https://github.com/firebase/php-jwt).
## License
Released under the MIT License. See [LICENSE.txt](LICENSE.txt).