A framework agnostic authentication & authorization system.

Overview

Sentinel

Build Status Software License Latest Version on Packagist Total Downloads

Sentinel is a PHP 7.3+ 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

Version Laravel PHP Version
5.x 8.0 >= 7.3
4.x 7.0 >= 7.2.5
3.x 6.0 >= 7.2
2.x 5.0 >= 5.4.0
1.x 4.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 [email protected] instead of using the issue tracker.

License

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

Comments
  • Sentry findUserByActivationCode is missing in Sentinel

    Sentry findUserByActivationCode is missing in Sentinel

    Migrating to Sentinel I am stuck in the activation process. The findUserByActivationCode method is missing in Sentinel. You can only activate an account by passing a User object. But people are not logged in when not activated.

    What's the correct workflow to activate without logging in? Or should I create a Pull Request with the method ;-)

    opened by webpatser 19
  • array_key_exists() expects parameter 2 to be array, null given

    array_key_exists() expects parameter 2 to be array, null given

    Your Environment

    • OS and Version: Ubuntu 18
    • PHP Version: 7.2.19
    • Sentinel Version: 3.0.1

    Expected behaviour

    Please describe what you are expecting to see happening.

    Add permissions to roles with the addPermission Method

    Actual behaviour

    Please describe what is actually happening.

    It throws an error:

    array_key_exists() expects parameter 2 to be array, null given.
    
    In my table I have the role root with null permissions.
    
    //This is the code that its not working:
     In EloquentRole.class. This method is failling.
    
     public function addPermission(string $permission, bool $value = true): PermissibleInterface
        {
            if (! array_key_exists($permission, $this->permissions)) {
                $this->permissions = array_merge($this->permissions, [$permission => $value]);
            }
    
            return $this;
        }
    
    This only happens when roles.permissions = null. But if you update the field to '[]' instead of null it works.
    

    Steps to reproduce

    If your issue requires any specific steps to reproduce, please outline them here.

    1. Create a role with no permissions, permissions = null. $role = new Role();
    2. Add permissions to the role. $role->addPermission('update_sales');
    opened by juanpscotto 18
  • Laravel Passport support

    Laravel Passport support

    It is possible to make it works for laravel passport, I used the sentinel user and extended using the Authenticatable class.

    But when I do $request->user() is null

    Question 
    opened by german-bortoli 18
  • [Feature Request] Integrate into Laravel's Auth system to allow ACL features

    [Feature Request] Integrate into Laravel's Auth system to allow ACL features

    With the addition of Laravel's Authorization features, it would be nice to leverage Policies to have finer control of permissions.

    The only way I have been able to get Policies and Sentinel to work together is by manually authenticating with Laravel's Auth along side Sentinel. Policies want to resolve the authenticated user via Auth before it continues to check the policy. That is where an integration point would be beneficial; having the authenticated user be resolved via Sentinel rather than Auth.

    Proposal Rejected 
    opened by james-daddies 16
  • Where do I add the checkpoint code?

    Where do I add the checkpoint code?

    ref: https://cartalyst.com/manual/sentinel/2.0#functions

    $checkpoint = new Your\Custom\Checkpoint;
    Sentinel::addCheckpoint('your_checkpoint', $checkpoint);
    

    I'm on laravel 5.1, where in my code should this be put? I've tried adding it in boot() and register() in AppServiceProvider.php but It gives me an error.

    Question 
    opened by zakiaziz 15
  • Laravel 5.1 Middleware's using Sentinel 2.0

    Laravel 5.1 Middleware's using Sentinel 2.0

    I am creating an app using Laravel 5.1 and Sentinel. I have created custom Http Middleware to check whether the user is guest or authenticated. The problem that I am facing is Sentinel::check() and Sentinel::getUser() always returns FALSE in the Middleware's even when the user is logged in.

    I have gone through the code and can't understand what causing the issue. I am running the application on a virtual homestead development server.

    Can anyone provide some insight into why this may be happening?

    Bug Invalid 
    opened by kevinreynolds 15
  • Can't get Sentinel to work with UUIDs instead of incremental IDs

    Can't get Sentinel to work with UUIDs instead of incremental IDs

    Hello,

    I'm not sure this is a problem with the package, but maybe it is, so I'm also posting it here.

    Here's the link to the Stack Overflow question I made: https://stackoverflow.com/questions/40475580/laravels-eloquent-method-getkey-returns-the-first-number-of-the-uuid

    Thanks!

    Bug 
    opened by DanVeira 14
  • Switched arguments in function call in EloquentUser

    Switched arguments in function call in EloquentUser

    This call failed: if (Sentinel::inRole('admin')) with error "Fatal error: Call to a member function getRoleId() on integer"

    I noticed that the anonymous function in EloquentUser.php has the arguments switched https://github.com/cartalyst/sentinel/blob/2.0/src/Users/EloquentUser.php#L197

    Instead of $role = array_first($this->roles, function ($index, $instance) use ($role) { should be $role = array_first($this->roles, function ($instance, $index) use ($role) {

    Bug 
    opened by sabas 14
  • Logout Issues

    Logout Issues

    We have a private community site, using Laravel 5.1 and Sentinel providing the Auth system. We're having an issue where users are randomly getting logged out. I've looked through the code and can't figure out what's causing the issue.

    It's not after inactivity either, you could be browsing the site and randomly get logged out.

    Can anyone provide some insight into why this may be happening?

    Bug Invalid 
    opened by AzzAToTV 14
  • Accessor for last_login returns null

    Accessor for last_login returns null

    Trying to format the last login timestamps with Carbon via an accessor. To try and debug I attempted to just return the value:

    public function getLastLoginAttribute($timestamp)
    {
        return $timestamp;
    }
    

    It returns null. I then changed to $this->last_login but then received an Undefined Property error.

    Bug Invalid 
    opened by james-daddies 13
  • Use with Doctrine

    Use with Doctrine

    Has there been any work on using Sentinel with Doctrine? I'm happy to do it myself, if there aren't any packages that provide it - but I don't want to reinvent the wheel if it's already been done.

    Will it be as simple as writing Doctrine versions of the current Eloquent* models? Or will I run into any other challenges?

    opened by jasonlfunk 12
  • unable to login

    unable to login

    Hello, I am using sentinel for authentication in my project, when i used the project on my local machine(code + db on same machine ), it worked well. Right now, the code is in my machine and the database is another machine. The project is connecting to database but when trying to login, it returns null value for authenticate();

    opened by rajeshphilip0824 1
  • Authenticate using username or email

    Authenticate using username or email

    Your Environment

    • OS and Version: MacOS v12.4
    • PHP Version: 7.4.27
    • Sentinel Version: ^5.0

    Expected behaviour

    Login with username or email

    Actual behaviour

    When I use DB::enableQueryLog(), I noticed that it only check for email only, not username as well. I've created custom model that extend Cartalyst\Sentinel\User\EloquentUser and insert this code protected $loginNames = ['email', 'username']; But it's not working. I've tried from [this link](https://github.com/cartalyst/sentinel/issues/554#issuecomment-805941671

    opened by mar846 0
  • Activation::complete method returns PHP Fatal error:  Uncaught RuntimeException: A facade root has not been set error

    Activation::complete method returns PHP Fatal error: Uncaught RuntimeException: A facade root has not been set error

    Your Environment

    • OS and Version: Windows 10
    • PHP Version: 7.3
    • Sentinel Version: 5.0

    Hi guys, I am trying out Sentinel, but I am facing a challenge. Each time I call the Activation::complete method like this (Activation::complete($user, 'epzDOg6OHsHKLq5f5SPPdg7A9iUh2ukC')) I get an error message. `PHP Fatal error: Uncaught RuntimeException: A facade root has not been set. in C:\wamp64\www\practice\vendor\illuminate\support\Facades\Facade.php:258

    Using the Sentinel::registerAndActivate() method works fine; user is created and activated. But I want activation to be done separately. Please any ideas about what I am doing wrong?

    Thanks.

    opened by Edydeyemi 0
  • Cartalyst\Sentinel\Users\EloquentUser::getUserId(): Return value must be of type int, null returned

    Cartalyst\Sentinel\Users\EloquentUser::getUserId(): Return value must be of type int, null returned

    Your Environment

    • OS and Version: MacOS, Laravel 6
    • PHP Version: 8
    • Sentinel Version: 3.0.4

    Expected behaviour

    Activation::completed($user) to return boolean

    Actual behaviour

    Activation::completed($user) results in error Cartalyst\Sentinel\Users\EloquentUser::getUserId(): Return value must be of type int, null returned

    public function getUserId(): int { return $this->getKey(); }

    Steps to reproduce

    Calling Activation::completed() anywhere leads to this error

    opened by tidcp 0
  • registerAndActivate on a different connection doesn't work with config()

    registerAndActivate on a different connection doesn't work with config()

    I am creating and migrating databases on the fly, and have managed to successfully do this with seeding of data.

    However, when it comes to seeding a user on this new db using Sentinel::registerAndActivate , Sentinel defaults back to the main connection and creates a user on that connection.

    It doesn't respect the connection that I have specified for the new database via config('database.connection')

    Is there a workaround for this?

    opened by rxng 5
  • Prefix in database tables

    Prefix in database tables

    Description

    I am searching to configure prefix in database tables, to use multiple login or to implementing better organization in database infraestruture.

    Example

    tables: activations >> PREFIX_activations persistences >> PREFIX_persistences reminders>> PREFIX_reminders roles >> PREFIX_roles role_users >> PREFIX_role_users throttle > PREFIX_throttle users > PREFIX_users

    opened by mauroagr 0
Releases(v5.1.0)
  • v5.1.0(Dec 22, 2020)

  • v5.0.0(Sep 12, 2020)

  • v4.0.0(Mar 5, 2020)

  • v3.0.4(Feb 7, 2020)

  • v3.0.3(Sep 26, 2019)

  • v3.0.2(Sep 25, 2019)

  • v3.0.1(Sep 24, 2019)

  • v3.0.0(Sep 11, 2019)

    • BC Break: PHP 7.2 is the minimum required PHP version
    • BC Break: Laravel 6.0 is the minimum supported Laravel version
    • Added PHP 7 Scalar type hints
    • Added PHP 7 Return type hints
    • Added Sentinel::getCheckpoints() method to retrieve all the added Checkpoints
    • Added Sentinel::getActivationRepository()->get() method to retrieve the valid Activation
    • Added Sentinel::getReminderRepository()->get() method to retrieve the valid Reminder
    • Updated the Sentinel::getActivationRepository()->exists(); method to always return a boolean
    • Updated the Sentinel::getActivationRepository()->completed(); method to always return a boolean
    • Updated the Sentinel::getReminderRepository()->exists(); method to always return a boolean
    • Updated the findByPersistenceCode() to return a PersistenceInterface or null instead of PersistenceInterface or bool
    • Updated the findUserByPersistenceCode() to return UserInterface or null instead of UserInterface or bool
    • Fixed an issue where a call for EloquentUser::setPersistences was missing during bootstrap
    • Fixed an issue where personal permissions were not taking priority over pattern matching
    • Fixed an issue where the Throttling repository was not being set properly
    • Fixed an issue with the Native Cookie forget method
    • Fixed an issue where the events didn't had the payload passed correctly
    • Fixed an issue where the global throttles cache was not being cleared
    • Removed unnecessary dependencies
    • Removed integrations for both CodeIgniter and FuelPHP
    • Removed strict comparisons in favour of type hinting
    Source code(tar.gz)
    Source code(zip)
  • v2.0.18(Aug 14, 2019)

    ADDED

    • Added support for Larastan
    • Added events for logging in and logging out

    UPDATED

    • Updated the orWhere query builder loop to lead with correct boolean constraint
    • Updated several tests for better coverage and overall quality

    FIXED

    • Fixed an issue with the throttling threshold not behaving as expected
    • Fixed an issue where a model with soft deletes was causing issues when force deleting
    • Fixed an issue where the default global threshold value was incorrect
    • Fixed an issue with the order of overrides registration on the Laravel service provider
    • Fixed an issue with the checkPermission() method not behaving not casting some permissions as strings
    • Fixed an issue where the checkActivation method on the Activations Checkpoint was not returning the completion status
    • Fixed a few docblock typos
    Source code(tar.gz)
    Source code(zip)
  • v2.0.17(Nov 28, 2017)

  • v2.0.16(Nov 28, 2017)

  • v2.0.15(Feb 23, 2017)

  • v2.0.14(Jan 30, 2017)

    FIXED

    • Specify engine on the reminders table.
    • Single option on the native bootstrapper.
    • A bug causing inRole to return false after one iteration.
    • Use the event dispatcher contract.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.17(Jan 30, 2017)

  • v1.0.16(Jan 30, 2017)

  • v2.0.13(Sep 5, 2016)

    ADDED

    • Missing Throttle repository getter/setter.
    • Laravel 5.3 support.

    UPDATED

    • Detach the role from users when the role is deleted.
    • Pass persistence model from the configuration to the native bootstrapper.

    REMOVED

    • Removed usage of Laravel helpers.
    Source code(tar.gz)
    Source code(zip)
  • v2.0.12(May 13, 2016)

  • v2.0.11(Apr 28, 2016)

  • v2.0.10(Apr 28, 2016)

    FIXED

    • Delete method on the user model not returning parent.
    • Removed unused imports on some tests.
    • Reference to the stdClass on tests.
    • Various docblocks.

    UPDATED

    • User model to hide the hashed password by default.
    Source code(tar.gz)
    Source code(zip)
  • v2.0.9(Apr 28, 2016)

  • v2.0.8(Apr 28, 2016)

  • v1.0.15(Apr 28, 2016)

  • v2.0.7(Aug 26, 2015)

  • v1.0.14(Aug 26, 2015)

  • v2.0.6(Jul 21, 2015)

  • v1.0.13(Jul 21, 2015)

  • v2.0.5(Jul 9, 2015)

  • v2.0.4(Jun 25, 2015)

  • v1.0.12(Jun 25, 2015)

  • v2.0.3(Jun 24, 2015)

Owner
Cartalyst
We build framework agnostic PHP libraries for developers.
Cartalyst
Authentication and authorization library for Codeigniter 4

Authentication and Authorization Library for CodeIgniter 4. This library provides an easy and simple way to create login, logout, and user registratio

Rizky Kurniawan 12 Oct 10, 2022
This is a basic Oauth2 authorization/authentication server implemented using Mezzio.

Mezzio-OAuth2-Authorization-Authentication-Server This is a basic OAuth2 authorization/authentication server implemented using Mezzio. I have found so

null 1 Nov 15, 2022
Authentication, authorization and access control for PHP

Jasny Auth Authentication, authorization and access control for PHP. Features Multiple authorization strategies, like groups (for acl) and levels. Aut

Arnold Daniels 105 Dec 12, 2022
Vendor-Agnostic Two-Factor Authentication

Multi-Factor Designed to be a vendor-agnostic implementation of various Two-Factor Authentication solutions. Developed by Paragon Initiative Enterpris

Paragon Initiative Enterprises 139 Dec 21, 2022
php database agnostic authentication library for php developers

Whoo Whoo is a database agnostic authentication library to manage authentication operation easily. Whoo provides you a layer to access and manage user

Yunus Emre Bulut 9 Jan 15, 2022
Auth is a module for the Yii PHP framework that provides a web user interface for Yii's built-in authorization manager

Auth is a module for the Yii PHP framework that provides a web user interface for Yii's built-in authorization manager (CAuthManager). You can read more about Yii's authorization manager in the framework documentation under Authentication and Authorization.

Christoffer Niska 134 Oct 22, 2022
Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

Rinvex Authy Rinvex Authy is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest AP

Rinvex 34 Feb 14, 2022
It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session and API Authentication

About Auth Starter It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session an

Sami Alateya 10 Aug 3, 2022
phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

Apereo Foundation 780 Dec 24, 2022
Declarative style of authorization and validation in laravel.

Laravel Hey Man Readability Counts. In fact, Readability is the primary value of your code !!! ?? Heyman continues where the other role-permission pac

Iman 860 Jan 1, 2023
Minimalistic token-based authorization for Laravel API endpoints.

Bearer Minimalistic token-based authorization for Laravel API endpoints. Installation You can install the package via Composer: composer require ryang

Ryan Chandler 74 Jun 17, 2022
An authorization library that supports access control models like ACL, RBAC, ABAC in PHP .

PHP-Casbin Documentation | Tutorials | Extensions Breaking News: Laravel-authz is now available, an authorization library for the Laravel framework. P

PHP-Casbin 1.1k Dec 14, 2022
Files Course Laravel Micro Auth and Authorization

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

EspecializaTi 8 Oct 22, 2022
Easy, native Laravel user authorization.

An easy, native role / permission management system for Laravel. Index Installation Migration Customization Model Customization Usage Checking Permiss

DirectoryTree 5 Dec 14, 2022
It's authorization form, login button handler and login to your personal account, logout button

Authorization-form It's authorization form, login button handler and login to your personal account, logout button Each file is: header.php - html-fil

Galina 2 Nov 2, 2021
Manage authorization with granular role-based permissions in your Laravel Apps.

Governor For Laravel Manage authorization with granular role-based permissions in your Laravel apps. Goal Provide a simple method of managing ACL in a

GeneaLabs, LLC 149 Dec 23, 2022
EvaOAuth provides a standard interface for OAuth1.0(a) / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few lines code.

EvaOAuth EvaOAuth provides a standard interface for OAuth1.0 / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few

AlloVince 256 Nov 16, 2022
EvaOAuth provides a standard interface for OAuth1.0(a) / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few lines code.

EvaOAuth EvaOAuth provides a standard interface for OAuth1.0 / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few

AlloVince 261 Jan 17, 2022