定制 mlukman/securilex 二次开发

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

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

mlukman/securilex

Composer 安装命令:

composer require mlukman/securilex

包简介

Securilex is a simplified security provider for Silex.

README 文档

README

Packagist Version Build Status

Securilex is a simplified security provider for Silex.

The main class for Securilex is \Securilex\SecurityServiceProvider.

Usage:

// $app is instance of \Silex\Application
$app->register(new \Securilex\ServiceProvider());

// securilex is now a service
$app['securilex']-> ...

Authentication

Authentication deals with identifying user identity via login mechanism. The main class for authentication is \Securilex\Firewall.

To define a firewall, you need to define four items:

  1. The path(s) to secure: whether the whole site (/) or just specific area (/admin/).
  2. The path to login page = optional, if none specific it will use browser login popup (i.e. Basic HTTP Authentication).
  3. The authentication factory = method of authentication, e.g. plaintext password validation, encoded password validation, LDAP, OAuth etc.
  4. The user provider = source to get the list of users, e.g. hard-coded, database etc.

The first two items are required when constructing a Firewall:

$firewall = new \Securilex\Firewall('/secure/', '/login/');

You can define multiple secure paths to be under the same firewall:

$firewall = new \Securilex\Firewall(array('/secure/', '/admin/'), '/login/');

The next two items are to be passed to addAuthenticationFactory method:

$firewall->addAuthenticationFactory($authFactory, $userProvider);

Register the firewall to securilex using addFirewall() method:

$app['securilex']->addFirewall($firewall);

Authentication Factory

Authentication Factory defines the method of authentication of user credentials. Securilex comes with a few ready-to-use authentication factories:

  • PlaintextPasswordAuthenticationFactory - simply compares the entered password with the stored plaintext password.
  • LdapBindAuthenticationFactory - authenticates login using external LDAP service.
  • InitializableAuthenticationFactory - provides authentication mechanism that remembers the first password that users enter after registration/resetting the password. Requires a user provider that implements MutableUserProviderInterface (will be further explained in the next section).
  • SimpleAuthenticationFactory - delegates authentication to another class that implements SimpleAuthenticatorInterface.

You can create additional factories by:

  1. implementing AuthenticationFactoryInterface (LdapBindAuthenticationFactory does this), or
  2. extending SimpleAuthenticationFactory while implementing SimpleAuthenticatorInterface (PlaintextPasswordAuthenticationFactory and InitializableAuthenticationFactory do this).

User Provider

User Provider provides the list of users who have access to the corresponding firewall. Securilex supports all Symfony's existing user providers while it also provides additional ones:

  • NoPasswordUserProvider - when the application cannot know the passwords of the users, for example when using LdapBindAuthenticationFactory.
  • UserProviderSegmentalizer - when a list of users needs to be segmentalized to be authenticated by different authentication factories. Instead of defining two user providers with slightly different parameters and potentially causing redundant calls to database or external source, using segmentalizer will cache the user data while it is being authenticated by multiple authentication factories.

Authorization

Authorization deals with allowing or denying access to page or resource.

// TODO: Work In Progress

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-2.0-only
  • 更新时间: 2016-05-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固