serafim/railt-authorization

Railt authorization extension for Laravel Framework

dev-master 2018-03-15 02:13 UTC

README

Your application should use the Laravel Provider

Installation

  • composer require serafim/railt-authorization
  • Add into config/railt.php:
    ...
    'extensions' => [
        \Serafim\RailtAuthorization\AuthorizationExtension::class, 
    ]

Usage

Authenticated

The field that contains the directive @auth is only available to an authenticated user.

type Example {
    field: Result! @auth
}

Guest

The field that contains the directive @guest is only available to a guest (non-authenticated user).

type Example {
    field: Result! @guest
}

Authorization

The field that contains the directive @can(role: String!):

  1. Is only available to an authenticated user.
  2. Should pass the authorization gate defined in role argument.
type Example {
    field: Result! @can(role: "some")
}