Repository navigation
Release Note: tykfyr/openid-connect-php
The tykfyr/openid-connect-php package is a simple OpenID Connect client library for PHP, designed to facilitate the integration of OpenID Connect authentication into PHP applications.
Key Features
- Full OpenID Connect authentication flow
- Automatic provider configuration discovery
- JWT token validation
- User Info endpoint support
- Configurable SSL verification
- Proxy support
- Custom scopes support
Installation
Install the package via Composer:
composer require tykfyr/openid-connect-phpBasic Usage
<?php use Tykfyr\OpenIDConnect\Client;// Initialize the client
$oidc = new Client(
'https://your-identity-provider.com',
'your-client-id',
'your-client-secret'
);// Set the redirect URI
$oidc->setRedirectUri('https://your-app.com/callback');// Start authentication
$oidc->authenticate();// In your callback handler
$oidc->handleCallback();
// Get user information
$userInfo = $oidc->requestUserInfo();
$email = $oidc->requestUserInfo('email');
Advanced Configuration Options
- SSL Verification: Configure SSL verification settings to suit your environment
- Custom Certificate Path: Specify a custom certificate path if needed
- Proxy Configuration: Set up HTTP proxy settings for network configurations
- Custom Scopes: Define custom scopes to request specific user information
Security Considerations
- Always use HTTPS in production environments
- Keep your client secret secure and confidential
- Validate the state parameter to prevent CSRF attacks
- Verify the ID token to ensure its authenticity
- Use appropriate scopes to limit access to necessary information
For more detailed information and updates, visit the GitHub repository.