Download the PHP package zaengle/laravel-security-notifications without Composer

On this page you can find all versions of the php package zaengle/laravel-security-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-security-notifications

Tests

Laravel Security Notifications

This package adds an out-of-the-box, fully customizable solution for sending security notifications to users when their account is updated or accessed from a new device.

Installation

composer require zaengle/laravel-security-notifications

Testing

./vendor/bin/pest

Setup

Publish Configuration

php artisan vendor:publish --provider="Zaengle\LaravelSecurityNotifications\Providers\PackageServiceProvider" --tag="config"

Use Trait

In order to send security notifications, you'll need to add the Securable trait to your user model. Additionally, you'll want to make sure you are using Laravel's Notifiable trait.

Basic Usage

Securing Fields

The Securable trait watches your user model for updates to the specified secure fields. By default, the secure fields are email, username, and password. If any of these fields are updated, a security notification will be sent to the user. The original email address will be notified in the event that the email field is updated.

You may customize the secure fields by overriding the getSecureFields method on your user model.

Securing Logins

The Securable trait also provides a logins relationship that can be used to track user logins. This relationship tracks all IP addresses that have logged into the user's account. In order to set up secure logins, you'll need to publish and run the migration included in the package to set up a logins table. This table name is configurable in the published security-notifications.php config file.

You can use the IPAddress facade to track user logins in your existing login controller. If the given IP address has already been used, it will update the login record with the login time. If the IP address is new, it will create a new login record and send a notification to the user.

Disable Package

If you would like to disable the entire package you can set the following config value:

'enabled' => false

Disable Notifications

If you would like to disable sending notifications you can set the following config value:

'send_notifications' => false

Customizing Notification Templates

Custom Email Templates

The package provides email notification templates out-of-the-box. However, if you would like to customize these templates to match your system, you may publish the views to your application and override them.

php artisan vendor:publish --provider="Zaengle\LaravelSecurityNotifications\Providers\PackageServiceProvider" --tag="views"

They will be available under resources/views/vendor/security-notifications.

There are two views that can be customized. Each with access to specific data:

Custom Notification Classes

If you would like to further customize the notifications, you can configure the notification classes in the security-notifications.php config file.

Customizing Email Address

By default, this package assumes that the user model has an email attribute. If you would like to customize the email address that notifications are sent to, you can override the sendSecurityEmailsTo method on the models that utilize the Securable trait.

`

Custom IP Address Driver

If you would like to have full control over IP address and login handling, you can create a custom driver by implementing the Zaengle\LaravelSecurityNotifications\Services\DigestIPAddress interface like the example below.

Be sure to update the ip_address_driver config value to point to your custom driver.

This will tell the IPAddress facade to use your custom driver. Simply pass an array of data to IPAddress::process() matching your __construct definition.

Allow multiple IP's with same location

While this is not recommeded for most cases, you may run into a situation where users are on a network that changes IP addresses frequently (E.g. a public school network). In this case, the user is going to receive an email every time they log in because their IP address will have changed. This is probably not ideal. To account for this, you can configure the option to allow same location logins. This means that a user may login with as many IP addresses as they want and it will assume they are the same person as long as the location remains the same. This is based on the city and state/region.

To enable this, add the following value to the package config:

Using Paid API

Be default, this package uses the free api provided by ip-api.com. If you would like to use their paid API to increase rate limiting, you can set the following env value with your api key:

License

The MIT License (MIT). Please see License File for more information.

Credits


All versions of laravel-security-notifications with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zaengle/laravel-security-notifications contains the following files

Loading the files please wait ....