kodepandai / lunox

Laravel-Flavoured Nodejs Framework
https://lunox.js.org
MIT License
77 stars 8 forks source link

[lunox-core] Need Gate and Policy feature for Advance Authorization #37

Open axmad386 opened 1 year ago

axmad386 commented 1 year ago

In laravel, we can use gate and policy to handle authorization. See https://laravel.com/docs/10.x/authorization#introduction But maybe we can start from simple version

Also we need AuthServiceProvider can register policies like this

import Post from "../app/Models/Post";
import {ServiceProvider} from "@lunoxjs/core";
class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     */
    protected policies: [Class<any>,typeof Policy][]= [
        [Post, PostPolicy], // are we can do this in typescript?
    ];

    /**
     * Register any application authentication / authorization services.
     */
    public function boot(): void
    {
        // ...
    }
}