Skip to content

A free open source IT asset/license management system

Merge remote-tracking branch 'origin/master' into develop

snipe780222d372fe
diff --cc app/Http/Controllers/Api/AssetsController.php
index 05c81b3cf5,3b1854789a..2fa51dcd17
--- a/app/Http/Controllers/Api/AssetsController.php
+++ b/app/Http/Controllers/Api/AssetsController.php
@@@ -344,7 -345,9 +344,8 @@@ class AssetsController extends Controll
}]);
}
-
+
/**
* Here we're just determining which Transformer (via $transformer) to use based on the
* variables we set earlier on in this method - we default to AssetsTransformer.
diff --cc app/Http/Controllers/Auth/LoginController.php
index 7581e61bed,ee7551c6b1..5f15918a92
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@@ -68,20 -75,20 +68,21 @@@ class LoginController extends Controlle
return redirect()->intended('/');
}
- // If the environment is set to ALWAYS require SAML, go straight to the SAML route.
- // We don't need to check other settings, as this should override those.
- if (config('app.require_saml')) {
- return redirect()->route('saml.login');
- }
+ if (!$request->session()->has('loggedout')) {
+ // If the environment is set to ALWAYS require SAML, go straight to the SAML route.
+ // We don't need to check other settings, as this should override those.
+ if (config('app.require_saml')) {
+ return redirect()->route('saml.login');
+ }
- if ($this->saml->isEnabled() && Setting::getSettings()->saml_forcelogin == "1" && !($request->has('nosaml') || $request->session()->has('error'))) {
- return redirect()->route('saml.login');
+ if ($this->saml->isEnabled() && Setting::getSettings()->saml_forcelogin == '1' && ! ($request->has('nosaml') || $request->session()->has('error'))) {
+ return redirect()->route('saml.login');
+ }
}
-
- if (Setting::getSettings()->login_common_disabled == "1") {
+ if (Setting::getSettings()->login_common_disabled == '1') {
+ \Log::debug('login_common_disabled is set to 1 - return a 403');
return view('errors.403');
}
@@@ -103,13 -110,18 +104,18 @@@
*/
private function loginViaSaml(Request $request)
{
+ \Log::debug('Attempting to login via SAML');
$saml = $this->saml;
$samlData = $request->session()->get('saml_login');
+
- if ($saml->isEnabled() && !empty($samlData)) {
+ if ($saml->isEnabled() && ! empty($samlData)) {
+ \Log::debug('SAML is enabled, and the samleData is not empty');
+
try {
- Log::debug("Attempting to log user in by SAML authentication.");
+ Log::debug('Attempting to log user in by SAML authentication.');
$user = $saml->samlLogin($samlData);
- if (! is_null($user)) {
+
+ if (!is_null($user)) {
Auth::login($user);
} else {
$username = $saml->getUsername();
@@@ -122,11 -134,26 +128,26 @@@
$user->last_login = \Carbon::now();
$user->save();
}
+
} catch (\Exception $e) {
- \Log::warning("There was an error authenticating the SAML user: " . $e->getMessage());
+ \Log::warning('There was an error authenticating the SAML user: '.$e->getMessage());
throw new \Exception($e->getMessage());
}
+
+ // Fallthrough with better logging
+ } else {
+
+ // Better logging
+ if (!$saml->isEnabled()) {
+ \Log::warning("SAML page requested, but SAML does not seem to enabled.");
+ } else {
+ \Log::warning("SAML page requested, but samlData seems empty.");
+ }
}
+
+ \Log::warning("Something else went wrong while trying to login as SAML user");
+
+
}
/**
@@@ -244,7 -233,8 +266,8 @@@
return view('errors.403');
}
- if (Setting::getSettings()->login_common_disabled == "1") {
+ if (Setting::getSettings()->login_common_disabled == '1') {
+ \Log::debug('login_common_disabled is set to 1 - return a 403');
return view('errors.403');
}
diff --cc app/Http/Controllers/Auth/SamlController.php
index 41eda91d9c,a54f71db16..d84ae2601a
--- a/app/Http/Controllers/Auth/SamlController.php
+++ b/app/Http/Controllers/Auth/SamlController.php
@@@ -51,9 -51,10 +51,10 @@@ class SamlController extends Controlle
$metadata = $this->saml->getSPMetadata();
if (empty($metadata)) {
+ \Log::debug('SAML metadata is empty - return a 403');
return response()->view('errors.403', [], 403);
}
-
+
return response()->streamDownload(function () use ($metadata) {
echo $metadata;
}, 'snipe-it-metadata.xml', ['Content-Type' => 'text/xml']);
diff --cc app/Presenters/LicensePresenter.php
index cce2a8ecd5,bcfcb3770e..1e8784f2fc
--- a/app/Presenters/LicensePresenter.php
+++ b/app/Presenters/LicensePresenter.php
@@@ -189,57 -191,65 +189,65 @@@ class LicensePresenter extends Presente
public static function dataTableLayoutSeats()
{
$layout = [
+ [
+ 'field' => 'id',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'title' => trans('general.id'),
+ 'visible' => false,
+ ],
[
- "field" => "name",
- "searchable" => false,
- "sortable" => false,
- "sorter" => "numericOnly",
- "switchable" => true,
- "title" => trans('admin/licenses/general.seat'),
- "visible" => true,
+ 'field' => 'name',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'sorter' => 'numericOnly',
+ 'switchable' => true,
+ 'title' => trans('admin/licenses/general.seat'),
+ 'visible' => true,
], [
- "field" => "assigned_user",
- "searchable" => false,
- "sortable" => false,
- "switchable" => true,
- "title" => trans('admin/licenses/general.user'),
- "visible" => true,
- "formatter" => "usersLinkObjFormatter"
+ 'field' => 'assigned_user',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('admin/licenses/general.user'),
+ 'visible' => true,
+ 'formatter' => 'usersLinkObjFormatter',
], [
- "field" => "department",
- "searchable" => false,
- "sortable" => true,
- "switchable" => true,
- "title" => trans('general.department'),
- "visible" => false,
- "formatter" => "departmentNameLinkFormatter"
+ 'field' => 'department',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'title' => trans('general.department'),
+ 'visible' => false,
+ 'formatter' => 'departmentNameLinkFormatter',
],
[
- "field" => "assigned_asset",
- "searchable" => false,
- "sortable" => false,
- "switchable" => true,
- "title" => trans('admin/licenses/form.asset'),
- "visible" => true,
- "formatter" => "hardwareLinkObjFormatter"
+ 'field' => 'assigned_asset',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('admin/licenses/form.asset'),
+ 'visible' => true,
+ 'formatter' => 'hardwareLinkObjFormatter',
], [
- "field" => "location",
- "searchable" => false,
- "sortable" => false,
- "switchable" => true,
- "title" => trans('general.location'),
- "visible" => true,
- "formatter" => "locationsLinkObjFormatter"
+ 'field' => 'location',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('general.location'),
+ 'visible' => true,
+ 'formatter' => 'locationsLinkObjFormatter',
],
[
- "field" => "checkincheckout",
- "searchable" => false,
- "sortable" => false,
- "switchable" => true,
- "title" => trans('general.checkin').'/'.trans('general.checkout'),
- "visible" => true,
- "formatter" => "licenseSeatInOutFormatter"
- ]
+ 'field' => 'checkincheckout',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('general.checkin').'/'.trans('general.checkout'),
+ 'visible' => true,
+ 'formatter' => 'licenseSeatInOutFormatter',
+ ],
];
return json_encode($layout);