Skip to content

Commit

Permalink
split up keycloak auth0 in ActionServiceProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasVHG committed Jun 20, 2024
1 parent 9e9459b commit eab43aa
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions app/ActionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ public function register(): void
$this->get(Auth0::class),
new Authentication(
[
'domain' => $this->parameter('auth0.domain'),
'clientId' => $this->parameter('auth0.client_id'),
'clientSecret' => $this->parameter('auth0.client_secret'),
'cookieSecret' => $this->parameter('auth0.cookie_secret'),
'domain' => $this->parameter($this->getIdentityProvider() . '.domain'),
'clientId' => $this->parameter($this->getIdentityProvider() . '.client_id'),
'clientSecret' => $this->parameter($this->getIdentityProvider() . '.client_secret'),
'cookieSecret' => $this->parameter($this->getIdentityProvider() . '.cookie_secret'),
]
),
$this->get(ResponseFactoryInterface::class),
new UriFactory(),
$this->parameter('auth0.log_out_uri'),
$this->parameter('auth0.client_id')
$this->parameter($this->getIdentityProvider() . '.log_out_uri'),
$this->parameter($this->getIdentityProvider() . '.client_id')
)
);

Expand All @@ -127,25 +127,26 @@ public function register(): void
RefreshServiceInterface::class,
fn (): RefreshAuth0Adapter => new RefreshAuth0Adapter(
new Client(),
$this->parameter('auth0.client_id'),
$this->parameter('auth0.client_secret'),
$this->parameter('auth0.domain')
$this->parameter($this->getIdentityProvider() . '.client_id'),
$this->parameter($this->getIdentityProvider() . '.client_secret'),
$this->parameter($this->getIdentityProvider() . '.domain'),
$this->getIdentityProvider()
)
);

$this->addShared(
Auth0::class,
fn (): Auth0 => new Auth0(
[
'domain' => $this->parameter('auth0.domain'),
'clientId' => $this->parameter('auth0.client_id'),
'clientSecret' => $this->parameter('auth0.client_secret'),
'redirectUri' => $this->parameter('auth0.redirect_uri'),
'domain' => $this->parameter($this->getIdentityProvider() . '.domain'),
'clientId' => $this->parameter($this->getIdentityProvider() . '.client_id'),
'clientSecret' => $this->parameter($this->getIdentityProvider() . '.client_secret'),
'redirectUri' => $this->parameter($this->getIdentityProvider() . '.redirect_uri'),
'scope' => ['openid','email','profile','offline_access'],
'persistIdToken' => true,
'persistRefreshToken' => true,
'tokenLeeway' => $this->parameter('auth0.id_token_leeway'),
'cookieSecret' => $this->parameter('auth0.cookie_secret'),
'tokenLeeway' => $this->parameter($this->getIdentityProvider() . '.id_token_leeway'),
'cookieSecret' => $this->parameter($this->getIdentityProvider() . '.cookie_secret'),
]
)
);
Expand All @@ -154,7 +155,7 @@ public function register(): void
IsAllowedRefreshToken::class,
fn (): IsAllowedRefreshToken => new IsAllowedRefreshToken(
$this->get(ConsumerReadRepositoryInterface::class),
(string)$this->parameter('auth0.allowed_refresh_permission')
(string)$this->parameter($this->getIdentityProvider() . '.allowed_refresh_permission')
)
);

Expand All @@ -178,4 +179,12 @@ function (): SessionClientInformation {
)
);
}

private function getIdentityParameter(): string
{
if ($this->parameter('keycloak.enabled')) {
return 'keycloak';
}
return 'auth0';
}
}

0 comments on commit eab43aa

Please sign in to comment.