Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement OpenID Connect and SAML 2.0 #336

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ LDAP_TLS=false

# LDAP logging debugging only
LDAP_LOGGING=false

# Enable local authentication
LOCAL_AUTH_ENABLED=true
# Don't forget to rebuild frontend on changing any environment variables starting with VITE_
# Available languages for the language picker
VITE_AVAILABLE_LOCALES=en,de
Expand Down
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ LDAP_TLS=false
# Attribute by which the user should be found in the LDAP
#LDAP_LOGIN_ATTRIBUTE=uid

# Enable local authentication
LOCAL_AUTH_ENABLED=true
# Don't forget to rebuild frontend on changing any environment variables starting with VITE_
# Available languages for the language picker
VITE_AVAILABLE_LOCALES=en,de
Expand Down
11 changes: 11 additions & 0 deletions app/Auth/OIDC/InvalidConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Auth\OIDC;

class InvalidConfiguration extends \Exception
{
public function __construct()

Check warning on line 7 in app/Auth/OIDC/InvalidConfiguration.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/InvalidConfiguration.php#L7

Added line #L7 was not covered by tests
{
parent::__construct('OIDC configuration could not be retrieved: invalid response from discovery endpoint');

Check warning on line 9 in app/Auth/OIDC/InvalidConfiguration.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/InvalidConfiguration.php#L9

Added line #L9 was not covered by tests
}
}
13 changes: 13 additions & 0 deletions app/Auth/OIDC/NetworkIssue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Auth\OIDC;

use Exception;

class NetworkIssue extends \Exception
{
public function __construct(Exception $e)

Check warning on line 9 in app/Auth/OIDC/NetworkIssue.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/NetworkIssue.php#L9

Added line #L9 was not covered by tests
{
parent::__construct('OIDC configuration could not be retrieved:'.$e->getMessage());

Check warning on line 11 in app/Auth/OIDC/NetworkIssue.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/NetworkIssue.php#L11

Added line #L11 was not covered by tests
}
}
105 changes: 105 additions & 0 deletions app/Auth/OIDC/OIDCController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

namespace App\Auth\OIDC;

use App\Auth\MissingAttributeException;
use App\Http\Controllers\Controller;
use App\Models\SessionData;
use Auth;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Laravel\Socialite\Facades\Socialite;
use Laravel\Socialite\Two\InvalidStateException;

