定制 michalsn/codeigniter-passage 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

michalsn/codeigniter-passage

最新稳定版本:v1.0.0

Composer 安装命令:

composer require michalsn/codeigniter-passage

包简介

Passage integration for the CodeIgniter 4 framework

README 文档

README

Basic integration for Passage - passwordless authentication powered by passkeys.

PHPUnit PHPStan Deptrac

PHP CodeIgniter

Installation

Composer

composer require michalsn/codeigniter-passage

Manually

In the example below we will assume, that files from this project will be located in app/ThirdParty/passage directory.

Download this project and then enable it by editing the app/Config/Autoload.php file and adding the Michalsn\CodeIgniterPassage namespace to the $psr4 array, like in the below example:

<?php

namespace Config;

use CodeIgniter\Config\AutoloadConfig;

class Autoload extends AutoloadConfig
{
    // ...
    public $psr4 = [
        APP_NAMESPACE => APPPATH, // For custom app namespace
        'Config'      => APPPATH . 'Config',
        'Michalsn\CodeIgniterPassage' => APPPATH . 'ThirdParty/passage/src',
    ];

    // ...

Also add the required helper to the same file under $files array:

    // ...
    public $files = [
        APPPATH . 'ThirdParty/passage/src/Common.php',
    ];

    // ...

Configuration

  • Follow the quickstart
  • Create an app in the Passage Console
    • php spark passage:publish - to copy config file to the App namespace
    • Fill the config variables or use .env file
  • Add a Passage Element to your frontend
  • You can use passageStateless filter as your middleware implementation

Helper functions

  • passageAppId() will return your AppId
  • passageId() will return your user id (if you're using passageStateless filter), you can also set this yourself via: passageId($userId)

Example

<?php

namespace App\Controllers;

use Michalsn\CodeIgniterPassage\Exceptions\PassageException;

class Home extends BaseController
{
    public function index()
    {
        try {
            $passage = service('passage');
            $userId = $passage->authenticateRequest($this->request);
            $data = ['user' => $passage->user->get($userId)];
        } catch (PassageException $e) {
            return $this->response->setHeader(401)->setBody('401 Unauthorized');
        }

        return view('home/index', $data);
    }
}

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-23