Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 40ba43f

Browse files
committed
LDAP com PHP
0 parents commit 40ba43f

File tree

115 files changed

+53126
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+53126
-0
lines changed

‎README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# LDAP usando PHP
2+
3+
- 1. Faça um sistema que utilize os serviços de autenticação de usuários e grupos através do protocolo LDAP.
4+
- 2. O Sistema deve ter uma área restrita ao grupo do gerentes;
5+
- 3. O Sistema deve ter uma área restrita aos grupos de vendedores e de gerentes;
6+
- 4. O Sistema deve ter uma área pública para qualquer usuário;
7+
- 5. O Sistema deve ter uma tela de login contendo apenas usuário e senha;
8+
- 6. O Sistema deve utilizar os protocolos Active Directory ou LDAP;
9+
- 7. O Sistema deverá ser entregue dentro de um arquivo .zip contendo todos os códigos-fonte, instruções de utilização e também referências sobre códigos-fonte de terceiros;
10+
- 8. O Sistema não poderá ter nenhuma outra base de armazenamento de dados;
11+
- 9. O Sistema não poderá armazenar as senhas em nenhuma hipótese;
12+
- 10. É permitido utilizar qualquer linguagem de programação;
13+
- 11. É permitido utilizar qualquer biblioteca externa, desde que devidamente citada e com licenciamento aberto.
14+
15+
# Passos para execução:
16+
17+
### Configurar variáveis de ambiente ou configure no arquivo `html/configs/config.env`
18+
19+
| **Variável** | **Descrição** | **Obrigatório?** |
20+
| --------------------- | -------------------------------------------- | ------------------ |
21+
| LDAP_HOST | Host LDAP | **✓** |
22+
| LDAP_PORT | Porta LDAP (Padrão: 389) | **✗** |
23+
| LDAP_ADMIN_USER | Usúario administrador LDAP | **✓** |
24+
| LDAP_ADMIN_PASS | Senha administrador LDAP | **✓** |
25+
| LDAP_BASE_DN | DN BASE LDAP | **✓** |
26+
| LDAP_USERS_DN | DN dos Usuários | **✓** |
27+
| LDAP_USERS_DN | DN dos Grupos | **✓** |
28+
| AES_CIPHER | (Padrão: aes-128-ecb)| **✗** |
29+
| AES_KEY | Chave de criptografia | **✓** |
30+
| SESSION_TOKEN | (Padrão: TOKEN) | **✗** |
31+
32+
### Rodar serviço do apache modo de desenvolvimento:
33+
34+
```bash
35+
docker-compose up
36+
```
37+
38+
### Acesse a aplicação em http://localhost:8000
39+
40+
# Referências:
41+
42+
- https://docs.docker.com/compose/
43+
44+
- https://www.php.net/manual/en/book.ldap.php
45+
46+
- https://github.com/anthony-b/simple-php-LDAP-Authentication

‎apache/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:8.1-apache
2+
3+
RUN \
4+
apt-get update && \
5+
apt-get install libldap2-dev -y && \
6+
rm -rf /var/lib/apt/lists/* && \
7+
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
8+
docker-php-ext-install ldap

‎docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3.7'
2+
services:
3+
apache:
4+
build: apache/
5+
container_name: apache
6+
ports:
7+
- '8000:80'
8+
volumes:
9+
- ./html:/var/www/html
10+
environment:
11+
- LDAP_HOST=<LDAP_HOST>
12+
- LDAP_PORT=389
13+
- LDAP_ADMIN_USER=<LDAP_ADMIN_USER>
14+
- LDAP_ADMIN_PASS=<LDAP_ADMIN_PASS>
15+
- "LDAP_BASE_DN=<LDAP_BASE_DN>"
16+
- "LDAP_USERS_DN=<LDAP_USERS_DN>"
17+
- "LDAP_GROUPS_DN=<LDAP_GROUPS_DN>"
18+
- AES_CIPHER=aes-128-ecb
19+
- AES_KEY=<AES_KEY>
20+
- SESSION_TOKEN=TOKEN

‎html/configs/config.env

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
;[LDAP]
2+
;LDAP_HOST = "<LDAP_HOST>";
3+
;LDAP_PORT = 389;
4+
;LDAP_ADMIN_USER = "<LDAP_ADMIN_USER>";
5+
;LDAP_ADMIN_PASS = "LDAP_ADMIN_PASS";
6+
;LDAP_BASE_DN = "<LDAP_BASE_DN>";
7+
;LDAP_USERS_DN = "<LDAP_USERS_DN>";
8+
;LDAP_GROUPS_DN = "<LDAP_GROUPS_DN>";
9+
10+
;[AES]
11+
;AES_CIPHER = "aes-128-ecb";
12+
;AES_KEY = "<AES_KEY>";
13+
14+
;[SESSAO]
15+
;SESSION_TOKEN = "TOKEN";

‎html/configs/config.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
$envs = parse_ini_file("config.env");
3+
/* Configurações do LDAP */
4+
$config['LDAP_HOST'] = isset($_ENV["LDAP_HOST"]) ? $_ENV["LDAP_HOST"] : $envs["LDAP_HOST"];
5+
$config['LDAP_PORT'] = isset($_ENV["LDAP_PORT"]) ? $_ENV["LDAP_PORT"] : (isset($envs["LDAP_PORT"]) ? $envs["LDAP_PORT"] : 389);
6+
$config['LDAP_ADMIN_USER'] = isset($_ENV["LDAP_ADMIN_USER"]) ? $_ENV["LDAP_ADMIN_USER"] : $envs["LDAP_ADMIN_USER"];
7+
$config['LDAP_ADMIN_PASS'] = isset($_ENV["LDAP_ADMIN_PASS"]) ? $_ENV["LDAP_ADMIN_PASS"] : $envs["LDAP_ADMIN_PASS"];
8+
$config['LDAP_BASE_DN'] = isset($_ENV["LDAP_BASE_DN"]) ? $_ENV["LDAP_BASE_DN"] : $envs["LDAP_BASE_DN"];
9+
$config['LDAP_USERS_DN'] = isset($_ENV["LDAP_USERS_DN"]) ? $_ENV["LDAP_USERS_DN"] : $envs["LDAP_USERS_DN"];
10+
$config['LDAP_GROUPS_DN'] = isset($_ENV["LDAP_GROUPS_DN"]) ? $_ENV["LDAP_GROUPS_DN"] : $envs["LDAP_GROUPS_DN"];
11+
12+
/* Configurações de Criptografia */
13+
$config['AES_CIPHER'] = isset($_ENV["AES_CIPHER"]) ? $_ENV["AES_CIPHER"] : (isset($envs["AES_CIPHER"]) ? $envs["AES_CIPHER"] : "aes-128-ecb");
14+
$config['AES_KEY'] = isset($_ENV["AES_KEY"]) ? $_ENV["AES_KEY"] : $envs["AES_KEY"];
15+
16+
/* Configurações Sessão */
17+
$config["SESSION_TOKEN"] = isset($_ENV["SESSION_TOKEN"]) ? $_ENV["SESSION_TOKEN"] : (isset($envs["SESSION_TOKEN"]) ? $envs["SESSION_TOKEN"] : "TOKEN");
18+
19+
return $config;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /