euroglas/authkey

用于EUROGLAS的基于密钥的认证模块

1.0.0 2021-02-26 19:17 UTC

This package is auto-updated.

Last update: 2024-09-27 03:34:45 UTC


README

EUROGLAS服务器的部分

使用预共享密钥进行客户端认证

文件

eurorest
├───src
│   └───authkey.php
├───.gitignore
├───composer.json
├───index.php
├───iniciaServidorDePruebas.php
├───servidor.ini
├───LICENSE
└───README.md

源代码目录 src

包含实现该模块的文件,扩展了基类 auth(实现了接口 authInterfacerestModuleInterface

class authkey extends \euroglas\eurorest\auth

根目录

包含模块的测试文件。

配置

令牌

对于服务器,我们正在使用JSON Web Token(JWT)。为了使用它,需要两个步骤

  1. 交换凭据(密钥)以获得一个令牌。
    1. 向服务器发送请求,包括所需的凭据
    2. 服务器验证凭据,如果有效,则返回一个TOKEN
    3. 如果凭据无效,则返回错误
  2. 需要令牌的所有调用都必须包含它
    HTTP头: Authorization
    格式: Bearer <token>(注意:大小写敏感)

URL

在EUROGLAS REST服务器中使用authkey模块

  • 在开发环境中安装composer
  • 为您的项目创建一个目录
  • 将基本模块(eurorest)添加到您的项目中
composer require euroglas/eurorest
  • 添加此模块
composer require euroglas/authkey
  • 或者,编辑 composer.json 文件以包含要求
        {
            "require": {
                "euroglas/eurorest": "^1.0.0",
                "euroglas/authkey": "^1.0.0"
            }
        }
  • 执行composer以安装依赖关系(这将生成 composer.lock 文件和 vendor 目录)
php composer.phar install

如果您想使用composer的类自动加载器,请将以下内容包含到您的php脚本(index.php)中

require 'vendor/autoload.php';

注意 如果您想了解更多关于REST服务器的信息,请参阅模块 euroglas/eurorest 的信息