承接 ohtarr/laravelazure 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ohtarr/laravelazure

Composer 安装命令:

composer require ohtarr/laravelazure

包简介

Laravel Azure Token Authentication

README 文档

README

Add Azure AD Token Validation and role assignment via the following php packages:

https://github.com/ohtarr/Azure - AzureAD Authentication and Token Validation
https://github.com/JosephSilber/bouncer - Authorization

Installation:

Add library to your Laravel project:

composer require ohtarr/LaravelAzure

You must have an application registration in Azure with role based permissions setup.

Add the necessary env vars for Azure Active Directory OAUTH:

AZURE_AD_TENANT=MyAwesomeAzureADTenant
AZURE_AD_CLIENT_ID=1234abcd-12ab-34cd-56ef-123456abcdef
AZURE_AD_CLIENT_SECRET=123456789abcdef123456789abcdef\123456789abc=

Publish LaravelAzure files - migration to add azure_id to users table, addPermission command to easily add bouncer permissions.

php artisan vendor:publish --provider="Ohtarr\LaravelAzure\ServiceProvider" --force

Publish Bouncer files - Standard bouncer migrations to add tables for authorization control

php artisan vendor:publish --provider="Silber\Bouncer\BouncerServiceProvider" --force

Migrate

php artisan migrate

Add Bouncer to User model at /app/Models/User.php

namespace App\Models;

use Silber\Bouncer\Database\HasRolesAndAbilities;

class User extends Authenticatable
{
		use HasRolesAndAbilities;
}

Add permissions via addPermission command, or add bouncer permissions your own way...

# modify addPermission file
nano app/Console/Commands/addPermission.php

	#modify the objects array to include all of the objects you want to assign permissions to:
	$objects = [
		\App\Models\Thing::class,
	];

# execute addPermission
php artisan LaravelAzure:addPermission write Admin

add auth:api middleware to controllers or routes. Controller example below.

#controller constructor:
public function __construct()
{
	$this->middleware('auth:api');
}

add authorization check to controller methods as needed

public function index(Request $request)
{
	//IF user is authorized
	$user = auth()->user();

	if ($user->cant('read', Model::class)) {
		abort(401, 'You are not authorized');
	}
	return $coolapistuff;
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2022-09-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固