定制 fadhil_riyanto/noauth-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fadhil_riyanto/noauth-laravel

Composer 安装命令:

composer require fadhil_riyanto/noauth-laravel

包简介

static auth set without DB

README 文档

README

is a non-database authentication that keeps authentication as small as possible. good for single-user APP

Setup

create your password list inside .env with comma-separated string

NOAUTH_PASSWORD="abc123,foobar123,otherxyz"

first, use the namespace

use FadhilRiyanto\NoAuthLaravel\NoAuth;

defining routes for guest which try access route with NoAuthMiddleware class, the route must be named as 'noauth-guest', example

// guest will redireced here
Route::get('login', function() {
        return view('admin/login');
})->name("noauth-guest");

define admin route with middleware, example

// protect admin page using middleware NoAuthMiddleware
Route::get('home', [Controllers\AdminController::class, 'handle_admin_homepage'])
                ->middleware(NoAuthMiddleware::class);

authentication example, NoAuth::attemp is automatically create a session if successful and return false otherwise

class AdminController extends Controller
{
        public function handle_admin_login_ajax(Request $request)
        {
                $validator = Validator::make($request->all(), [
                        'password' => 'required',
                ]);

                $validated = $validator->validated();

                if (NoAuth::attemp($request)) {
                        return response()->json(["message" => "Welcome"], 200);
                } else {
                        return response()->json(["message" => "The provided credentials do not match our records"], 400);
                }
        }
}

Maintainer:

Fadhil-Riyanto

License

GPL-2.0

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2025-01-22