Skip to content

Commit 02fef70

Browse files
committed
Merge remote-tracking branch 'origin/develop'
# Conflicts: # config/version.php
2 parents 98dfb9d + b266000 commit 02fef70

File tree

10 files changed

+85
-27
lines changed

10 files changed

+85
-27
lines changed

app/Http/Controllers/Auth/SamlController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ public function metadata(Request $request)
5353
if (empty($metadata)) {
5454
return response()->view('errors.403', [], 403);
5555
}
56-
57-
return response($metadata)->header('Content-Type', 'text/xml');
56+
57+
return response()->streamDownload(function () use ($metadata) {
58+
echo $metadata;
59+
}, 'snipe-it-metadata.xml', ['Content-Type' => 'text/xml']);
5860
}
5961

6062
/**

app/Http/Kernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Kernel extends HttpKernel
3838
\App\Http\Middleware\CheckLocale::class,
3939
\App\Http\Middleware\CheckForTwoFactor::class,
4040
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
41+
\App\Http\Middleware\AssetCountForSidebar::class,
4142
],
4243

4344
'api' => [
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Auth;
6+
use App\Models\Asset;
7+
use Closure;
8+
9+
class AssetCountForSidebar
10+
{
11+
/**
12+
* Handle an incoming request.
13+
*
14+
* @param \Illuminate\Http\Request $request
15+
* @param \Closure $next
16+
* @return mixed
17+
*/
18+
public function handle($request, Closure $next)
19+
{
20+
$total_rtd_sidebar = Asset::RTD()->count();
21+
$total_deployed_sidebar = Asset::Deployed()->count();
22+
$total_archived_sidebar = Asset::Archived()->count();
23+
$total_pending_sidebar = Asset::Pending()->count();
24+
$total_undeployable_sidebar = Asset::Undeployable()->count();
25+
view()->share('total_rtd_sidebar', $total_rtd_sidebar);
26+
view()->share('total_deployed_sidebar', $total_deployed_sidebar);
27+
view()->share('total_archived_sidebar', $total_archived_sidebar);
28+
view()->share('total_pending_sidebar', $total_pending_sidebar);
29+
view()->share('total_undeployable_sidebar', $total_undeployable_sidebar);
30+
31+
return $next($request);
32+
}
33+
}

app/Http/Requests/SettingsSamlRequest.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,27 @@ public function withValidator($validator)
7070
]);
7171

7272
$csr = openssl_csr_new($dn, $pkey, ['digest_alg' => 'sha256']);
73-
74-
$x509 = openssl_csr_sign($csr, null, $pkey, 3650, ['digest_alg' => 'sha256']);
7573

76-
openssl_x509_export($x509, $x509cert);
77-
openssl_pkey_export($pkey, $privateKey);
74+
if ($csr) {
7875

79-
$errors = [];
80-
while (($error = openssl_error_string() !== false)) {
81-
$errors[] = $error;
82-
}
83-
84-
if (!(empty($x509cert) && empty($privateKey))) {
85-
$this->merge([
86-
'saml_sp_x509cert' => $x509cert,
87-
'saml_sp_privatekey' => $privateKey,
88-
]);
76+
$x509 = openssl_csr_sign($csr, null, $pkey, 3650, ['digest_alg' => 'sha256']);
77+
78+
openssl_x509_export($x509, $x509cert);
79+
openssl_pkey_export($pkey, $privateKey);
80+
81+
$errors = [];
82+
while (($error = openssl_error_string() !== false)) {
83+
$errors[] = $error;
84+
}
85+
86+
if (!(empty($x509cert) && empty($privateKey))) {
87+
$this->merge([
88+
'saml_sp_x509cert' => $x509cert,
89+
'saml_sp_privatekey' => $privateKey,
90+
]);
91+
}
92+
} else {
93+
$validator->errors()->add('saml_integration', 'openssl.cnf is missing/invalid');
8994
}
9095
}
9196

app/Models/User.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
7070
* @var array
7171
*/
7272

