piotzkhider/firebase-authentication-module

1.0.0 2019-08-28 09:03 UTC

This package is auto-updated.

Last update: 2024-09-29 05:29:33 UTC


README

Scrutinizer Code Quality Code Coverage Build Status Build Status

日语

Firebase Authentication Module for BEAR.Sunday

安装

Composer安装

$ composer require piotzkhider/firebase-authentication-module

模块安装

use Piotzkhider\FirebaseAuthenticationModule\FirebaseAuthenticationModule;
class AppModule extends AbstractAppModule
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $appDir = $this->appMeta->appDir;
        require_once $appDir . '/env.php';
        ...
        $this->install(new FirebaseAuthenticationModule(getenv('GOOGLE_APPLICATION_CREDENTIALS')));
        ...
    }
}

@Authenticate

@Authenticate 是一个用于身份验证的注解。
身份验证过程在处理方法之前执行。

class Tasks extends ResourceObject
{
    /**
     * @Authenticate
     */
    public function onGet(): ResourceObject
    {

已验证用户可以直接定义为方法参数。
为此,需要在 @Authenticate 属性中指定。并且它将最后一个参数的默认参数设置为 null,类似于 @Assisted

class Tasks extends ResourceObject
{
    /**
     * @Authenticate(user="user")
     */
    public function onGet(UserRecord $user = null): ResourceObject
    {