Skip to content

Commit

Permalink
bugfix new-mod/new-admin: wrong filter for already existing admins
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-staab committed Oct 10, 2024
1 parent e6c227e commit 555df81
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 3 deletions.
22 changes: 22 additions & 0 deletions app/Console/Commands/NewCommunityCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Console\Commands;

use App\Ldap\Community;
use Illuminate\Console\Command;

class NewCommunityCommand extends Command
{
protected $signature = 'community:new {uid}';

protected $description = 'Command description';

public function handle(): void
{
$community = Community::make([
'ou' => $this->argument('uid')
]);
$community->setDn("ou={$this->argument('uid')}," . Community::rootDn());
$community->generateSkeleton();
}
}
22 changes: 22 additions & 0 deletions app/Console/Commands/NewDomainCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Console\Commands;

use App\Ldap\Domain;
use Illuminate\Console\Command;

class NewDomainCommand extends Command
{
protected $signature = 'community:domain:new {community-uid} {fqdn}';

protected $description = 'Command description';

public function handle(): void
{
$d = Domain::make([
'dc' => $this->argument('fqdn'),
]);
$d->setDn("dc={$this->argument('fqdn')}," . Domain::dnRoot($this->argument('community-uid')));
$d->save();
}
}
4 changes: 3 additions & 1 deletion app/Livewire/Realm/NewAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contrac
$community = Community::findOrFailByUid($this->realm_uid);
$userList = $community->membersGroup()->members()->get();
$admins = $community->adminsGroup()->members()->get();
$adminDns = $admins->modelDns()->toBase();
$selectable_users = $userList->filter(fn ($user) => $adminDns->doesntContain($user->getDn()));

return view('livewire.realm.new-admin', [
'selectable_users' => $userList->except($admins->keys()),
'selectable_users' => $selectable_users,
'community' => $community,
])->title(__('realms.admins_new_title', ['realm' => $this->realm_uid]));
}
Expand Down
6 changes: 4 additions & 2 deletions app/Livewire/Realm/NewModerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contrac
$c = Community::findOrFailByUid($this->realm_uid);
$userList = $c->membersGroup()->members()->get();
$moderators = $c->moderatorsGroup()->members()->get();

// baseCollection does like strings in contains, ldapCollection does not...
$moderatorDns = $moderators->modelDns()->toBase();
$selectable_users = $userList->filter(fn ($user) => $moderatorDns->doesntContain($user->getDn()));
return view('livewire.realm.new-moderator', [
'community' => $c,
'selectable_users' => $userList->except($moderators->keys()),
'selectable_users' => $selectable_users,
]);
}

Expand Down
35 changes: 35 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Installation Guide

## Requirements
* php
* ext-ldap
* ext-pdo
* openldap server (see below)
* mysql
* composer
* npm
* webserver which is .htaccess compatible (apache) -> default laravel stuff

## LDAP-Requirements
* you need the following ./configure flags during compilation, if you compile openldap from scratch you can use the
following compile script for LTS LDAP 2.5.X
* otp, sssvlv and ppolicy are there for future use
* tls, argon2 and dynlist are needed
```bash
#!/bin/bash

set -e #stop on error
set -x #prints commands

cd openldap-2.5.15/

./configure \
--with-tls=yes \
--enable-modules --enable-ppolicy --enable-otp --enable-argon2 --enable-sssvlv --enable-dynlist

make depend
make
make install
```


5 changes: 5 additions & 0 deletions routes/breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
$trail->push(__('New Group'), route('realms.groups.new', $routeParams));
});

Breadcrumbs::for('realms.groups.edit', function (BreadcrumbTrail $trail, array $routeParams) {
$trail->parent('realms.groups', $routeParams);
$trail->push(__('Edit'), route('realms.groups.edit', $routeParams));
});

Breadcrumbs::for('realms.groups.roles', function (BreadcrumbTrail $trail, array $routeParams) {
$trail->parent('realms.groups', $routeParams);
$name = $routeParams['cn'];
Expand Down

0 comments on commit 555df81

Please sign in to comment.