Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <[email protected]>

# Conflicts:
#	public/css/dist/all.css
#	public/css/dist/bootstrap-table.css
#	public/js/dist/bootstrap-table.js
#	public/mix-manifest.json
  • Loading branch information
snipe committed Apr 26, 2023
2 parents 9529cd8 + 470a36a commit 42f0975
Show file tree
Hide file tree
Showing 24 changed files with 93 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
with:
context: .
file: ./Dockerfile.alpine
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
# but we ONLY do an image push to DockerHub if it's NOT a PR
push: ${{ github.event_name != 'pull_request' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
# but we ONLY do an image push to DockerHub if it's NOT a PR
push: ${{ github.event_name != 'pull_request' }}
Expand Down
7 changes: 6 additions & 1 deletion app/Console/Commands/LdapSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function handle()
$ldap_result_phone = Setting::getSettings()->ldap_phone_field;
$ldap_result_jobtitle = Setting::getSettings()->ldap_jobtitle;
$ldap_result_country = Setting::getSettings()->ldap_country;
$ldap_result_location = Setting::getSettings()->ldap_location;
$ldap_result_dept = Setting::getSettings()->ldap_dept;
$ldap_result_manager = Setting::getSettings()->ldap_manager;
$ldap_default_group = Setting::getSettings()->ldap_default_group;
Expand Down Expand Up @@ -209,8 +210,11 @@ public function handle()
$item['country'] = $results[$i][$ldap_result_country][0] ?? '';
$item['department'] = $results[$i][$ldap_result_dept][0] ?? '';
$item['manager'] = $results[$i][$ldap_result_manager][0] ?? '';
$item['location'] = $results[$i][$ldap_result_location][0] ?? '';


$location = Location::firstOrCreate([
'name' => $item['location'],
]);
$department = Department::firstOrCreate([
'name' => $item['department'],
]);
Expand All @@ -236,6 +240,7 @@ public function handle()
$user->jobtitle = $item['jobtitle'];
$user->country = $item['country'];
$user->department_id = $department->id;
$user->location_id = $location->id;

if($item['manager'] != null) {
// Check Cache first
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ public function postLdapSettings(Request $request)
$setting->ldap_phone_field = $request->input('ldap_phone');
$setting->ldap_jobtitle = $request->input('ldap_jobtitle');
$setting->ldap_country = $request->input('ldap_country');
$setting->ldap_location = $request->input('ldap_location');
$setting->ldap_dept = $request->input('ldap_dept');
$setting->ldap_client_tls_cert = $request->input('ldap_client_tls_cert');
$setting->ldap_client_tls_key = $request->input('ldap_client_tls_key');
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public static function parseAndMapLdapAttributes($ldapattributes)
$ldap_result_phone = Setting::getSettings()->ldap_phone;
$ldap_result_jobtitle = Setting::getSettings()->ldap_jobtitle;
$ldap_result_country = Setting::getSettings()->ldap_country;
$ldap_result_location = Setting::getSettings()->ldap_location;
$ldap_result_dept = Setting::getSettings()->ldap_dept;
$ldap_result_manager = Setting::getSettings()->ldap_manager;
// Get LDAP user data
Expand All @@ -227,6 +228,7 @@ public static function parseAndMapLdapAttributes($ldapattributes)
$item['country'] = $ldapattributes[$ldap_result_country][0] ?? '';
$item['department'] = $ldapattributes[$ldap_result_dept][0] ?? '';
$item['manager'] = $ldapattributes[$ldap_result_manager][0] ?? '';
$item['location'] = $ldapattributes[$ldap_result_location][0] ?? '';

return $item;
}
Expand Down
10 changes: 9 additions & 1 deletion app/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,15 @@ public static function getLdapSettings(): Collection
'ad_domain',
'ad_append_domain',
'ldap_client_tls_key',
'ldap_client_tls_cert'
'ldap_client_tls_cert',
'ldap_default_group',
'ldap_dept',
'ldap_emp_num',
'ldap_phone_field',
'ldap_jobtitle',
'ldap_manager',
'ldap_country',
'ldap_location',
])->first()->getAttributes();

return collect($ldapSettings);
Expand Down
7 changes: 5 additions & 2 deletions app/Models/SnipeSCIMConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public function getUserConfig()
// Map a SCIM attribute to an attribute of the object.
'mapping' => [

'id' => AttributeMapping::eloquent("id")->disableWrite(),
'id' => (new AttributeMapping())->setRead(
function (&$object) {
return (string)$object->id;
}
)->disableWrite(),

'externalId' => AttributeMapping::eloquent('scim_externalid'), // FIXME - I have a PR that changes a lot of this.

Expand Down Expand Up @@ -174,7 +178,6 @@ function (&$object) {
'$ref' => null,
'display' => null,
'type' => null,
'type' => null
]],

