PHPackages                             horus/sentinel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. horus/sentinel

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

horus/sentinel
==============

Pacote de segurança completo para autenticação, autorização e proteção de aplicações.

v1.5.0(11mo ago)037MITPHPPHP &gt;=8.1

Since Jun 20Pushed 11mo agoCompare

[ Source](https://github.com/rael017/sentinel)[ Packagist](https://packagist.org/packages/horus/sentinel)[ RSS](/packages/horus-sentinel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Horus Sentinel
==============

[](#horus-sentinel)

**Horus Sentinel** é um pacote de segurança completo e desacoplado, desenhado para fornecer funcionalidades robustas de autenticação, autorização e proteção para aplicações PHP modernas.

Ele oferece uma forma elegante de gerir:

- ✅ Autenticação de utilizadores
- ✅ Gestão de sessões seguras com backend em Redis
- ✅ Proteção contra CSRF e XSS
- ✅ Rate Limiting para prevenir ataques de força bruta
- ✅ Geração e validação de URLs assinadas para rotas seguras

---

📦 Instalação
------------

[](#-instalação)

Use o [Composer](https://getcomposer.org):

```
composer require horus/sentinel

⚙️ Guia de Uso
O Sentinel foi desenhado para ser flexível. Ele depende de interfaces, permitindo que você o integre a qualquer framework ou aplicação, fornecendo suas próprias implementações.

1. Implementar as Interfaces
A. UserIdentityInterface
Sua classe de modelo User precisa implementar esta interface:

id;
    }

    public function getPasswordHash(): string {
        return $this->password;
    }

    public function getRoles(): array {
        return [$this->role ?? 'user'];
    }
}
B. UserRepositoryInterface
Você precisa criar um repositório que saiba como buscar os utilizadores na base de dados:

first();
    }
}
C. RateLimiterInterface (Opcional)
Implemente a interface de rate limiting se desejar controlar o número de tentativas de login.

2. Inicializar o Sentinel
No bootstrap da sua aplicação (bootstrap/app.php ou equivalente):

use Horus\Sentinel\Sentinel;
use App\Repositories\UserRepository;
use App\Repositories\RedisRateLimiter;

$appKey = getenv('APP_KEY'); // Chave secreta do seu .env

$sentinel = new Sentinel(
    new UserRepository(),
    new RedisRateLimiter(),
    $appKey
);
Se estiver usando um container de injeção de dependência (DI), registre como singleton:

$container->singleton(Sentinel::class, fn() => $sentinel);
3. Utilização
🔐 Autenticação
php
Copiar
Editar
$email = $_POST['email'];
$password = $_POST['password'];

if ($sentinel->login($email, $password)) {
    header('Location: /dashboard');
    exit;
}
🔒 Proteção de Rotas (Middleware)

class AuthMiddleware {
    public function handle($request, $next) {
        global $sentinel;

        if (!$sentinel->user()) {
            header('Location: /login');
            exit;
        }

        return $next($request);
    }
}
🛡️ CSRF Protection
No formulário:

    csrfInput(); ?>
    Enviar

No controlador:

if (!$sentinel->validateCsrfToken($_POST['_csrf'] ?? null)) {
    // Erro 403
}
🔗 URLs Assinadas
Gerar o link:

$urlSegura = $sentinel->signUrl('http://meusite.com/cancelar-conta', 3600); // válido por 1 hora
Validar na rota:

if (!$sentinel->validateSignedUrl($urlCompleta)) {
    // Erro 401 - link inválido ou expirado
}
✅ Contribuição
Pull Requests são bem-vindos. Para contribuições maiores, abra uma Issue para discutir mudanças antes.

📄 Licença
MIT © 2025 [Seu Nome ou Organização]

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance52

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

6

Last Release

332d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/416004dc76cf6284d5e25d43d64389aaa057237ca10564be65c033e3943f0430?d=identicon)[rael017](/maintainers/rael017)

---

Top Contributors

[![rael017](https://avatars.githubusercontent.com/u/49925622?v=4)](https://github.com/rael017 "rael017 (7 commits)")

---

Tags

phpsecurityauthAuthenticationauthorization

### Embed Badge

![Health badge](/badges/horus-sentinel/health.svg)

```
[![Health](https://phpackages.com/badges/horus-sentinel/health.svg)](https://phpackages.com/packages/horus-sentinel)
```

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M248](/packages/league-oauth2-server)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40820.2M68](/packages/auth0-auth0-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
