networkrailbusinesssystems/user-login

Provide user login with active directory account with minimal overhead
1,419
Install
composer require networkrailbusinesssystems/user-login
Latest Version:4.0.2
PHP:^8
License:MIT
Last Updated:Jun 1, 2026
Links: GitHub  ·  Packagist
Maintainer: AnthonyEdmonds

User Login.

This package provides user login functionality.

Built for Laravel 11.

Installation

Add the library using Composer:

composer require networkrailbusinesssystems/user-login

The service provider will be automatically registered.

Configuration

1. Export the config file

To customize the package, export the configuration file using Artisan:

php artisan vendor:publish --provider="NetworkRailBusinessSystems\UserLogin\Providers\UserLoginServiceProvider" --tag=config

2. Publish the views.

To modify the login views, publish the package views using Artisan:

php artisan vendor:publish --provider="NetworkRailBusinessSystems\UserLogin\Providers\UserLoginServiceProvider" --tag=views

3. Available Configuration Options

After publishing, you can modify the following configuration options in the config/user-login.php file:

Option Type Default Usage
view string gov-uk-login Customise the view to be used for the login page
auth-identifier string samaccountname Customise the attribute used for authentication
local-email-indentifer string email Customise the email attribute for the user in local model
local-model class \App\Models\User::class Customise the class for local user
local-model-identifier string username Customise the attribute identifies the user in local model
local-unique-identifier string guid Customise the unique attribute identifies the user in local model
ldap-model class \LdapRecord\Models\ActiveDirectory\User::class Customise the class for LDAP user
ldap-model-identifier string samaccountname Customise the attribute identifies the user in LDAP model
ldap-unique-identifier string objectguid Customise the unique attribute identifies the user in LDAP model
login-failed-message string Sign-in failed; check your details and try again. Customise the message for login failure
login-success-message string You have successfully signed in. Customise the message for login success
forgot-password array 'description' => null, routes => ['label' => 'name'] Customise the "Forgot Password" section in view You can set a description and routes for IT helpdesk or password reset.

Routing

A route macro is provided to handle the login.

Route::userLogin();

interface: ExistingUser

The ExistingUser interface defines an abstract function for retrieving the unique identifier

Trait: HasGuidInDatabase

The HasGuidInDatabase trait provides a method uniqueIdentifier to fetch a user unique identifier (like a GUID) from your local database.

Trait: HasGuidInLdap

The HasGuidInLdap trait provides a method uniqueIdentifier to fetch a user unique identifier (like a objectguid) from LDAP.

uniqueIdentifier($username)

  • $username: This is the value used to authenticate the user.

  • The method returns the user GUID if found, or null if no match is found.

Usage

The package handles user routing and validation without requiring a custom Login Controller and Login Request.

How to Set Up the Login Functionality

To get the user login functionality up and running, follow these steps:

  1. In your User model or any other model you want to use for authentication, must implement the ExistingUser interface and use one of the provided traits (HasGuidInLdap, HasGuidInDatabase) to retrieve the unique identifier.
class User extends Model implements ExistingUser
{
    use HasGuidInLdap;

    // Other logic...
}
  1. Add the following route macro to your routes/web.php file to handle the login routes automatically.
Route::userLogin();

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

634,760,849 9,707
laravel/framework

The Laravel Framework.

584,532,650 34,931
laravel/tinker

Powerful REPL for the Laravel framework.

493,838,477 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

408,553,772 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

387,976,821 4,658