serafim/railt-authorization

此包已被废弃,不再维护。未建议替代包。

Railt授权扩展,适用于Laravel框架

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

This package is auto-updated.

Last update: 2020-09-07 06:52:13 UTC


README

您的应用程序应使用 Laravel Provider

安装

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

使用方法

已认证用户

包含指令 @auth 的字段仅对已认证用户可用。

type Example {
    field: Result! @auth
}

访客

包含指令 @guest 的字段仅对访客(非认证用户)可用。

type Example {
    field: Result! @guest
}

授权

包含指令 @can(role: String!)

  1. 仅对已认证用户可用。
  2. 应通过在 role 参数中定义的授权网关。
type Example {
    field: Result! @can(role: "some")
}