class OIDCController extends Controller
{
public function __construct()

Check warning on line 17 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L17

Added line #L17 was not covered by tests
{
$this->middleware('guest');

Check warning on line 19 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L19

Added line #L19 was not covered by tests
}

public function redirect(Request $request)

Check warning on line 22 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L22

Added line #L22 was not covered by tests
{
if ($request->get('redirect')) {
$request->session()->put('redirect_url', $request->input('redirect'));

Check warning on line 25 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L24-L25

Added lines #L24 - L25 were not covered by tests
}

try {
return Socialite::driver('oidc')->redirect();
} catch(NetworkIssue $e) {
report($e);

Check warning on line 31 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L29-L31

Added lines #L29 - L31 were not covered by tests

return redirect('/external_login?error=network_issue');
} catch(InvalidConfiguration $e) {
report($e);

Check warning on line 35 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L33-L35

Added lines #L33 - L35 were not covered by tests

return redirect('/external_login?error=invalid_configuration');

Check warning on line 37 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L37

Added line #L37 was not covered by tests
}
}

public function logout(Request $request)

Check warning on line 41 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L41

Added line #L41 was not covered by tests
{
if (isset($_REQUEST['logout_token'])) {
$logout_token = $_REQUEST['logout_token'];

Check warning on line 44 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L43-L44

Added lines #L43 - L44 were not covered by tests

$claims = Socialite::driver('oidc')->getLogoutTokenClaims($logout_token);

Check warning on line 46 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L46

Added line #L46 was not covered by tests

$lookupSessions = SessionData::where('key', 'oidc_sub')->where('value', $claims->sub)->get();
foreach ($lookupSessions as $lookupSession) {
$lookupSession->session()->delete();

Check warning on line 50 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L48-L50

Added lines #L48 - L50 were not covered by tests
}
}
}

public function callback(Request $request)

Check warning on line 55 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L55

Added line #L55 was not covered by tests
{
try {
$oidc_raw_user = Socialite::driver('oidc')->user();
} catch(NetworkIssue $e) {
report($e);

Check warning on line 60 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L58-L60

Added lines #L58 - L60 were not covered by tests

return redirect('/external_login?error=network_issue');
} catch(InvalidConfiguration $e) {
report($e);

Check warning on line 64 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L62-L64

Added lines #L62 - L64 were not covered by tests

return redirect('/external_login?error=invalid_configuration');
} catch(ClientException $e) {
report($e);

Check warning on line 68 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L66-L68

Added lines #L66 - L68 were not covered by tests

return redirect('/external_login?error=invalid_configuration');
} catch(InvalidStateException $e) {
report($e);

Check warning on line 72 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L70-L72

Added lines #L70 - L72 were not covered by tests

return redirect('/external_login?error=invalid_state');

Check warning on line 74 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L74

Added line #L74 was not covered by tests
}

// Create new open-id connect user
try {
$oidc_user = new OIDCUser($oidc_raw_user);
} catch(MissingAttributeException $e) {
return redirect('/external_login?error=missing_attributes');

Check warning on line 81 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L79-L81

Added lines #L79 - L81 were not covered by tests
}

// Get eloquent user (existing or new)
$user = $oidc_user->createOrFindEloquentModel();

Check warning on line 85 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L85

Added line #L85 was not covered by tests

// Sync attributes and map roles
$oidc_user->syncWithEloquentModel($user, config('services.oidc.mapping')->roles);

Check warning on line 88 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L88

Added line #L88 was not covered by tests

Auth::login($user);

Check warning on line 90 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L90

Added line #L90 was not covered by tests

session(['session_data' => [
['key'=>'oidc_sub', 'value' => $oidc_user->getRawAttributes()['sub']],
]]);

Check warning on line 94 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L92-L94

Added lines #L92 - L94 were not covered by tests

session()->put('external_auth', 'oidc');
session()->put('oidc_id_token', $oidc_raw_user->accessTokenResponseBody['id_token']);

Check warning on line 97 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L96-L97

Added lines #L96 - L97 were not covered by tests

Log::info('External user :user has been successfully authenticated.', ['user' => $user->getLogLabel(), 'type' => 'oidc']);

Check warning on line 99 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L99

Added line #L99 was not covered by tests

$url = '/external_login';

Check warning on line 101 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L101

Added line #L101 was not covered by tests

return redirect($request->session()->has('redirect_url') ? ($url.'?redirect='.urlencode($request->session()->get('redirect_url'))) : $url);

Check warning on line 103 in app/Auth/OIDC/OIDCController.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCController.php#L103

Added line #L103 was not covered by tests
}
}
13 changes: 13 additions & 0 deletions app/Auth/OIDC/OIDCExtendSocialite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Auth\OIDC;

use SocialiteProviders\Manager\SocialiteWasCalled;

class OIDCExtendSocialite
{
public function handle(SocialiteWasCalled $socialiteWasCalled)
{
$socialiteWasCalled->extendSocialite('oidc', OIDCProvider::class);
}
}
207 changes: 207 additions & 0 deletions app/Auth/OIDC/OIDCProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
<?php

namespace App\Auth\OIDC;

use Cache;
use Exception;
use GuzzleHttp\RequestOptions;
use Http;
use Illuminate\Http\Request;
use SocialiteProviders\Manager\OAuth2\AbstractProvider;
use SocialiteProviders\Manager\OAuth2\User;
use Firebase\JWT\JWK;
use Firebase\JWT\JWT;