73+
// 'username' => 'required|string|min:1|unique:users,username,NULL,id,deleted_at,NULL',
7374
protected $rules = [
7475
'first_name' => 'required|string|min:1',
7576
'username' => 'required|string|min:1|unique_undeleted',

app/Services/Saml.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use OneLogin\Saml2\Auth as OneLogin_Saml2_Auth;
66
use OneLogin\Saml2\IdPMetadataParser as OneLogin_Saml2_IdPMetadataParser;
77
use OneLogin\Saml2\Settings as OneLogin_Saml2_Settings;
8+
use OneLogin\Saml2\Utils as OneLogin_Saml2_Utils;
89
use App\Models\Setting;
910
use App\Models\User;
1011
use Exception;
@@ -153,6 +154,9 @@ private function loadSettings()
153154
$this->_enabled = $setting->saml_enabled == '1';
154155

155156
if ($this->isEnabled()) {
157+
//Let onelogin/php-saml know to use 'X-Forwarded-*' headers if it is from a trusted proxy
158+
OneLogin_Saml2_Utils::setProxyVars(request()->isFromTrustedProxy());
159+
156160
data_set($settings, 'sp.entityId', url('/'));
157161
data_set($settings, 'sp.assertionConsumerService.url', route('saml.acs'));
158162
data_set($settings, 'sp.singleLogoutService.url', route('saml.sls'));

config/version.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22
return array (
3-
'app_version' => 'v5.0.7',
4-
'full_app_version' => 'v5.0.7 - build 5615-g6eb860ca2',
5-
'build_version' => '5615',
3+
'app_version' => 'v5.0.8',
4+
'full_app_version' => 'v5.0.8 - build 5616-8a38b9d',
5+
'build_version' => '5616',
66
'prerelease_version' => '',
7-
'hash_version' => 'g6eb860ca2',
8-
'full_hash' => 'v5.0.7-87-g6eb860ca2',
7+
'hash_version' => '8a38b9d',
8+
'full_hash' => 'v5.0.8-87-8a38b9d',
99
'branch' => 'master',
1010
);

resources/lang/en/admin/settings/general.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
'saml_sp_acs_url' => 'Assertion Consumer Service (ACS) URL',
126126
'saml_sp_sls_url' => 'Single Logout Service (SLS) URL',
127127
'saml_sp_x509cert' => 'Public Certificate',
128+
'saml_sp_metadata_url' => 'Metadata URL',
128129
'saml_idp_metadata' => 'SAML IdP Metadata',
129130
'saml_idp_metadata_help' => 'You can specify the IdP metadata using a URL or XML file.',
130131
'saml_attr_mapping_username' => 'Attribute Mapping - Username',

resources/views/layouts/default.blade.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,46 +403,52 @@
403403
</a>
404404
<ul class="treeview-menu">
405405
<li>
406-
<a href="{{ url('hardware') }}">
406+
<a href="{{ url('hardware') }}">
407+
<i class="fa fa-circle-o text-grey" aria-hidden="true"></i>
407408
{{ trans('general.list_all') }}
408409
</a>
409410
</li>
410411

411-
<?php $status_navs = \App\Models\Statuslabel::where('show_in_nav', '=', 1)->get(); ?>
412+
<?php $status_navs = \App\Models\Statuslabel::where('show_in_nav', '=', 1)->withCount('assets as asset_count')->get(); ?>
412413
@if (count($status_navs) > 0)
413-
<li class="divider">&nbsp;</li>
414414
@foreach ($status_navs as $status_nav)
415-
<li><a href="{{ route('statuslabels.show', ['statuslabel' => $status_nav->id]) }}"}> {{ $status_nav->name }}</a></li>
415+
<li><a href="{{ route('statuslabels.show', ['statuslabel' => $status_nav->id]) }}"><i class="fa fa-circle text-grey" aria-hidden="true"></i> {{ $status_nav->name }} ({{ $status_nav->asset_count }})</a></li>
416416
@endforeach
417417
@endif
418418

419419

420420
<li{!! (Request::query('status') == 'Deployed' ? ' class="active"' : '') !!}>
421-
<a href="{{ url('hardware?status=Deployed') }}"><i class="fa fa-circle-o text-blue"></i>
421+
<a href="{{ url('hardware?status=Deployed') }}">
422+
<i class="fa fa-circle-o text-blue"></i>
422423
{{ trans('general.all') }}
423424
{{ trans('general.deployed') }}
425+
({{ ($total_deployed_sidebar) ? $total_deployed_sidebar : '' }})
424426
</a>
425427
</li>
426428
<li{!! (Request::query('status') == 'RTD' ? ' class="active"' : '') !!}>
427429
<a href="{{ url('hardware?status=RTD') }}">
428430
<i class="fa fa-circle-o text-green"></i>
429431
{{ trans('general.all') }}
430432
{{ trans('general.ready_to_deploy') }}
433+
({{ ($total_rtd_sidebar) ? $total_rtd_sidebar : '' }})
431434
</a>
432435
</li>
433436
<li{!! (Request::query('status') == 'Pending' ? ' class="active"' : '') !!}><a href="{{ url('hardware?status=Pending') }}"><i class="fa fa-circle-o text-orange"></i>
434437
{{ trans('general.all') }}
435438
{{ trans('general.pending') }}
439+
({{ ($total_pending_sidebar) ? $total_pending_sidebar : '' }})
436440
</a>
437441
</li>
438442
<li{!! (Request::query('status') == 'Undeployable' ? ' class="active"' : '') !!} ><a href="{{ url('hardware?status=Undeployable') }}"><i class="fa fa-times text-red"></i>
439443
{{ trans('general.all') }}
440444
{{ trans('general.undeployable') }}
445+
({{ ($total_undeployable_sidebar) ? $total_undeployable_sidebar : '' }})
441446
</a>
442447
</li>
443448
<li{!! (Request::query('status') == 'Archived' ? ' class="active"' : '') !!}><a href="{{ url('hardware?status=Archived') }}"><i class="fa fa-times text-red"></i>
444449
{{ trans('general.all') }}
445450
{{ trans('admin/hardware/general.archived') }}
451+
({{ ($total_archived_sidebar) ? $total_archived_sidebar : '' }})
446452
</a>
447453
</li>
448454
<li{!! (Request::query('status') == 'Requestable' ? ' class="active"' : '') !!}><a href="{{ url('hardware?status=Requestable') }}"><i class="fa fa-check text-blue"></i>

resources/views/settings/saml.blade.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656
{{ Form::checkbox('saml_enabled', '1', Request::old('saml_enabled', $setting->saml_enabled), [((config('app.lock_passwords')===true)) ? 'disabled ': '', 'class' => 'minimal '. $setting->demoMode, $setting->demoMode]) }}
5757
{{ trans('admin/settings/general.saml_enabled') }}
58+
{!! $errors->first('saml_integration', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}<br>
5859
@if (config('app.lock_passwords')===true)
5960
<p class="text-warning"><i class="fa fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
6061
@endif
@@ -82,8 +83,12 @@
8283
{{ Form::textarea('saml_sp_x509cert', $setting->saml_sp_x509cert, ['class' => 'form-control', 'wrap' => 'off', 'readonly']) }}
8384
<br>
8485
@endif
86+
<!-- SAML SP Metadata URL -->
87+
{{ Form::label('saml_sp_metadata_url', trans('admin/settings/general.saml_sp_metadata_url')) }}
88+
{{ Form::text('saml_sp_metadata_url', route('saml.metadata'), ['class' => 'form-control', 'readonly']) }}
89+
<br>
8590
<p class="help-block">
86-
<a href="{{ route('saml.metadata') }}" target="_blank" class="btn btn-default" style="margin-right: 5px;">View Metadata</a>
91+
<a href="{{ route('saml.metadata') }}" target="_blank" class="btn btn-default" style="margin-right: 5px;">Download Metadata</a>
8792
</p>
8893
@endif
8994
{!! $errors->first('saml_enabled', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}

0 commit comments

Comments
 (0)