Slim app

parent f1d22bf7
......@@ -77,6 +77,10 @@ if ($bind) {
$attribute = isset($data[$i][$attribute_name]) ? $data[$i][$attribute_name] : null;
if ($attribute === null)
continue;
if (is_string($attribute)) {
echo "{$attribute_name}:{$attribute}", PHP_EOL;
continue;
}
for ($c = 0; $c < $attribute['count']; $c++) {
echo "{$attribute_name}:{$attribute[$c]}", PHP_EOL;
}
......
/vendor/
/logs/*
!/logs/README.md
Διαδικτυακή εφαρμογή SLIM για έλεγχο LDAP χρήστη
================================================
Η εφαρμογή ελέγχει με απλό τρόπο εάν ένα χρήστης υπάρχει στον
κατάλογο και επιστρέφει attributes του χρήστη εφόσον ζητηθούν.
# Οδηγίες
Αντιγράψτε το αρχείο `src\settings.php.dist` σε ένα νέο αρχείο `src\settings.php`
και τροποποιήστε αναλόγως.
```php
return [
'settings' => [
// ...
'ldap' => [
'connectionString' => 'ldap://my.ldap.server',
'domain' => null, // if AD, provide domain name for login
'baseSearchDN' => 'cn=Users,dc=YOURCOMPANY,dc=COM',
]
]
];
```
# Εφαρμογή επίδειξης
Η εφαρμογή έχει αναπτυχθεί με το SLIM framework και παρέχει τις παρακάτω
λειτουργίες. Οι σχετικές path parameters αποδίδονται στις μεθόδους.
Όπου χρησιμοποιούνται επιπλέον παράμετροι, μέσω query string ή post
body, αναφέρονται παρακάτω στις σχετικές παραγράφους περιγραφής των
λειτουργιών.
| HTTP Method | Resource routes | Επιστρεφόμενη τιμή | Μέθοδος που καλείται στο [Gr\Gov\Minedu\Osteam\Slim\App](src/osteam/App.php) |
|-------------+-----------------+--------------------+--------------------------------------------------------------------------------|
| GET | /check/{username}/{password}[/{domain}] | JSON μήνυμα | checkCredentials |
| GET | /get/{username}/{password}[/{domain}]?attributes=[comma separated list of attribute names] | JSON μήνυμα | getInformation |
Η εφαρμογή δημιουργήθηκε με σημείο εκκίνησης το Slim Framework 3 Skeleton Application.
Περισσότερες λεπτομέρειες στη [σελίδα του Slim-Skeleton](https://github.com/slimphp/Slim-Skeleton)
Στο φάκελο [src\osteam](src/osteam) βρίσκεται ο κύριος κώδικας της εφαρμογής και στο
αρχείο [src\routes.php](src/routes.php) καθορίζονται τα σχετικά routes.
**Σημαντικό!** Για να τρέξει η εφαρμογή είναι απαραίτητο μετά τη λήψη της
να εκτελέσετε την εντολή `composer install` μέσα στο ριζικό της φάκελο
(\slim-app).
## Gr\Gov\Minedu\Osteam\Slim\App
Η κλάση [Gr\Gov\Minedu\Osteam\Slim\App](src/osteam/App.php) παρέχει μεθόδους
διευκόλυνσης για τον προγραμματιστή ώστε να μπορεί εύκολα να καταναλώσει
λειτουργίες που αφορούν την πρωτοκόλληση εγγράφων. Οι βασικές λειτουργίες
περιγράφηκαν παραπάνω.
**Τεκμηρίωση παρέχεται εντός του [Gr\Gov\Minedu\Osteam\Slim\App](src/osteam/App.php)**
# Λειτουργίες
> Στα παρακάτω δείγματα κλήσης θεωρείται ότι η εφαρμογή είναι διαθέσιμη στη διεύθυνση: http://generic.local.dev/ldap/
## Επιτυχής έλεγχος στοιχείων
- `http://generic.local.dev/ldap/check/kotsos/kotsos`
Δείγμα απάντησης
```json
{
"result": "true"
}
```
## Ανεπιτυχής έλεγχος στοιχείων
- `http://generic.local.dev/ldap/check/kotsos/lauos/domain`
Δείγμα απάντησης
```json
{
"result": "false"
}
```
## Επιτυχής άντληση στοιχείων
Πρέπει να δοθεί η παράμετρος `attributes` στο query string:
- `attributes` λίστα ονομάτων πεδίων που ζητούνται, χωρισμένη με κόμματα
Παράδειγμα
- `http://generic.local.dev/ldap/get/kotsos/kotsos?attributes=sn,displayname,memberOf`
Δείγμα απάντησης
```json
{
"result": true,
"data": [
{
"sn": [
{
"value": "kotsou"
}
],
"displayname": [
{
"value": "kotsos kotsou"
}
],
"memberof": [
{
"value": "CN=Debugger Users,CN=Users,DC=pdecrete,DC=local"
},
{
"value": "CN=IIS_WPG,CN=Users,DC=pdecrete,DC=local"
}
]
}
]
}```
## Ανεπιτυχής άντληση στοιχείων
- `http://generic.local.dev/ldap/get/kotsos/denyparhei?attributes=sn,displayname,memberOf`
```json
{
"result": false,
"reason": "Λανθασμένα στοιχεία πρόσβασης ή λάθος κατά τη σύνδεση"
}
```
- `http://generic.local.dev/ldap/get/kotsos/kotsos`
```json
{
"result": false,
"reason": "Δεν έχετε καθορίσει λίστα ονομάτων πεδίων"
}
```
## Άλλες πιθανές απαντήσεις της εφαρμογής
Σε περίπτωση λάθους κατά την αναζήτηση θα επιστραφεί μήνυμα αντίστοιχο με το παρακάτω.
```json
{
"result": false,
"reason": "ΕΠΕΞΗΓΗΜΑΤΙΚΟ ΚΕΙΜΕΝΟ"
}
```
Δείγμα απάντησης στο `http://generic.local.dev/ldap/%CE%B1%CF%85%CF%84%CF%8C%20%CE%B4%CE%B5%CE%BD%20%CF%85%CF%80%CE%AC%CF%81%CF%87%CE%B5%CE%B9`
```json
{
"message": "Δεν αναγνωρίστηκε το αίτημα σας",
"in": "array (\n 'anythingelse' => 'αυτό δεν υπάρχει',\n)"
}
```
{
"name": "minedu-osteam/ldap-test-slim-app",
"description": "A Slim Framework application for testing ldap",
"keywords": ["rest", "minedu"],
"homepage": "https://git.minedu.gov.gr/spapad/samples",
"license": "EUPL",
"authors": [
{
"name": "MINEDU OPEN SOURCE TEAM",
"email": "osteam@minedu.gov.gr",
"homepage": "http://ostmgmt.minedu.gov.gr/"
},
{
"name": "Stavros Papadakis",
"email": "spapad@gmail.com"
}
],
"require": {
"php": ">=5.5.0",
"slim/slim": "^3.1",
"slim/php-view": "^2.0",
"monolog/monolog": "^1.17"
},
"require-dev": {
"phpunit/phpunit": ">=4.8 < 6.0"
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"start": "php -S 0.0.0.0:8080 -t public public/index.php",
"test": "phpunit"
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "879428115fc13a8594452b5562652f72",
"content-hash": "5f27dd39567b5d1d746fb58863702d06",
"packages": [
{
"name": "container-interop/container-interop",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/container-interop/container-interop.git",
"reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e",
"reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-4": {
"Interop\\Container\\": "src/Interop/Container/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
"time": "2014-12-30 15:22:37"
},
{
"name": "monolog/monolog",
"version": "1.22.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "bad29cb8d18ab0315e6c477751418a82c850d558"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bad29cb8d18ab0315e6c477751418a82c850d558",
"reference": "bad29cb8d18ab0315e6c477751418a82c850d558",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "~5.3"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"time": "2016-11-26 00:15:39"
},
{
"name": "nikic/fast-route",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/FastRoute.git",
"reference": "f3dcf5130e634b6123d40727d612ec6aa4f61fb3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/f3dcf5130e634b6123d40727d612ec6aa4f61fb3",
"reference": "f3dcf5130e634b6123d40727d612ec6aa4f61fb3",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"FastRoute\\": "src/"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Nikita Popov",
"email": "nikic@php.net"
}
],
"description": "Fast request router for PHP",
"keywords": [
"router",
"routing"
],
"time": "2016-10-20 17:36:47"
},
{
"name": "pimple/pimple",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/silexphp/Pimple.git",
"reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/silexphp/Pimple/zipball/a30f7d6e57565a2e1a316e1baf2a483f788b258a",
"reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-0": {
"Pimple": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Pimple, a simple Dependency Injection Container",
"homepage": "http://pimple.sensiolabs.org",
"keywords": [
"container",
"dependency injection"
],
"time": "2015-09-11 15:10:35"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06 14:39:51"
},
{
"name": "psr/log",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2016-10-10 12:19:37"
},
{
"name": "slim/php-view",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/slimphp/PHP-View.git",
"reference": "122ed121a8d9cf91a94020814d2a3ee6c836754f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slimphp/PHP-View/zipball/122ed121a8d9cf91a94020814d2a3ee6c836754f",
"reference": "122ed121a8d9cf91a94020814d2a3ee6c836754f",
"shasum": ""
},
"require": {
"psr/http-message": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"slim/slim": "^3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Slim\\Views\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Glenn Eggleton",
"email": "geggleto@gmail.com"
}
],
"description": "Render PHP view scripts into a PSR-7 Response object.",
"keywords": [
"framework",
"php",
"phtml",
"renderer",
"slim",
"template",
"view"
],
"time": "2016-10-11 07:43:08"
},
{
"name": "slim/slim",
"version": "3.7.0",
"source": {
"type": "git",
"url": "https://github.com/slimphp/Slim.git",
"reference": "4254e40d81559e35cdf856bcbaca5f3af468b7ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/4254e40d81559e35cdf856bcbaca5f3af468b7ef",
"reference": "4254e40d81559e35cdf856bcbaca5f3af468b7ef",
"shasum": ""
},
"require": {
"container-interop/container-interop": "^1.1",
"nikic/fast-route": "^1.0",
"php": ">=5.5.0",
"pimple/pimple": "^3.0",
"psr/http-message": "^1.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0",
"squizlabs/php_codesniffer": "^2.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Slim\\": "Slim"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Rob Allen",
"email": "rob@akrabat.com",
"homepage": "http://akrabat.com"
},
{
"name": "Josh Lockhart",
"email": "hello@joshlockhart.com",
"homepage": "https://joshlockhart.com"
},
{
"name": "Gabriel Manricks",
"email": "gmanricks@me.com",
"homepage": "http://gabrielmanricks.com"
},
{
"name": "Andrew Smith",
"email": "a.smith@silentworks.co.uk",
"homepage": "http://silentworks.co.uk"
}
],
"description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs",
"homepage": "https://slimframework.com",
"keywords": [
"api",
"framework",
"micro",
"router"
],
"time": "2016-12-20 20:30:47"
}
],
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
"shasum": ""
},
"require": {
"php": ">=5.3,<8.0-DEV"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "http://ocramius.github.com/"
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator",
"keywords": [
"constructor",
"instantiate"
],
"time": "2015-06-14 21:17:01"
},
{
"name": "myclabs/deep-copy",
"version": "1.5.5",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/399c1f9781e222f6eb6cc238796f5200d1b7f108",
"reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"doctrine/collections": "1.*",
"phpunit/phpunit": "~4.1"
},
"type": "library",
"autoload": {
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Create deep copies (clones) of your objects",
"homepage": "https://github.com/myclabs/DeepCopy",
"keywords": [
"clone",
"copy",
"duplicate",
"object",
"object graph"
],
"time": "2016-10-31 17:19:45"
},
{
"name": "phpdocumentor/reflection-common",
"version": "1.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
"shasum": ""
},
"require": {
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "^4.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jaap van Otterdijk",