// keycloak.php
'input_key' => 'api_token'
// If there is no Bearer token on request it will use `api_token` request param
GET $this->get("/foo/secret?api_token=xxxxx")
POST $this->post("/foo/secret", ["api_token" => "xxxxx"])
...
'defaults' => [
'guard' => 'api', # <-- For sure, i`m building an API
'passwords' => 'users',
],
....
'guards' => [
# <!-----
# Make sure your "api" guard looks like this.
# Newer Laravel versions just removed this config block.
# ---->
'api' => [
'driver' => 'keycloak',
'provider' => 'users',
],
],
// public endpoints
$router->get('/hello', function () {
return ':)';
});
// protected endpoints
$router->group(['middleware' => 'auth'], function () {
$router->get('/protected-endpoint', 'SecretController@index');
// more endpoints ...
});
$token = Auth::token() // or Auth::user()->token()