class OIDCProvider extends AbstractProvider
{
public const IDENTIFIER = 'OIDC';

protected $scopeSeparator = ' ';

protected $scopes = ['openid'];

public function __construct(Request $request, $clientId, $clientSecret, $redirectUrl, $guzzle = [])

Check warning on line 23 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L23

Added line #L23 was not covered by tests
{
parent::__construct($request, $clientId, $clientSecret, $redirectUrl, $guzzle);

Check warning on line 25 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L25

Added line #L25 was not covered by tests
}

/**
* {@inheritdoc}
*/
public static function additionalConfigKeys()

Check warning on line 31 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L31

Added line #L31 was not covered by tests
{
return ['issuer','ttl','scopes'];

Check warning on line 33 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L33

Added line #L33 was not covered by tests
}

protected function getOIDCConfig($key)

Check warning on line 36 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L36

Added line #L36 was not covered by tests
{
$url = rtrim($this->getConfig('issuer'), '/').'/.well-known/openid-configuration';

Check warning on line 38 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L38

Added line #L38 was not covered by tests

$cacheKey = 'oidc.config.'.md5($url);
$config = Cache::get($cacheKey);

Check warning on line 41 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L40-L41

Added lines #L40 - L41 were not covered by tests

if (!$config) {

Check warning on line 43 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L43

Added line #L43 was not covered by tests
try {
$response = Http::get($url);
} catch(Exception $e) {
throw new NetworkIssue($e);

Check warning on line 47 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L45-L47

Added lines #L45 - L47 were not covered by tests
}

if ($response->successful()) {
$config = $response->json();
Cache::put($cacheKey, $config, $seconds = $this->getConfig('ttl'));

Check warning on line 52 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L50-L52

Added lines #L50 - L52 were not covered by tests
} else {
throw new InvalidConfiguration();

Check warning on line 54 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L54

Added line #L54 was not covered by tests
}
}

$this->redirectUrl = url($this->getConfig('redirect'));

Check warning on line 58 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L58

Added line #L58 was not covered by tests

return $config[$key] ?? null;

Check warning on line 60 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L60

Added line #L60 was not covered by tests
}

/**
* Get public keys
*
* @return array
*/
private function getJWTKeys()

Check warning on line 68 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L68

Added line #L68 was not covered by tests
{
$response = Http::get($this->getOIDCConfig('jwks_uri'));

Check warning on line 70 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L70

Added line #L70 was not covered by tests

return $response->json();

Check warning on line 72 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L72

Added line #L72 was not covered by tests
}

public function getLogoutTokenClaims($logoutToken)

Check warning on line 75 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L75

Added line #L75 was not covered by tests
{
try {
// payload validation
$payload = explode('.', $logoutToken);
$payloadJson = json_decode(base64_decode(str_pad(strtr($payload[1], '-_', '+/'), strlen($payload[1]) % 4, '=', STR_PAD_RIGHT)), true);

Check warning on line 80 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L79-L80

Added lines #L79 - L80 were not covered by tests

$claims = JWT::decode($logoutToken, JWK::parseKeySet($this->getJWTKeys(), 'RS256'), $this->getOIDCConfig('id_token_signing_alg_values_supported'));

Check warning on line 82 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L82

Added line #L82 was not covered by tests

if ($this->verifyLogoutTokenClaims($claims)) {
return $claims;

Check warning on line 85 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L84-L85

Added lines #L84 - L85 were not covered by tests
}
} catch (Exception $ex) {
return false;

Check warning on line 88 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L87-L88

Added lines #L87 - L88 were not covered by tests
}

return false;

Check warning on line 91 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L91

Added line #L91 was not covered by tests
}

private function verifyLogoutTokenClaims($claims)

Check warning on line 94 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L94

Added line #L94 was not covered by tests
{
// Verify that the Logout Token doesn't contain a nonce Claim.
if (isset($claims->nonce)) {
return false;

Check warning on line 98 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L97-L98

Added lines #L97 - L98 were not covered by tests
}

// Verify that the logout token contains the sub
if ( !isset($claims->sub)) {
return false;

Check warning on line 103 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L102-L103

Added lines #L102 - L103 were not covered by tests
}

// Verify that the Logout Token contains an events Claim whose
// value is a JSON object containing the member name
// http://schemas.openid.net/event/backchannel-logout
if (isset($claims->events)) {
$events = (array) $claims->events;
if (!isset($events['http://schemas.openid.net/event/backchannel-logout']) ||
!is_object($events['http://schemas.openid.net/event/backchannel-logout'])) {
return false;

Check warning on line 113 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L109-L113

Added lines #L109 - L113 were not covered by tests
}
} else {
return false;

Check warning on line 116 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L116

Added line #L116 was not covered by tests
}

// Validate the iss
if (strcmp($claims->iss, $this->getOIDCConfig('issuer'))) {
return false;

Check warning on line 121 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L120-L121

Added lines #L120 - L121 were not covered by tests
}

// Validate the aud
$auds = $claims->aud;
$auds = is_array( $auds ) ? $auds : [ $auds ];
if (!in_array($this->config['client_id'], $auds, true)) {
return false;

Check warning on line 128 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L125-L128

Added lines #L125 - L128 were not covered by tests
}

// Validate the iat. At this point we can return true if it is ok
if (!isset($claims->iat) || !((is_int($claims->iat)) && ($claims->iat <= time() + 300))) {
return false;

Check warning on line 133 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L132-L133

Added lines #L132 - L133 were not covered by tests
}

return true;

Check warning on line 136 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L136

Added line #L136 was not covered by tests
}

/**
* {@inheritdoc}
*/
protected function getAuthUrl($state)

Check warning on line 142 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L142

Added line #L142 was not covered by tests
{
$this->setScopes(array_merge($this->scopes, $this->getConfig('scopes')));

Check warning on line 144 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L144

Added line #L144 was not covered by tests

return $this->buildAuthUrlFromBase($this->getOIDCConfig('authorization_endpoint'), $state);

Check warning on line 146 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L146

Added line #L146 was not covered by tests
}

/**
* {@inheritdoc}
*/
protected function getTokenUrl()

Check warning on line 152 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L152

Added line #L152 was not covered by tests
{
return $this->getOIDCConfig('token_endpoint');

Check warning on line 154 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L154

Added line #L154 was not covered by tests
}

/**
* {@inheritdoc}
*/
protected function getUserByToken($token)

Check warning on line 160 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L160

Added line #L160 was not covered by tests
{
$response = $this->getHttpClient()->get($this->getOIDCConfig('userinfo_endpoint'), [
RequestOptions::HEADERS => [
'Authorization' => 'Bearer '.$token,
],
]);

Check warning on line 166 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L162-L166

Added lines #L162 - L166 were not covered by tests

return json_decode((string) $response->getBody(), true);

Check warning on line 168 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L168

Added line #L168 was not covered by tests
}

/**
* {@inheritdoc}
*/
protected function mapUserToObject(array $user)

Check warning on line 174 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L174

Added line #L174 was not covered by tests
{
return (new User())->setRaw($user);

Check warning on line 176 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L176

Added line #L176 was not covered by tests
}

/**
* {@inheritdoc}
*/
protected function getTokenFields($code)

Check warning on line 182 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L182

Added line #L182 was not covered by tests
{
return array_merge(parent::getTokenFields($code), [
'grant_type' => 'authorization_code'
]);

Check warning on line 186 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L184-L186

Added lines #L184 - L186 were not covered by tests
}

public function logout($idToken, $redirect)

Check warning on line 189 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L189

Added line #L189 was not covered by tests
{
$signout_endpoint = $this->getOIDCConfig('end_session_endpoint');

Check warning on line 191 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L191

Added line #L191 was not covered by tests

if (!$signout_endpoint) {
return false;

Check warning on line 194 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L193-L194

Added lines #L193 - L194 were not covered by tests
}

$signout_params = [
'client_id' => $this->config['client_id'],
'id_token_hint' => $idToken,
'post_logout_redirect_uri' => $redirect,
];

Check warning on line 201 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L197-L201

Added lines #L197 - L201 were not covered by tests

$signout_endpoint .= (strpos($signout_endpoint, '?') === false ? '?' : '&') . http_build_query( $signout_params, '', '&');

Check warning on line 203 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L203

Added line #L203 was not covered by tests

return $signout_endpoint;

Check warning on line 205 in app/Auth/OIDC/OIDCProvider.php

View check run for this annotation

Codecov / codecov/patch

app/Auth/OIDC/OIDCProvider.php#L205

Added line #L205 was not covered by tests
}
}