'entitlements' => null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddsLdapLocationToSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->string('ldap_location')->after('ldap_country')->nullable()->default(null);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('ldap_location');
});
}
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"vue-template-compiler": "2.4.4"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.3.0",
"@fortawesome/fontawesome-free": "^6.4.0",
"acorn": "^8.8.2",
"acorn-import-assertions": "^1.8.0",
"admin-lte": "^2.4.18",
Expand Down
2 changes: 1 addition & 1 deletion public/css/dist/all.css

Large diffs are not rendered by default.

Binary file modified public/css/webfonts/fa-brands-400.ttf
Binary file not shown.
Binary file modified public/css/webfonts/fa-brands-400.woff2
Binary file not shown.
Binary file modified public/css/webfonts/fa-regular-400.ttf
Binary file not shown.
Binary file modified public/css/webfonts/fa-regular-400.woff2
Binary file not shown.
Binary file modified public/css/webfonts/fa-solid-900.ttf
Binary file not shown.
Binary file modified public/css/webfonts/fa-solid-900.woff2
Binary file not shown.
Binary file modified public/css/webfonts/fa-v4compatibility.ttf
Binary file not shown.
Binary file modified public/css/webfonts/fa-v4compatibility.woff2
Binary file not shown.
2 changes: 1 addition & 1 deletion public/js/dist/bootstrap-table.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
"/css/dist/skins/skin-green.css": "/css/dist/skins/skin-green.css?id=b48f4d8af0e1ca5621c161e93951109f",
"/css/dist/skins/skin-contrast.css": "/css/dist/skins/skin-contrast.css?id=f0fbbb0ac729ea092578fb05ca615460",
"/css/dist/skins/skin-red.css": "/css/dist/skins/skin-red.css?id=b9a74ec0cd68f83e7480d5ae39919beb",
"/css/dist/all.css": "/css/dist/all.css?id=06f08e03169ffa22e079e47d5681a471",
"/css/dist/all.css": "/css/dist/all.css?id=422928bd7d4860a3a4dfe601cf7d9472",
"/css/dist/signature-pad.css": "/css/dist/signature-pad.css?id=6a89d3cd901305e66ced1cf5f13147f7",
"/css/dist/signature-pad.min.css": "/css/dist/signature-pad.min.css?id=6a89d3cd901305e66ced1cf5f13147f7",
"/css/webfonts/fa-brands-400.ttf": "/css/webfonts/fa-brands-400.ttf?id=2df05d4beaa48550d71234e8dca79141",
"/css/webfonts/fa-brands-400.woff2": "/css/webfonts/fa-brands-400.woff2?id=682885a4f72597322017a9fcd0683831",
"/css/webfonts/fa-regular-400.ttf": "/css/webfonts/fa-regular-400.ttf?id=e7a7f9dd9376f68614860d920255d4df",
"/css/webfonts/fa-regular-400.woff2": "/css/webfonts/fa-regular-400.woff2?id=204fc700c679395e6aa9bebc3cada64e",
"/css/webfonts/fa-solid-900.ttf": "/css/webfonts/fa-solid-900.ttf?id=c9d3294ec75b843a31ef711069a0f0b6",
"/css/webfonts/fa-solid-900.woff2": "/css/webfonts/fa-solid-900.woff2?id=6707d0247b0bca1b4964bab435e3c0d6",
"/css/webfonts/fa-v4compatibility.ttf": "/css/webfonts/fa-v4compatibility.ttf?id=a947172f4fde88e43b4c1a60b01db061",
"/css/webfonts/fa-v4compatibility.woff2": "/css/webfonts/fa-v4compatibility.woff2?id=bbc23038a6067c78310d3f19432a3ebf",
"/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=418917c053841ab1aa1b78610a1825e0",
"/css/webfonts/fa-brands-400.ttf": "/css/webfonts/fa-brands-400.ttf?id=e2e2b1797606a266ed55549f5bb5a179",
"/css/webfonts/fa-brands-400.woff2": "/css/webfonts/fa-brands-400.woff2?id=fe912d1c4a7e0e1db87a64eb7e54c945",
"/css/webfonts/fa-regular-400.ttf": "/css/webfonts/fa-regular-400.ttf?id=31a6b5ecfc8d018d0e3a294f0c80e9e9",
"/css/webfonts/fa-regular-400.woff2": "/css/webfonts/fa-regular-400.woff2?id=bf8eabe300a00a3adb0293596987abc4",
"/css/webfonts/fa-solid-900.ttf": "/css/webfonts/fa-solid-900.ttf?id=cd687455c6d6c058e2e9f84f409e2965",
"/css/webfonts/fa-solid-900.woff2": "/css/webfonts/fa-solid-900.woff2?id=eea38615e7b5dbbaf88c263f2230cc32",
"/css/webfonts/fa-v4compatibility.ttf": "/css/webfonts/fa-v4compatibility.ttf?id=6ebbf5afc34f54463abc2b81ca637364",
"/css/webfonts/fa-v4compatibility.woff2": "/css/webfonts/fa-v4compatibility.woff2?id=67b8a78b7e80e805cfa4ee0421895ba4",
"/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=2265e072e44c782c901dce8e037d97fc",
"/js/build/vendor.js": "/js/build/vendor.js?id=3843eca1b2e670b29c1e1cb57e1d7aa7",
"/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=7a506bf59323cf5b5fe97f7080fc5ee0",
"/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=a0e44dba789031b34ef150a01318b865",
"/js/dist/all.js": "/js/dist/all.js?id=abb8cd9afe481e321ed279c6a2dfed3d",
"/css/dist/skins/skin-green.min.css": "/css/dist/skins/skin-green.min.css?id=b48f4d8af0e1ca5621c161e93951109f",
"/css/dist/skins/skin-green-dark.min.css": "/css/dist/skins/skin-green-dark.min.css?id=15eb3805c9016a4ec8171a69d2830d51",
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en/admin/settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
'ldap_settings' => 'LDAP Settings',
'ldap_client_tls_cert_help' => 'Client-Side TLS Certificate and Key for LDAP connections are usually only useful in Google Workspace configurations with "Secure LDAP." Both are required.',
'ldap_client_tls_key' => 'LDAP Client-Side TLS key',
'ldap_location' => 'LDAP Location',
'ldap_location_help' => 'The Ldap Location field should be used if <strong>an OU is not being used in the Base Bind DN.</strong> Leave this blank if an OU search is being used.',
'ldap_login_test_help' => 'Enter a valid LDAP username and password from the base DN you specified above to test whether your LDAP login is configured correctly. YOU MUST SAVE YOUR UPDATED LDAP SETTINGS FIRST.',
'ldap_login_sync_help' => 'This only tests that LDAP can sync correctly. If your LDAP Authentication query is not correct, users may still not be able to login. YOU MUST SAVE YOUR UPDATED LDAP SETTINGS FIRST.',
'ldap_manager' => 'LDAP Manager',
Expand Down
14 changes: 14 additions & 0 deletions resources/views/settings/ldap.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,20 @@ class="form-control select2"
@endif
</div>
</div>
<!-- LDAP Location -->
<div class="form-group {{ $errors->has('ldap_location') ? 'error' : '' }}">
<div class="col-md-3">
{{ Form::label('ldap_location', trans('admin/settings/general.ldap_location')) }}
</div>
<div class="col-md-9">
{{ Form::text('ldap_location', Request::old('ldap_location', $setting->ldap_location), ['class' => 'form-control','placeholder' => trans('general.example') .'physicaldeliveryofficename', $setting->demoMode]) }}
<p class="help-block">{!! trans('admin/settings/general.ldap_location_help') !!}</p>
{!! $errors->first('ldap_location', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
@if (config('app.lock_passwords')===true)
<p class="text-warning"><i class="fas fa-lock" aria-hidden="true"></i> {{ trans('general.feature_disabled') }}</p>
@endif
</div>
</div>
@if ($setting->ldap_enabled)

<!-- LDAP test -->
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/Users/UpdateUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UpdateUserTest extends TestCase

public function testUsersCanBeActivated()
{
$admin = User::factory()->admin()->create();
$admin = User::factory()->superuser()->create();
$user = User::factory()->create(['activated' => false]);

$this->actingAs($admin)
Expand All @@ -27,7 +27,7 @@ public function testUsersCanBeActivated()

public function testUsersCanBeDeactivated()
{
$admin = User::factory()->admin()->create();
$admin = User::factory()->superuser()->create();
$user = User::factory()->create(['activated' => true]);

$this->actingAs($admin)
Expand All @@ -44,7 +44,7 @@ public function testUsersCanBeDeactivated()

public function testUsersUpdatingThemselvesDoNotDeactivateTheirAccount()
{
$admin = User::factory()->admin()->create(['activated' => true]);
$admin = User::factory()->superuser()->create(['activated' => true]);

$this->actingAs($admin)
->put(route('users.update', $admin), [
Expand Down

0 comments on commit 42f0975

Please sign in to comment.