Use Permify in server-side PHP Projects.

Overview

Permify Php Library

Twitter URL

Use Permify in server-side PHP Projects.

What is Permify?​

Permify is a plug-&-play authorization API that helps dev teams create granular access control and user management systems without breaking a sweat!

You can easily create complex and flexible RBAC and ABAC solutions without dealing with any learning curve.

Installation

You can install the package via composer:

composer require permify/permify-php

Setup

To get started, create the Permify client using your workspace id and API private token:

use Permify\Client;

$client = new Client("workspace_id", "private_token");

Documentation and Usage Instructions

See the documentation for usage instructions.

An example for better understanding of Permify with the IsAuthorized function

IsAuthorized

This method returns a decision about whether the user is authorized for this action with the given parameters.

Parameters

  • PolicyName (mandatory)

Custom Permify Policy name.

  • UserID (mandatory)

Id of the User

  • ResourceID (optional)

Id of the Resource, mandatory if any resource used or accessed when creating Rule/Rules.

  • ResourceType (optional)

Type or name of the Resource, mandatory if any resource used or accessed when creating Rule/Rules.

use Permify\Requests\IsAuthorized;

$isAuthz = $client->call(new IsAuthorized("post-edit", "1", ["resource_id"=> "1", "resource_type" => "posts"]));
echo (int) $isAuthz->allow;

Error handling

For the sake of brevity, the doc instructions omit exception handling. However, various exceptions can occur while processing request, for example because of adding an already existing user or because of timeout.

Example:

use Permify\Requests;
use Permify\Exceptions;

try
{
    $resource = $client->send(
      new CreateResource("group_id", "resource_type", ["id" => "resource_id", "attributes" => ["custom attribute" => "custom"]])
    );
}
catch(Exceptions\ApiTimeoutException $e)
{
    //Handle timeout => use fallback
}
catch(Exceptions\ResponseException $e)
{
    //Handle errorneous request => use fallback
}
catch(Exceptions\PermifyException $e)
{
    //PermifyException is parent of both ResponseException and ApiTimeoutException
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] or [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

❤️ Let's get connected:

guilyx | Twitter guilyx's LinkdeIN guilyx's Discord

You might also like...
A support-rich server software for Minecraft Bedrock Edition based on PocketMine-MP.
A support-rich server software for Minecraft Bedrock Edition based on PocketMine-MP.

A support-rich server software for Minecraft Bedrock Edition based on PocketMine-MP. Credits @ItzLightyHD - Adding features to OpenTouch (new API, mo

This is a basic Oauth2 authorization/authentication server implemented using Mezzio.
This is a basic Oauth2 authorization/authentication server implemented using Mezzio.

Mezzio-OAuth2-Authorization-Authentication-Server This is a basic OAuth2 authorization/authentication server implemented using Mezzio. I have found so

A plugin for implementing an OAuth2 server in CakePHP 3

OAuth2 Server for CakePHP 3 A plugin for implementing an OAuth2 server in CakePHP 3. Built on top of the PHP League's OAuth2 Server. Currently we supp

Symfony bundle which provides OAuth 2.0 authorization/resource server capabilities

Symfony bundle which provides OAuth 2.0 authorization/resource server capabilities. The authorization and resource server actors are implemented using the thephpleague/oauth2-server library.

Static utilitiy classes to bridge PSR-7 http messages to OAuth2 Server requests and responses.

Static utilitiy classes to bridge PSR-7 http messages to OAuth2 Server requests and responses. While this libray is entended for use with Slim 3, it should work with any PSR-7 compatible framework.

OAuth server implementation for WP API

WP REST API - OAuth 1.0a Server Connect applications to your WordPress site without ever giving away your password. This plugin uses the OAuth 1.0a pr

Painless OAuth 2.0 Server for CodeIgniter 4 🔥
Painless OAuth 2.0 Server for CodeIgniter 4 🔥

Inspired from the Norse mythology, Heimdallr, modernly anglicized as Heimdall is the gatekeeper of Bifröst, the rainbow road connecting Midgard, realm

Routes and Middleware for Using OAuth2 Server within a Slim Framework API

Chadicus\Slim\OAuth2 A collection of OAuth2 Server routes, middleware and utilities for use within a Slim 3 Framework API Requirements Chadicus\Slim\O

A demo application for running an OAuth2 server
A demo application for running an OAuth2 server

OAuth2 Demo PHP This application is designed to demo the workflow between OAuth2.0 Clients and Servers. If this is your first time here, try experimen

Releases(v2.0.2)
Owner
Permify
Permify is a plug-&-play authorization API that helps dev teams create granular access control and user management systems without breaking a sweat!
Permify
CakeDC Auth Objects is a refactor of the existing Auth objects present in the CakeDC Users Plugin, to let anyone else use them in their projects.

CakeDC Auth Objects is a refactor of the existing Auth objects present in the CakeDC Users Plugin, to let anyone else use them in their projects.

Cake Development Corporation 24 Sep 23, 2022
Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use

Introduction Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use. Official Documentation Documenta

The Laravel Framework 3.1k Dec 31, 2022
A PHP boilerplate based on Slim Framework, for start projects with Eloquent ORM, Validation, Auth (JWT), Repositories and Transformers ready

A PHP boilerplate based on Slim Framework, for start projects with Eloquent ORM, Validation, Auth (JWT), Repositories and Transformers ready.

Damiano Petrungaro 58 Aug 10, 2022
A Native PHP MVC With Auth. If you will build your own PHP project in MVC with router and Auth, you can clone this ready to use MVC pattern repo.

If you will build your own PHP project in MVC with router and Auth, you can clone this ready to use MVC pattern repo. Auth system is implemented. Works with bootstrap 5. Composer with autoload are implemented too for future composer require.

null 2 Jun 6, 2022
A spec compliant, secure by default PHP OAuth 2.0 Server

PHP OAuth 2.0 Server league/oauth2-server is a standards compliant implementation of an OAuth 2.0 authorization server written in PHP which makes work

The League of Extraordinary Packages 6.2k Jan 4, 2023
documentation for the oauth2-server-php library

OAuth2 Server PHP Documentation This repository hosts the documentation for the oauth2-server-php library. All submissions are welcome! To submit a ch

Brent Shaffer 227 Nov 24, 2022
Kaiju is an open source verification bot based on Discord's OAuth written in C# and PHP, with the functionality of being able to integrate the user to a new server in case yours is suspended.

What is Kaiju? Kaiju is an open source verification bot for Discord servers, based on OAuth and with permission for the server owner, to be able to mi

in the space 10 Nov 20, 2022
PHP server built using laravel framework.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Lee 0 Dec 27, 2021
phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

Apereo Foundation 780 Dec 24, 2022
The most popular PHP library for use with the Twitter OAuth REST API.

TwitterOAuth The most popular PHP library for Twitter's OAuth REST API. See documentation at https://twitteroauth.com. PHP versions listed as "active

Abraham Williams 4.2k Dec 23, 2022