Skip to content

Commit

Permalink
added keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Eelen committed Jul 16, 2024
1 parent 1369553 commit 09244a4
Show file tree
Hide file tree
Showing 4 changed files with 1,188 additions and 673 deletions.
47 changes: 26 additions & 21 deletions app/Auth/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,14 @@ public function register(Application $app): void
{
$app[Auth0::class] = $app::share(
function (Application $app) {
if ($app['config']['keycloak']['enable']) {
return new Auth0(
$this->getParams($app['config']['keycloak'])
);
}

return new Auth0(
[
'domain' => $app['config']['auth0']['domain'],
'client_id' => $app['config']['auth0']['client_id'],
'client_secret' => $app['config']['auth0']['client_secret'],
'redirect_uri' => $app['config']['auth0']['callback_url'],
'scope' => implode(
' ',
[
'openid',
'email',
'profile',
'offline_access',
'https://api.publiq.be/auth/uitpas_balie',
'https://api.publiq.be/auth/uitpas_balie_insights',
]
),
'audience' => 'https://api.publiq.be',
'persist_id_token' => false,
'id_token_leeway' => 30,
]
$this->getParams($app['config']['auth0'])
);
}
);
Expand All @@ -53,4 +40,22 @@ public function boot(Application $app): void
{

}
}

private function getParams(array $auth) : array
{
return [
'domain' => $auth['domain'],
'clientId' => $auth['client_id'],
'clientSecret' => $auth['client_secret'],
'cookieSecret' => $auth['cookieSecret'],
'redirectUri' => $auth['callback_url'],
'scope' => [
'openid',
'email',
'profile',
'offline_access',
],
'audience' => ['https://api.publiq.be'],
];
}
}
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"cultuurnet/hydra": "~0.1",
"2dotstwice/collection": "~1.0",
"monolog/monolog": "^1.17.2",
"auth0/auth0-php": "7.5.0"
"auth0/auth0-php": "^8.3",
"symfony/http-client": "^5.4",
"nyholm/psr7": "^1.8"
},
"require-dev": {
"escapestudios/symfony2-coding-standard": "~2.0",
Expand All @@ -52,5 +54,10 @@
"scripts": {
"phing": "./vendor/bin/phing test",
"test": "./vendor/bin/phpunit"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
Loading

0 comments on commit 09244a4

Please sign in to comment.