composer require ataccama/keycloak-adapter
Neon config:
parameters:
keycloak:
realmId: your_realm
clientDd: your_client_id
host: https://your.keycloak.com
defaultRedirectUri: https://your.default.url
api:
username: your_username
password: your_password
clientId: your_api_client_id
clientSecret: your_client_secret
services:
- Ataccama\Adapters\Keycloak(%keycloak%)
Create new class and extend class Ataccama\Auth, then you MUST implement all missing methods with your own logic.
Login URL:
$loginUrl = $yourAuthClass->getLoginUrl()
In code use your class like this:
$yourAuthClass->authorize($_GET['code'])
Example (Nette Framework):
// waiting for authorization code from Keycloak
if ($yourAuthClass->authorize($this->getParameter('code'))) {
$this->redirectUrl($yourAuthClass->getRedirectUri());
} else {
if (!$yourAuthClass->isAuthorized()) {
$this->redirectUrl($yourAuthClass->getLoginUrl());
}
}
// check if user is logged in on every page, if not redirect him to Keycloak login page
if (!$yourAuthClass->isAuthorized()) {
$this->redirectUrl($yourAuthClass->getLoginUrl());
}