• Stars
    star
    228
  • Rank 175,267 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A HTTP basic auth middleware for Laravel

shield

Laravel Shield

A HTTP basic auth middleware for Laravel.

// Use on your routes.
Route::get('/', ['middleware' => 'shield'], function () {
    // Your protected page.
});

// Use it within your controller constructor.
$this->middleware('shield');

// Use specific user credentials.
$this->middleware('shield:hasselhoff');

Build Status Monthly Downloads Latest Version

Installation

Require this package, with Composer, in the root directory of your project.

composer require vinkla/shield

Add the middleware to the $routeMiddleware array in your Kernel.php file.

'shield' => \Vinkla\Shield\ShieldMiddleware::class,

Configuration

Laravel Shield requires configuration. To get started, you'll need to publish all vendor assets:

$ php artisan vendor:publish

This will create a config/shield.php file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

HTTP Basic Auth Credentials

The user credentials which are used when logging in with HTTP basic authentication.

Usage

To protect your routes with the shield you can add it to the routes file.

Route::get('/', ['middleware' => 'shield'], function () {
    // Your protected page.
});

You can also add the shield middleware to your controllers constructor.

$this->middleware('shield');

The middleware accepts one optional parameter to specify which user credentials to compared with.

$this->middleware('shield:kitt');

To add a new user, you probably want to use hashed credentials. Hashed credentials can be generated with the password_hash() function in the terminal:

php -r "echo password_hash('my-secret-passphrase', PASSWORD_DEFAULT);"

Then copy and paste the hashed credentials to the .env environment file.

SHIELD_USER=your-hashed-user
SHIELD_PASSWORD=your-hashed-password

More Repositories

1

hashids

A small PHP library to generate YouTube-like ids from numbers. Use it when you don't want to expose your database ids to the user.
PHP
5,053
star
2

wordplate

WordPlate is a boilerplate for WordPress, built with Composer and designed with sensible defaults.
PHP
1,974
star
3

laravel-hashids

A Hashids bridge for Laravel
PHP
1,909
star
4

instagram

An easy-to-use and simple Instagram package
PHP
493
star
5

extended-acf

Register advanced custom fields with object oriented PHP
PHP
376
star
6

climb

A Composer version manager tool
PHP
359
star
7

laravel-translator

An Eloquent translator for Laravel
PHP
274
star
8

laravel-gitlab

A GitLab bridge for Laravel
PHP
143
star
9

laravel-facebook

A Facebook bridge for Laravel
PHP
114
star
10

laravel-alert

A Bootstrap alert helper for Laravel
PHP
110
star
11

laravel-backup

A easy-to-use backup manager for Laravel
PHP
93
star
12

laravel-algolia

An Algolia bridge for Laravel
PHP
71
star
13

headache

An easy-to-swallow painkiller plugin for WordPress
PHP
71
star
14

recaptcha

An easy-to-use reCAPTCHA package
PHP
55
star
15

alfred-packagist

Alfred workflow to search for PHP packages with Packagist
JavaScript
21
star
16

base62

A reversible base62 ID obfuscator
PHP
21
star
17

local-login

Enable automatic login within a local WordPress environment
PHP
4
star
18

laravel-sqids

PHP
3
star
19

extended-api

Enhancing the WordPress REST API with advanced request and response objects. Work in progress.
PHP
3
star
20

bason

A lightweight JSON viewer extension for Chromium based browsers
JavaScript
2
star
21

salts

A salts generator for environment files in WordPlate
HTML
2
star
22

tabsli.de

Simple text slides for your browser-based presentation.
Svelte
1
star