opb/slim-basic-auth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

opb/slim-basic-auth

Composer 安装命令:

composer require opb/slim-basic-auth

包简介

HTTP Basic Auth Middleware for the Slim PHP Framework

README 文档

README

This HTTP Basic Auth Middleware plugin for Slim. Key features:

  • Protects a path and all sub-paths. For example, setting it to protect /admin will also protect /admin/foo and /admin/bar/baz but not /foo.

  • Provides an interface AuthCheckerInterface for you to implement, in order to check a username/password combo against your own user database. An example is provided below of this in use.

Install

Install via composer:

{
    "require": {
        "opb/slim-basic-auth": "dev-master"
    }
}

Usage

The HttpBasicAuth middleware class is instantiated with two parameters: a mandatory implementation of AuthCheckerInterface and an optional array of options. The two options currently supported are the path to match, and the realm if you wish to set that. The example below shows how you might implement this.

// MyAuthClass - implementing the required AuthCheckerInterface

class MyAuthClass implements \Slim\Middleware\AuthCheckerInterface
{
	// only function required by the interface
	public function checkCredentials($username, $password)	{
		// interact with your own auth system
		// do some stuff and return true if authorised, false if not	
	}
}

// the rest of your Slim app, adding in the middleware

$app = new \Slim\Slim();

$authChecker = new MyAuthCLass;

$app->add(new \Slim\Middleware\HttpBasicAuth($authChecker, array(
	'path' => '/api', // optional, defaults to '/'
	'realm' => 'Protected API' // optional, defaults to 'Protected Area'
)));

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-06-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固