reshadman/
laravel-mongo-auth
g4t.io

Laravel Mongo Auth

19 views 29 stars by Eric L. Barnes

A native mongo db auth driver on Laravel 5's default auth module.

README from reshadman/laravel-mongo-auth Open on GitHub →

Laravel Native MongoDB Authentication Driver

This package does not require any external MongoDB related dependencies except the Php MongoDB Driver and simply uses Auth::extend() to extend the native Laravel Auth module.

Installation

  1. Run composer require reshadman/laravel-mongo-auth in your project's composer root.
  2. Add the Reshadman\LmAuth\LmAuthServiceProvider service provider to your app.
  3. Run php artisan vendor:publish command to generate package config files.
  4. In auth.php config set the driver to lmauth :
<?php return [
    //...
    'driver' => 'lmauth'
];

Approach

An instance of MongoCollection is passed to \Reshadman\LmAuth\MongoDbUserProvider like below :

From \Reshadman\LmAuth\LmAuthServiceProvider :

<?php
$this->app['auth']->extend('lmauth', function(Application $app){

    $config = $app['config']->get('lmauth');

	return new MongoDbUserProvider(
	    $app['lmauth.collection'], // Should be bound to an instance of \MongoCollection
	    $app['hash'],
	    $config
	);

});

The above code needs $app['lmauth.collection'] to be available in IoC container which is an instance of MongoCollection. If you set the use_default_collection_provider config option to true, the package will create a new binding for that.

You may also create your own driver with another driver name and pass your own config and mongo collection instance to it.

<?php
Auth::extend('my-lmauth', function($app) {
    $config = $app['config']->get('lmauth'); // or your desired
    $mongoCollection = $app['global_mongo_connection']->myDb->myCollection;

    return new \Reshadman\LmAuth\MongoDbUserProvider($mongoCollection, $app['hash'], $config);
});

The default_connection_closure config

If you pass a closure to this config key then the package will use this closure to get the MongoClient connection to connect to mongodb. Usefull when using Doctrine Mongo db package or alternatives.

<?php return [
    //...
    'default_connection_closure' => function($app) {
        return new \MongoClient('192.168.0.2:27013'); // or $app['mongo.singleton_connection']
    }
];

If you set the above option to null the the package will use a singleton shared instance ( new \MongoClient()) which has lmauth.connection key in the container.

More from the ecosystem

durable-workflow/
workflow
g4t.io
9 1,292

Durable Workflow: Long-Running Workflows for Laravel

Embedded durable workflow runtime and orchestration engine for Laravel applications.

durable-workflow/workflow via Laravel News
packstub/
session-replay
g4t.io
14 52

Session Replay for Laravel: Self-Hosted Browser Recordings

Session replay for Laravel: record what a person did in the browser with rrweb, keep the recording on your own disk and database, and watch it behind a gate you define — masked inputs by default, errors, failed Livewire requests and web vitals marked on the timeline, a link to the replay in every log line. packstub/filament-session-replay adds the sessions to a Filament panel.

packstub/session-replay via Laravel News
cyberwizard-dev/
schedule-catchup
g4t.io
17

Replay Missed Laravel Scheduled Tasks With Schedule Catchup

Schedule Catchup replays missed Laravel scheduled tasks after downtime, with opt-in recovery, bounded retries, and access to the original scheduled date.

cyberwizard-dev/schedule-catchup via Laravel News