1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Slides\Saml2\Http\Middleware; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
6
|
|
|
use Slides\Saml2\Exceptions\IdentityProviderNotFound; |
7
|
|
|
use Slides\Saml2\Contracts\ResolvesIdentityProvider; |
8
|
|
|
use Illuminate\Support\Facades\Log; |
9
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
|
|
|
10
|
|
|
use Slides\Saml2\OneLoginBuilder; |
11
|
|
|
|
12
|
|
|
class ResolveIdentityProvider |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var ResolvesIdentityProvider |
16
|
|
|
*/ |
17
|
|
|
protected ResolvesIdentityProvider $resolver; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var OneLoginBuilder |
21
|
|
|
*/ |
22
|
|
|
protected OneLoginBuilder $builder; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* ResolveTenant constructor. |
26
|
|
|
* |
27
|
|
|
* @param ResolvesIdentityProvider $resolver |
28
|
|
|
* @param OneLoginBuilder $builder |
29
|
|
|
*/ |
30
|
|
|
public function __construct(ResolvesIdentityProvider $resolver, OneLoginBuilder $builder) |
31
|
|
|
{ |
32
|
|
|
$this->resolver = $resolver; |
33
|
|
|
$this->builder = $builder; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Handle an incoming request. |
38
|
|
|
* |
39
|
|
|
* @param \Illuminate\Http\Request $request |
40
|
|
|
* @param \Closure $next |
41
|
|
|
* |
42
|
|
|
* @throws NotFoundHttpException |
43
|
|
|
* |
44
|
|
|
* @return mixed |
45
|
|
|
*/ |
46
|
|
|
public function handle(Request $request, \Closure $next) |
47
|
|
|
{ |
48
|
|
|
if (!$idp = $this->resolver->resolve($request)) { |
49
|
|
|
throw new IdentityProviderNotFound(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
if (config('saml2.debug')) { |
|
|
|
|
53
|
|
|
Log::debug('[Saml2] Identity Provider resolved', [ |
54
|
|
|
'uuid' => $idp->idpUuid() |
55
|
|
|
]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
session()->flash('saml2.idp.uuid', $idp->idpUuid()); |
|
|
|
|
59
|
|
|
|
60
|
|
|
$this->builder->configureIdp($idp); |
61
|
|
|
|
62
|
|
|
return $next($request); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths