Convert Figma logo to code with AI

cartalyst logosentinel

A framework agnostic authentication & authorization system.

1,511
238
1,511
40

Top Related Projects

2,730

Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.

11,274

🔐 JSON Web Token Authentication for Laravel & Lumen

Associate users with roles and permissions

Laravel Passport provides OAuth2 server support to Laravel.

9,325

A RESTful API package for the Laravel and Lumen frameworks.

A spec compliant, secure by default PHP OAuth 2.0 Server

Quick Overview

Cartalyst Sentinel is a PHP authentication and authorization package designed for Laravel applications. It provides a robust set of tools for user management, including registration, authentication, authorization, and password reset functionality.

Pros

  • Comprehensive user management system with advanced features like throttling and activation
  • Flexible and customizable, allowing for easy integration with existing projects
  • Well-documented with clear examples and API references
  • Supports multiple user models and roles/permissions system

Cons

  • Steeper learning curve compared to Laravel's built-in authentication system
  • May be overkill for simple projects that don't require advanced user management features
  • Requires additional setup and configuration compared to using Laravel's default auth
  • Less frequent updates and maintenance compared to some other popular auth packages

Code Examples

  1. User registration:
$credentials = [
    'email'    => 'john.doe@example.com',
    'password' => 'password',
    'first_name' => 'John',
    'last_name' => 'Doe',
];

Sentinel::register($credentials);
  1. User authentication:
$credentials = [
    'email'    => 'john.doe@example.com',
    'password' => 'password',
];

if (Sentinel::authenticate($credentials)) {
    // User is logged in
}
  1. Checking user permissions:
$user = Sentinel::getUser();

if ($user->hasAccess('posts.create')) {
    // User has permission to create posts
}
  1. Creating and assigning roles:
$role = Sentinel::getRoleRepository()->createModel()->create([
    'name' => 'Admin',
    'slug' => 'admin',
    'permissions' => [
        'users.create' => true,
        'users.update' => true,
        'users.delete' => true,
    ],
]);

$user = Sentinel::findById(1);
$role->users()->attach($user);

Getting Started

  1. Install Sentinel via Composer:
composer require cartalyst/sentinel
  1. Add the service provider to your config/app.php:
'providers' => [
    // ...
    Cartalyst\Sentinel\Laravel\SentinelServiceProvider::class,
],
  1. Add the Sentinel facade to your config/app.php:
'aliases' => [
    // ...
    'Sentinel' => Cartalyst\Sentinel\Laravel\Facades\Sentinel::class,
],
  1. Publish the configuration and migration files:
php artisan vendor:publish --provider="Cartalyst\Sentinel\Laravel\SentinelServiceProvider"
  1. Run the migrations:
php artisan migrate

Now you can start using Sentinel in your Laravel application.

Competitor Comparisons

2,730

Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.

Pros of Sanctum

  • Lightweight and easy to integrate, especially for API authentication
  • Built-in support for SPA authentication and mobile app tokens
  • Seamless integration with Laravel ecosystem

Cons of Sanctum

  • Limited features compared to more comprehensive packages
  • Lacks advanced user management and role-based access control out of the box

Code Comparison

Sanctum (API token creation):

$token = $user->createToken('token-name');

Sentinel (User authentication):

$credentials = [
    'email'    => 'john.doe@example.com',
    'password' => 'password',
];
$user = Sentinel::authenticate($credentials);

Sanctum focuses on simplicity and API authentication, while Sentinel offers a more comprehensive user management system. Sanctum is ideal for projects requiring straightforward API authentication, whereas Sentinel is better suited for applications needing advanced user roles and permissions.

Sanctum's integration with Laravel makes it a natural choice for Laravel developers, but it may require additional packages or custom development for more complex authentication scenarios. Sentinel, on the other hand, provides a robust set of features out of the box but may have a steeper learning curve and require more setup time.

11,274

🔐 JSON Web Token Authentication for Laravel & Lumen

Pros of jwt-auth

  • Lightweight and focused specifically on JWT authentication
  • Easy integration with Laravel and other PHP frameworks
  • Active development and community support

Cons of jwt-auth

  • Limited to JWT authentication, lacking broader user management features
  • Requires additional setup for advanced authentication scenarios
  • Less comprehensive documentation compared to Sentinel

Code Comparison

jwt-auth:

$token = JWTAuth::attempt($credentials);
$user = JWTAuth::toUser($token);

Sentinel:

$user = Sentinel::authenticate($credentials);
$activation = Activation::create($user);
Activation::complete($user, $activation->code);

Key Differences

  • jwt-auth focuses solely on JWT authentication, while Sentinel offers a more comprehensive user management solution
  • Sentinel provides built-in features like user activation and role management, which are not included in jwt-auth
  • jwt-auth is more suitable for API-centric applications, while Sentinel caters to a broader range of authentication needs

Use Cases

  • Choose jwt-auth for lightweight JWT authentication in API-driven applications
  • Opt for Sentinel when you need a full-featured user management system with roles, permissions, and activation features

Community and Support

  • jwt-auth has a larger GitHub community with more stars and contributors
  • Sentinel, being a paid product, offers professional support and documentation

Both libraries have their strengths, and the choice depends on the specific requirements of your project and the level of authentication complexity you need.

Associate users with roles and permissions

Pros of Laravel Permission

  • Lightweight and focused solely on roles and permissions
  • Seamless integration with Laravel's built-in authorization features
  • Active development and community support

Cons of Laravel Permission

  • Lacks built-in user authentication and management features
  • May require additional packages for complete user management solution

Code Comparison

Laravel Permission:

$user->givePermissionTo('edit articles');
$user->assignRole('writer');
$user->hasPermissionTo('edit articles');

Sentinel:

$user = Sentinel::registerAndActivate($credentials);
$role = Sentinel::getRoleRepository()->createModel()->create($attributes);
$user->addRole($role);

Key Differences

  • Laravel Permission focuses on role-based access control, while Sentinel provides a complete user management solution.
  • Sentinel offers more extensive features like user registration, activation, and session management.
  • Laravel Permission integrates directly with Laravel's authorization system, whereas Sentinel has its own implementation.

Use Cases

  • Choose Laravel Permission for projects that need flexible role and permission management within an existing Laravel application.
  • Opt for Sentinel when building applications requiring comprehensive user management, including authentication and authorization.

Laravel Passport provides OAuth2 server support to Laravel.

Pros of Passport

  • Built-in OAuth2 server implementation
  • Seamless integration with Laravel's authentication system
  • Active development and maintenance by the Laravel team

Cons of Passport

  • Heavier and more complex for simple authentication needs
  • Requires more setup and configuration compared to Sentinel

Code Comparison

Passport (API token generation):

$user = User::find(1);
$token = $user->createToken('Token Name')->accessToken;

Sentinel (User authentication):

$credentials = [
    'email'    => 'john.doe@example.com',
    'password' => 'password',
];
Sentinel::authenticate($credentials);

Key Differences

  • Passport focuses on API authentication and OAuth2, while Sentinel provides a more general-purpose authentication solution
  • Sentinel offers role-based permissions out of the box, whereas Passport requires additional setup for advanced authorization
  • Passport is tightly integrated with Laravel, while Sentinel can be used in other PHP frameworks

Use Cases

  • Choose Passport for API-centric applications or when OAuth2 is required
  • Opt for Sentinel for simpler authentication needs or when working across different PHP frameworks

Both packages offer robust security features and are well-maintained, so the choice largely depends on specific project requirements and the desired level of integration with Laravel.

9,325

A RESTful API package for the Laravel and Lumen frameworks.

Pros of Dingo API

  • Provides a comprehensive API development toolkit for Laravel
  • Offers built-in versioning and rate limiting features
  • Includes powerful response transformers for data formatting

Cons of Dingo API

  • Steeper learning curve due to its extensive feature set
  • Less focus on authentication and user management
  • May be overkill for simple API projects

Code Comparison

Dingo API route definition:

$api = app('Dingo\Api\Routing\Router');

$api->version('v1', function ($api) {
    $api->get('users', 'App\Http\Controllers\UserController@index');
});

Sentinel authentication:

$credentials = [
    'email'    => 'john.doe@example.com',
    'password' => 'password',
];

Sentinel::authenticate($credentials);

Summary

Dingo API is a powerful toolkit for building APIs in Laravel, offering features like versioning and rate limiting. It excels in API-specific functionality but has a steeper learning curve. Sentinel, on the other hand, focuses on authentication and user management, making it more suitable for projects that prioritize these aspects. The choice between the two depends on the specific needs of your project, with Dingo API being better for complex API development and Sentinel for robust user authentication systems.

A spec compliant, secure by default PHP OAuth 2.0 Server

Pros of oauth2-server

  • Focused specifically on OAuth 2.0 implementation, providing a more comprehensive OAuth solution
  • More active development and community support
  • Follows PSR standards for better interoperability

Cons of oauth2-server

  • Limited to OAuth 2.0 functionality, lacking broader authentication features
  • Steeper learning curve for developers new to OAuth concepts
  • Requires additional components for complete user management

Code Comparison

Sentinel (User Authentication):

$credentials = [
    'email'    => 'john.doe@example.com',
    'password' => 'password',
];

Sentinel::authenticate($credentials);

oauth2-server (Token Generation):

$server = new \League\OAuth2\Server\AuthorizationServer();
$response = $server->respondToAccessTokenRequest($request, $response);

Sentinel focuses on user authentication and management, while oauth2-server specializes in OAuth 2.0 token handling and authorization. Sentinel provides a more straightforward API for common authentication tasks, whereas oauth2-server offers a robust implementation of the OAuth 2.0 specification.

Choose Sentinel for general authentication needs and user management. Opt for oauth2-server when implementing a full OAuth 2.0 server or when working with third-party OAuth integrations.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Sentinel

Build Status Software License Latest Version on Packagist Total Downloads

Sentinel is a PHP 8.2+ framework agnostic fully-featured authentication & authorization system. It also provides additional features such as user roles and additional security features.

An open source package by Cartalyst, code well, rock on!

Version Matrix

VersionLaravelPHP Version
8.x11.0>= 8.2
7.x10.0>= 8.1
6.x9.0>= 8.0
5.x8.0>= 7.3
4.x7.0>= 7.2.5
3.x6.0>= 7.2
2.x5.0>= 5.4.0
1.x4.1 - 5.0>= 5.4.0

Documentation

Reader-friendly documentation can be found here.

Using the package, but you're stuck? Found a bug? Have a question or suggestion for improving this package? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

Contributing

Thank you for your interest, here are some of the many ways to contribute.

Security

If you discover any security related issues, please email help@cartalyst.com instead of using the issue tracker.

License

This software is released under the BSD 3-Clause License.