API query and CI to build the docker demo image
Remove unused CI, removed some debugging for the demo
This commit is contained in:
parent
de4fa04d3b
commit
6620b9147e
@ -18,6 +18,10 @@ variables:
|
|||||||
LDAP_ADMIN_PASSWORD: test
|
LDAP_ADMIN_PASSWORD: test
|
||||||
# LDAP_SEED_INTERNAL_SCHEMA_PATH: "${CI_PROJECT_DIR}/tests/server/openldap/schema"
|
# LDAP_SEED_INTERNAL_SCHEMA_PATH: "${CI_PROJECT_DIR}/tests/server/openldap/schema"
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- deploy
|
||||||
|
|
||||||
# This folder is cached between builds
|
# This folder is cached between builds
|
||||||
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
|
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
|
||||||
cache:
|
cache:
|
||||||
@ -55,10 +59,42 @@ test:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
# run laravel tests
|
# run laravel tests
|
||||||
- php vendor/bin/phpunit --coverage-text --colors=never
|
- php vendor/bin/phpunit --coverage-text --colors=never
|
||||||
|
|
||||||
# run frontend tests
|
# run frontend tests
|
||||||
# if you have any task for testing frontend
|
# if you have any task for testing frontend
|
||||||
# set it in your package.json script
|
# set it in your package.json script
|
||||||
# comment this out if you don't have a frontend test
|
# comment this out if you don't have a frontend test
|
||||||
# npm test
|
# npm test
|
||||||
|
|
||||||
|
docker:
|
||||||
|
before_script:
|
||||||
|
- docker info
|
||||||
|
- docker version
|
||||||
|
- echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
|
||||||
|
- if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > auth.json; fi
|
||||||
|
|
||||||
|
variables:
|
||||||
|
VERSION: latest
|
||||||
|
CACHETAG: build-${VERSION}
|
||||||
|
DOCKER_HOST: tcp://docker:2375
|
||||||
|
|
||||||
|
stage: deploy
|
||||||
|
image: docker:latest
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
|
||||||
|
script:
|
||||||
|
- if [ -f init ]; then chmod 500 init; fi
|
||||||
|
- ([ -z "$REFRESH" ] && docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG}) || echo "true"
|
||||||
|
- echo -n ${CI_COMMIT_SHORT_SHA} > VERSION
|
||||||
|
- docker build --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} .
|
||||||
|
- docker push ${CI_REGISTRY_IMAGE}:${VERSION}
|
||||||
|
- docker push ${CI_REGISTRY_IMAGE}:${CACHETAG}
|
||||||
|
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- x86_64
|
||||||
|
|
||||||
|
only:
|
||||||
|
- BRANCH-2.0
|
||||||
|
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM registry.leenooks.net/leenooks/php:7.4-fpm-mp
|
||||||
|
|
||||||
|
COPY . /var/www/html/
|
||||||
|
|
||||||
|
RUN mkdir /var/www/.composer \
|
||||||
|
&& ([ -r auth.json ] && mv auth.json /var/www/.composer/) || true \
|
||||||
|
&& touch .composer.refresh \
|
||||||
|
&& mv .env.example .env \
|
||||||
|
&& FORCE_PERMS=1 /sbin/init \
|
||||||
|
&& rm -rf /var/www/.composer/*
|
84
README.md
84
README.md
@ -1,13 +1,87 @@
|
|||||||
phpLDAPadmin
|
# phpLDAPadmin
|
||||||
============
|
phpLDAPadmin is a web based LDAP data management tool for system administrators. It is commonly known and referred by many as PLA.
|
||||||
|
|
||||||
phpLDAPadmin - Web based LDAP administration tool
|
A primary goal of PLA is to be as intuitive as possible - so it is certainly possible for end users to use it as well, for example, to manage their data in an LDAP server.
|
||||||
|
|
||||||
|
PLA is designed to be compliant with LDAP RFCs, enabling it to be used with any LDAP server.
|
||||||
|
If you come across an LDAP server, where PLA exhibits problems, please open an issue with full details of the problem so that we can have it fixed.
|
||||||
|
|
||||||
|
## History
|
||||||
|
Initially created in 2002 by David Smith, it was taken over by Deon George (aka leenooks) in 2005.
|
||||||
|
|
||||||
|
Since 2003 many things have changed - initial development was done in CVS and the project was hosted on Sourceforge.
|
||||||
|
In 2009, CVS was swapped out for GIT, and in around 2011 the project was moved to Github.
|
||||||
|
|
||||||
|
The PLA v1.2.x stream was created in July 2009.
|
||||||
|
|
||||||
|
## THANK YOU
|
||||||
|
Over the years, many, many, many people have supported PLA with either their time, their coding or with financial donations.
|
||||||
|
I have tried to send an email to acknowledge each contribution, and if you havent seen anything personally from me, I am sorry, but please know that I do appreciate all the help I get, in whatever form it is provided.
|
||||||
|
|
||||||
|
Again, Thank You.
|
||||||
|
|
||||||
|
## Future
|
||||||
|
Web development, tools, approaches and technology has come along way since 2009 and some talented folks have created some fantastic tools.
|
||||||
|
With that PLA is going under a major revamp in preparation for v2 and will aim to use those existing creations to help speed up the revamp effort.
|
||||||
|
|
||||||
|
Some of the creations planned to be used in v2 include:
|
||||||
|
* Laravel (https://laravel.com)
|
||||||
|
* adldap2/adldap2 (https://github.com/Adldap2/Adldap2)
|
||||||
|
* JQuery (https://jquery.com)
|
||||||
|
* FancyTree (https://github.com/mar10/fancytree)
|
||||||
|
* ArchitectUI (https://architectui.com)
|
||||||
|
|
||||||
|
PLA v1.2.x will be archived into [BRANCH-1.2](https://github.com/leenooks/phpLDAPadmin/tree/BRANCH-1.2), and `master` will be changed to reflect the new v2 work and effort.
|
||||||
|
|
||||||
|
If you plan to use PLA, and cannot use an installation from your OS package, please use [BRANCH-1.2](https://github.com/leenooks/phpLDAPadmin/tree/BRANCH-1.2) while progress is made in master for v2.
|
||||||
|
|
||||||
|
If you like the cutting edge, feel free to try out `master`, but expect problems, bugs and missing functionality.
|
||||||
|
If you have extended v2 and would like to contribute your extension, or if you find a way to fix something that is broken or missing please submit a pull request.
|
||||||
|
|
||||||
|
Alternatively, you can get take a peek at the work so far by using our docker container, which is built automatically after testing passes.
|
||||||
|
The [demo](http://demo.phpldapadmin.org) site, will also be running the same docker container. (See below for details.)
|
||||||
|
|
||||||
|
In summary, for the time being, expect `master` to be buggy and broken, and I'll update this readme as enhancements progress.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
[INSTALL](INSTALL.md)
|
### Installation on your server
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
* A HTTP server (eg: Apache, Nginx)
|
||||||
|
* PHP (minimum version 7.2) https://www.php.net
|
||||||
|
* Composer https://getcomposer.org
|
||||||
|
* GIT
|
||||||
|
|
||||||
|
#### Installation
|
||||||
|
1. Checkout the code from github
|
||||||
|
```bash
|
||||||
|
git checkout https://github.com/leenooks/phpLDAPadmin.git
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Install composer dependencies.
|
||||||
|
```bash
|
||||||
|
composer install
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Edit your `.env` file as appropriate
|
||||||
|
|
||||||
|
copy `.env.example` to `.env` as a start.
|
||||||
|
|
||||||
|
1. Configure your webserver to have PLA's root in the `public` directory
|
||||||
|
|
||||||
|
### Using Docker
|
||||||
|
Instructions to come.
|
||||||
|
|
||||||
|
## Getting Help
|
||||||
|
The best place to get help with PLA (new and old) is on Stack Overflow (https://stackoverflow.com/tags/phpldapadmin/info)
|
||||||
|
|
||||||
|
## Found a bug?
|
||||||
|
If you have found a bug, and can provide detailed instructions so that it can be reproduced, please open an [issue](https://github.com/leenooks/phpLDAPadmin/issues) and provide those details.
|
||||||
|
|
||||||
|
Before opening a ticket, please check to see if it hasnt already been reported, and if it has, please provide any additional information that will help it be fixed.
|
||||||
|
|
||||||
|
*TIP*: Issues opened with reproducible details accompanied with a patch (or a pull request) to fix the problem will be looked at first.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[LICENSE](LICENSE)
|
[LICENSE](LICENSE)
|
||||||
|
@ -18,6 +18,7 @@ class Server
|
|||||||
*/
|
*/
|
||||||
public function getBaseDN(): ?Collection
|
public function getBaseDN(): ?Collection
|
||||||
{
|
{
|
||||||
|
//findBaseDn()?
|
||||||
// If the base is set in the configuration file, then just return that after validating it exists.
|
// If the base is set in the configuration file, then just return that after validating it exists.
|
||||||
// @todo
|
// @todo
|
||||||
if (false) {
|
if (false) {
|
||||||
@ -41,8 +42,6 @@ class Server
|
|||||||
protected function getDNAttrValues(string $dn,array $attrs=['*','+'],int $deref=LDAP_DEREF_NEVER): ?Entry
|
protected function getDNAttrValues(string $dn,array $attrs=['*','+'],int $deref=LDAP_DEREF_NEVER): ?Entry
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
dump(config('ldap.connections.default.settings'));
|
|
||||||
|
|
||||||
return ($x=(new Adldap)
|
return ($x=(new Adldap)
|
||||||
->addProvider(config('ldap.connections.default.settings'))
|
->addProvider(config('ldap.connections.default.settings'))
|
||||||
->search()
|
->search()
|
||||||
@ -54,4 +53,27 @@ class Server
|
|||||||
dd(['e'=>$e]);
|
dd(['e'=>$e]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the server for a DN
|
||||||
|
*
|
||||||
|
* @param string $dn
|
||||||
|
* @return |null
|
||||||
|
*/
|
||||||
|
public function query(string $dn)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return ($x=(new Adldap)
|
||||||
|
->addProvider(config('ldap.connections.default.settings'))
|
||||||
|
->search()
|
||||||
|
->setBaseDn($dn)
|
||||||
|
//->select($attrs)
|
||||||
|
->listing()
|
||||||
|
->get()) ? $x : NULL;
|
||||||
|
|
||||||
|
// @todo Tidy up this exception
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
dd(['e'=>$e]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
use App\Classes\LDAP\Server;
|
use App\Classes\LDAP\Server;
|
||||||
|
|
||||||
@ -14,17 +16,42 @@ class APIController extends Controller
|
|||||||
*
|
*
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public function bases()
|
public function bases(): Collection
|
||||||
{
|
{
|
||||||
return (new Server())->getBaseDN()->transform(function($item) {
|
return (new Server())
|
||||||
return [
|
->getBaseDN()
|
||||||
'title'=>$item,
|
->transform(function($item) {
|
||||||
'item'=>base64_encode(Crypt::encryptString($item)),
|
return [
|
||||||
//'folder'=>TRUE,
|
'title'=>$item,
|
||||||
'lazy'=>TRUE,
|
'item'=>Crypt::encryptString($item),
|
||||||
//'key'=>0,
|
//'folder'=>TRUE,
|
||||||
//'autoexpand'=>TRUE,
|
'lazy'=>TRUE,
|
||||||
];
|
//'key'=>0,
|
||||||
});
|
//'autoexpand'=>TRUE,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function query(Request $request): Collection
|
||||||
|
{
|
||||||
|
$levels = $request->query('depth',1);
|
||||||
|
$dn = Crypt::decryptString($request->query('key'));
|
||||||
|
Log::debug(sprintf('%s: Query [%s] - Levels [%d]',__METHOD__,$dn,$levels));
|
||||||
|
|
||||||
|
return (new Server())
|
||||||
|
->query($dn)
|
||||||
|
->transform(function($item) {
|
||||||
|
//dd($item->getDistinguishedName(),$item);
|
||||||
|
return [
|
||||||
|
'title'=>$item->getDistinguishedName(),
|
||||||
|
'item'=>Crypt::encryptString($item->getDistinguishedName()),
|
||||||
|
//'folder'=>TRUE,
|
||||||
|
'lazy'=>TRUE,
|
||||||
|
//'key'=>0,
|
||||||
|
//'autoexpand'=>TRUE,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
Log::debug(sprintf('%s: Query [%s] - Levels [%d]: %s',__METHOD__,$dn,$levels,serialize($x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
public/css/architect.min.css
vendored
Normal file
30
public/css/architect.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
public/img/logo-h.png
Normal file
BIN
public/img/logo-h.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
89
public/js/architect.min.js
vendored
Normal file
89
public/js/architect.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -16,9 +16,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-sm-4">
|
<div class="col-12 col-sm-4">
|
||||||
<h3 class="d-inline-block d-sm-none">phpLDAPadmin</h3>
|
<h3 class="d-inline-block d-sm-none">phpLDAPadmin</h3>
|
||||||
<div class="col-12">
|
<img src="img/logo.png" class="logo-image col-12" alt="PLA Logo">
|
||||||
<img src="img/logo.png" class="product-image" alt="PLA Logo">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-sm-8">
|
<div class="col-12 col-sm-8">
|
||||||
@ -64,12 +62,9 @@
|
|||||||
$('#tree').fancytree({
|
$('#tree').fancytree({
|
||||||
clickFolderMode: 3,
|
clickFolderMode: 3,
|
||||||
extensions: ['glyph'],
|
extensions: ['glyph'],
|
||||||
aria: true, // Enable WAI-ARIA support.
|
|
||||||
autoActivate: false, // Automatically activate a node when it is focused (using keys).
|
|
||||||
autoCollapse: true, // Automatically collapse all siblings, when a node is expanded.
|
autoCollapse: true, // Automatically collapse all siblings, when a node is expanded.
|
||||||
autoScroll: false, // Automatically scroll nodes into visible area.
|
autoScroll: true, // Automatically scroll nodes into visible area.
|
||||||
focusOnSelect: true, // Set focus when node is checked by a mouse click
|
focusOnSelect: true, // Set focus when node is checked by a mouse click
|
||||||
keyboard: true, // Support keyboard navigation.
|
|
||||||
glyph: {
|
glyph: {
|
||||||
preset: 'awesome5',
|
preset: 'awesome5',
|
||||||
map: {
|
map: {
|
||||||
@ -100,8 +95,8 @@
|
|||||||
},
|
},
|
||||||
lazyLoad: function(event,data) {
|
lazyLoad: function(event,data) {
|
||||||
data.result = {
|
data.result = {
|
||||||
url: "{{ url('api/branch') }}",
|
url: "{{ url('api/query') }}",
|
||||||
data: {key: data.node.data.item}
|
data: {key: data.node.data.item,depth: 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
expandChildren(data.tree.rootNode);
|
expandChildren(data.tree.rootNode);
|
||||||
@ -126,6 +121,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
{{--
|
||||||
<style>
|
<style>
|
||||||
.fancytree-node {
|
.fancytree-node {
|
||||||
display: flex !important;
|
display: flex !important;
|
||||||
@ -169,4 +165,5 @@
|
|||||||
padding: 2px 0;
|
padding: 2px 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
--}}
|
||||||
@append
|
@append
|
||||||
|
@ -19,6 +19,7 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
|
|||||||
return $request->user();
|
return $request->user();
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
Route::group(['middleware'=>'auth:api'], function() {
|
Route::group([],function() {
|
||||||
Route::get('/bases', 'APIController@bases');
|
Route::get('/bases', 'APIController@bases');
|
||||||
|
Route::get('/query', 'APIController@query');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user