1. Go to this page and download the library: Download drenso/symfony-oidc-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
drenso / symfony-oidc-bundle example snippets
composer
/**
* This controller forwards the user to the OIDC login
*
* @throws \Drenso\OidcBundle\Exception\OidcException
*/
#[Route('/login_oidc', name: 'login_oidc')]
#[IsGranted('PUBLIC_ACCESS')]
public function surfconext(OidcClientInterface $oidcClient): RedirectResponse
{
// Redirect to authorization @ OIDC provider
return $oidcClient->generateAuthorizationRedirect();
}
public function surfconext(OidcClientLocator $clientLocator): RedirectResponse
{
return $clientLocator->getClient('your_client_id')->generateAuthorizationRedirect();
}
namespace App\Security;
use App\Security\Constraint\HasAudienceContaining;
use Drenso\OidcBundle\Enum\OidcTokenType;
use Drenso\OidcBundle\OidcTokenConstraintProviderInterface;
class AdditionalTokenConstraintProvider implements OidcTokenConstraintProviderInterface
{
public function getAdditionalConstraints(OidcTokenType $tokenType): array
{
if (OidcTokenType::ID === $tokenType) {
return [
new HasAudienceContaining('abc123'),
];
}
if (OidcTokenType::ACCESS === $tokenType) {
return [
new HasAudienceContaining('def456'),
];
}
return [];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.