jeremykenedy/laravel-https

Laravel Https is middleware to check for Secure HTTP requests. Laravel Https middleware providers can check and redirect if the user is not hitting the https url of your app/site or the request can be automatically redirected to a Secure Http (HTTPS) request.

v2.0.0 2023-02-26 23:57 UTC

This package is auto-updated.

Last update: 2024-11-27 03:59:58 UTC


README

Laravel Https

Laravel HTTPS Web and API Checker

Laravel Https is middleware to check for Secure HTTP requests. Laravel Https has can check for HTTPS and throw an error or automatically redirect to HTTPS.

Latest Stable Version Total Downloads StyleCI License: MIT

Features

Requirements

Installation Instructions

  1. From your projects root folder in terminal run:

        composer require jeremykenedy/laravel-https
  2. Register the package

    • Laravel 5.5 and up Uses package auto discovery feature, no need to edit the config/app.php file.

    • Laravel 5.4 and below Register the package with laravel in config/app.php under providers with the following:

        'providers' => [
        ...
            jeremykenedy\LaravelHttps\LaravelHttpsServiceProvider::class,
        ];
  3. Optionally publish the packages views, config file, and language files by running the following from your projects root folder:

        php artisan vendor:publish --tag=LaravelHttps
  4. Add the middleware to your routes or controller. See Usage.

Configuration

laravel-https can be configured in directly in /config/laravel-https.php if you published the assets. Or you can variables to your .env file.

Environment File

Here are the .env file variables available:

LARAVEL_HTTP_ERROR_CODE=403

Usage

From Route File:
  • You can include the checkHTTPS or forceHTTPS in a route groups or on individual routes.
Route Group Example:
    Route::group(['middleware' => ['web', 'checkHTTPS']], function () {
        Route::get('/', 'WelcomeController@welcome');
    });
Individual Route Examples:
    Route::get('/', 'WelcomeController@welcome')->middleware('checkHTTPS');
    Route::match(['post'], '/test', 'Testing\TestingController@runTest')->middleware('forceHTTPS');
From Controller File:
  • You can include the checkHTTPS or forceHTTPS in the contructor of your controller file.
Controller File Example:
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
       $this->middleware('forceHTTPS');
    }

Screenshots

Http Middleware checkHTTPS API Middleware checkHTTPS

File Tree

├── .gitignore
├── LICENSE
├── README.md
├── composer.json
└── src
    ├── LaravelHttpsServiceProvider.php
    ├── app
    │   └── Http
    │       └── Middleware
    │           ├── CheckHTTPS.php
    │           └── ForceHTTPS.php
    ├── config
    │   └── laravel-https.php
    └── resources
        ├── lang
        │   └── en
        │       └── laravel-https.php
        └── views
            └── errors
                └── 403.blade.php
  • Tree command can be installed using brew: brew install tree
  • File tree generated using command tree -a -I '.git|node_modules|vendor|storage|tests'

Opening an Issue

Before opening an issue there are a couple of considerations:

  • You are all awesome!
  • Read the instructions and make sure all steps were followed correctly.
  • Check that the issue is not specific to your development environment setup.
  • Provide duplication steps.
  • Attempt to look into the issue, and if you have a solution, make a pull request.
  • Show that you have made an attempt to look into the issue.
  • Check to see if the issue you are reporting is a duplicate of a previous reported issue.
  • Following these instructions show me that you have tried.
  • If you have a questions send me an email to jeremykenedy@gmail.com
  • Need some help, I can do my best on Slack: https://opensourcehelpgroup.slack.com
  • Please be considerate that this is an open source project that I provide to the community for FREE when openeing an issue.

Open source projects are a the community’s responsibility to use, contribute, and debug.

License

Laravel-https is licensed under the MIT license. Enjoy!