noraziz/ci4-aauth 问题修复 & 功能扩展

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

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

noraziz/ci4-aauth

Composer 安装命令:

composer require noraziz/ci4-aauth

包简介

Aauth is a User Authorization Library for CodeIgniter 4.x, the original version https://github.com/emreakay/CodeIgniter-Aauth

README 文档

README

Aauth is a User Authorization Library for CodeIgniter 4.x, the original version aauth, which aims to make easy some essential jobs such as login, permissions and access operations. Despite its ease of use, it has also very advanced features like private messages, groupping, access management, and public access.

This is Quick Start page. You can also take a look at the detailed Documentation Wiki to learn about other great Features

Features

  • User Management and Operations (login, logout, register, verification via e-mail, forgotten password, user ban, login DDoS protection)
  • Group Operations (creating/deleting groups, membership management)
  • Admin and Public Group support (Public permissions)
  • Permission Management (creating/deleting permissions, allow/deny groups, public permissions, permission checking)
  • Group Permissions
  • User Permissions
  • User and System Variables
  • Login DDoS Protection
  • Private Messages (between users)
  • Error Messages and Validations
  • Langugage and config file support
  • Flexible implementation

What's new

  • PSR-4 Compatibility, using branch psr4-lib.

Migration

  • Coming soon.

Quick Start

Let's get started :) First, we will load the Aauth Library into the system

$this->load->library("Aauth");

That was easy!

Now let's create two new users, Frodo and Legolas.

$this->aauth->create_user('frodo@example.com','frodopass','FrodoBaggins');
$this->aauth->create_user('legolas@example.com','legolaspass','Legolas');

We now we have two users.

OK, now we can create two groups, hobbits and elves.

$this->aauth->create_group('hobbits');
$this->aauth->create_group('elves');

Now, let's create a user with power, Gandalf (for our example, let's assume he was given the id of 12).

$this->aauth->create_user('gandalf@example.com', 'gandalfpass', 'GandalfTheGray');

OK, now we have two groups and three users.

Let's create two permissions walk_unseen and immortality

$this->aauth->create_perm('walk_unseen');
$this->aauth->create_perm('immortality');

Ok, now let's give accesses to our groups. The Hobbits seem to have ability to walk unseen, so we will assign that privilage to them. The Elves have imortality, so we will assign that privilage to them. We will assign access with allow_group() function.

$this->aauth->allow_group('hobbits','walk_unseen');
$this->aauth->allow_group('elves','immortality');
  
  
$this->aauth->allow_group('hobbits','immortality');

Wait a minute! Hobbits should not have immortality. We need to fix this, we can use deny_group() to remove the permission.

$this->aauth->deny_group('hobbits','immortality');

Gandalf can also live forever.

$this->aauth->allow_user(12,'immortality');

Ok now let's check if Hobbits have immortality.

if($this->aauth->is_group_allowed('hobbits','immortality')){
	echo "Hobbits are immortal";
} else {
	echo "Hobbits are NOT immortal";
}

Results:

Hobbits are NOT immortal

Does Gandalf have the ability to live forever?

if($this->aauth->is_allowed(12,'immortality')){
	echo "Gandalf is immortal";
} else {
	echo "Gandalf is NOT immortal";
}

Results:

Gandalf is immortal

Since we don't accually live in Middle Earth, we are not aware of actual immortality. Alas, we must delete the permission.

$this->aauth->delete_perm('immortality');

It is gone.

Un-authenticated Users

So, how about un-authenticated users? In Aauth they are part of the public group. Let's give them permissions to travel. We will assume we already have a permission set up named travel.

$this->aauth->allow_group('public','travel');

Admin Users

What about the Admin users? The Admin user and any member of the Admin group is a superuser who had access everthing, There is no need to grant additional permissions.

User Parameters/Variables

For each user, variables can be defined as individual key/value pairs.

$this->aauth->set_user_var("key","value");

For example, if you want to store a user's phone number.

$this->aauth->set_user_var("phone","1-507-555-1234");

To retreive value you will use get_user_var():

$this->aauth->get_user_var("key");

Aauth also permits you to define System Variables. These can be which can be accesed by all users in the system.

$this->aauth->set_system_var("key","value");
$this->aauth->get_system_var("key");

Private Messages

OK, let's look at private messages. Frodo (id = 3) will send a PM to Legolas (id = 4);

$this->aauth->send_pm(3,4,'New cloaks','These new cloaks are fantastic!')

Banning users

Frodo has broke the rules and will now need to be banned from the system.

$this->aauth->ban_user(3);

You have reached the end of the Quick Start Guide, but please take a look at the detailed Documentation Wiki for additional information.

Don't forget to keep and eye on Aauth, we are constantly improving the system. You can also contribute and help me out. :)

noraziz/ci4-aauth 适用场景与选型建议

noraziz/ci4-aauth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Authentication」 「library」 「codeigniter」 「codeigniter4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 noraziz/ci4-aauth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 noraziz/ci4-aauth 我们能提供哪些服务?
定制开发 / 二次开发

基于 noraziz/ci4-aauth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2023-03-29