|
1 |
| -Auto-generated README for nl-rdo-openid-connect-php-laravel |
| 1 | +# OpenID Connect Package for Laravel |
| 2 | +This package is an OpenID Connect implementation for Laravel, based on the [jumbojett/OpenID-Connect-PHP](https://github.com/jumbojett/OpenID-Connect-PHP) package. It provides a convenient way to integrate OpenID Connect into your Laravel application. |
| 3 | + |
| 4 | +## Requirements |
| 5 | +Before using the OpenID Connect package for Laravel, ensure that your development environment meets the following requirements: |
| 6 | + |
| 7 | +- PHP 8.1 or higher: The package requires at least PHP version 8.1. Make sure you have PHP installed and configured properly on your system. |
| 8 | +- Laravel: The package is designed to work with Laravel, so you should have a Laravel application set up and running. |
| 9 | +- Composer: Composer is a dependency manager for PHP. You will need Composer installed to install and manage the package and its dependencies. |
| 10 | + |
| 11 | +If your environment meets these requirements, you can proceed with the installation and configuration of the OpenID Connect package. |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +You can install the package via Composer package manager: |
| 16 | + |
| 17 | +```bash |
| 18 | +composer require minvws/openid-connect-php-laravel |
| 19 | +``` |
| 20 | + |
| 21 | +For Laravel, publish the configuration file: |
| 22 | + |
| 23 | +```bash |
| 24 | +php artisan vendor:publish --provider="MinVWS\OpenIDConnect\OpenIDConnectServiceProvider" |
| 25 | +``` |
| 26 | + |
| 27 | +This command will publish the configuration file to your Laravel application's config directory. The configuration file is named `oidc.php`. |
| 28 | + |
| 29 | + |
| 30 | +## Configuration |
| 31 | +To use this package, you need to configure the following variables in your Laravel application's .env file or through environment variables: |
| 32 | + |
| 33 | +- `OIDC_ISSUER`: The issuer URL of the OpenID Connect provider. |
| 34 | +- `OIDC_CLIENT_ID`: The client ID of the OpenID Connect provider. |
| 35 | +- `OIDC_CLIENT_SECRET`: If needed, the client secret of the OpenID Connect provider. |
| 36 | +- `OIDC_DECRYPTION_KEY_PATH`: Only needed when the response of the user info endpoint is encrypted. This is the path to the JWE decryption key. |
| 37 | +- `OIDC_ADDITIONAL_SCOPES`: By default, the openid scope is requested. If you need additional scopes, you can specify them here as a comma-separated list. |
| 38 | +- `OIDC_CODE_CHALLENGE_METHOD`: Code Challenge Method used for Proof Key for Code Exchange (PKCE). The default value is S256. |
| 39 | + |
| 40 | +### Cache Configuration |
| 41 | +The package provides a configurable cache for caching the OpenID Connect configuration. You can customize the behavior of the cache using the following configuration options: |
| 42 | + |
| 43 | +- `OIDC_CONFIGURATION_CACHE_DRIVER`: The cache store to use for caching OpenID Connect configuration. |
| 44 | +- `OIDC_CONFIGURATION_CACHE_TTL`: The cache TTL (time-to-live) in seconds for the OpenID Connect configuration. |
| 45 | + |
| 46 | +### Route Configuration |
| 47 | +The package provides a configurable login route for OpenID Connect authentication. You can customize the behavior of the login route using the following configuration options: |
| 48 | + |
| 49 | +- `OIDC_LOGIN_ROUTE_ENABLED`: Enable or disable the login route. Set this value to true or false. |
| 50 | +- `OIDC_LOGIN_ROUTE`: The URL of the login route. |
| 51 | +- `OIDC_LOGIN_ROUTE_MIDDLEWARE`: The middleware that runs on the login route. By default, the web middleware is applied. |
| 52 | +- `OIDC_LOGIN_ROUTE_PREFIX`: The prefix of the login route. |
| 53 | + |
| 54 | +## Usage |
| 55 | +Once you have configured the necessary variables, you can go to the `/oidc/login` route that is available by default. |
| 56 | + |
| 57 | +### Login Route |
| 58 | +The package provides a pre-configured login route for OpenID Connect authentication. The login route is available out of the box and can be accessed at `/oidc/login`. |
| 59 | + |
| 60 | +To enable or disable the login route, you can update the `OIDC_LOGIN_ROUTE_ENABLED` variable in your environment configuration. Set it to true to enable the login route or false to disable it. |
| 61 | +To change the URL of the login route, you can update the `OIDC_LOGIN_ROUTE` variable in your environment configuration. The default value is `/oidc/login`. |
| 62 | + |
| 63 | +### Customizing Login Response |
| 64 | +The package includes a default LoginResponse class that returns a JSON response containing user information. However, you have the flexibility to customize the login response according to your project's needs. |
| 65 | + |
| 66 | +To bind your own implementation of the LoginResponseInterface, you can use the following code in your Laravel application: |
| 67 | +```php |
| 68 | +$this->app->bind(LoginResponseInterface::class, YourCustomLoginResponse::class); |
| 69 | +``` |
| 70 | + |
| 71 | +Replace `YourCustomLoginResponse` with the class name of your custom implementation. By binding your own response class, you can define the desired behavior and format of the login response. |
| 72 | + |
| 73 | +Make sure to implement the `LoginResponseInterface` in your custom response class to ensure compatibility. |
| 74 | + |
| 75 | +## Contributing |
| 76 | +If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the GitHub repository of this package. |
| 77 | + |
| 78 | +## License |
| 79 | +This package is open-source and released under the [European Union Public License version 1.2](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12). You are free to use, modify, and distribute the package in accordance with the terms of the license. |
0 commit comments