-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathAppServiceProvider.php
More file actions
executable file
·87 lines (77 loc) · 2.37 KB
/
AppServiceProvider.php
File metadata and controls
executable file
·87 lines (77 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace App\Providers;
use DB;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use LdapRecord\Container;
use Log;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if (
(App::environment('production') && (Config::get('app.force_https') === null))
||
Config::get('app.force_https')
) {
URL::forceScheme('https');
}
if (config('app.debug')) {
DB::listen(function ($query) {
Log::info(
$query->sql,
$query->bindings
);
});
}
// Si le logging LDAP est activé, on force l’utilisation du channel "ldap"
if (config('ldap.logging.enabled')) {
Container::setLogger(
Log::channel('ldap')
);
}
if (in_array('keycloak', Config::get('services.socialite_controller.providers'))) {
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
$event->extendSocialite('keycloak', \SocialiteProviders\Keycloak\Provider::class);
});
}
if (in_array('oidc', Config::get('services.socialite_controller.providers'))) {
$this->bootOIDCSocialite();
}
// Show appVersion from version.txt in Blades
view()->composer('*', function ($view) {
$version = trim(file_get_contents(base_path('version.txt')));
$view->with('appVersion', $version);
});
}
/**
* Register Generic OpenID Connect Provider.
*/
private function bootOIDCSocialite()
{
$socialite = $this->app->make('Laravel\Socialite\Contracts\Factory');
$socialite->extend(
'oidc',
function ($app) use ($socialite) {
$config = $app['config']['services.oidc'];
return $socialite->buildProvider(\App\Providers\Socialite\GenericSocialiteProvider::class, $config);
}
);
}
}