亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專欄INFORMATION COLUMN

Laravel 5 API 服務(wù)端支持簽名授權(quán)認(rèn)證

xioqua / 799人閱讀

摘要:服務(wù)端支持簽名授權(quán)認(rèn)證項(xiàng)目地址關(guān)于

Laravel 5 API 服務(wù)端支持簽名授權(quán)認(rèn)證

Github 項(xiàng)目地址: https://github.com/HavenShen/larsign

Api Authorized Signature Middleware for Laravel 5 關(guān)于

The larsign package authorized signature server.

Features

Handles larsign requests

Installation

Require the havenshen/larsign package in your composer.json and update your dependencies:

$ composer require havenshen/larsign

Add the HavenShenLarsignLarsignServiceProvider to your config/app.php providers array:

HavenShenLarsignLarsignServiceProvider::class,

Add the HavenShenLarsignLarsignFacade to your config/app.php aliases array:

"Larsign" => HavenShenLarsignLarsignFacade::class,
Global usage

To allow Larsign for all your routes, add the HandleLarsign middleware in the $middleware property of app/Http/Kernel.php class:

protected $middleware = [
    // ...
    HavenShenLarsignHandleLarsign::class,
];
Group middleware

If you want to allow Larsign on a specific middleware group or route, add the HandleLarsign middleware to your group:

protected $middlewareGroups = [
    "web" => [
       // ...
    ],

    "api" => [
        // ...
        HavenShenLarsignHandleLarsign::class,
    ],
];
Application route middleware

If you want to allow Larsign on a specific application middleware or route, add the HandleLarsign middleware to your application route:

protected $routeMiddleware = [
    // ...
    "auth.larsign" => HavenShenLarsignHandleLarsign::class,
];
Configuration

The defaults are set in config/larsign.php. Copy this file to your own config directory to modify the values. You can publish the config using this command:

$ php artisan vendor:publish --provider="HavenShenLarsignLarsignServiceProvider"
return [
    /*
     |--------------------------------------------------------------------------
     | Larsign
     |--------------------------------------------------------------------------
     |
     */
    "headerName" => env("LARSIGN_HEADER_NAME", "Larsign"),
    "accessKey" => env("LARSIGN_ACCESS_KEY", ""),
    "secretKey" => env("LARSIGN_SECRET_KEY", ""),
];

Add api route in routes/api.php Copy this.

Route::middleware(["auth.larsign"])->group(function () {
    Route::get("/larsign", function () {
    return [
        "message" => "done."
    ]);
});

or

Route::get("/larsign", function () {
    return [
        "message" => "done."
    ];
})->middleware("auth.larsign");
Client

Generate Larsign signatures

Assume the following management credentials:

AccessKey = "test"
SecretKey = "123456"

Call interface address:

url = "https://larsign.dev/api/v1/test?page=1"

The original string to be signed:

note: the time-stamping followed by a newline [currenttime + voucher valid seconds]

signingStr = "/api/v1/test?page=1
1510986405"

Base64 url safe encode:

signingStrBase64UrlSafeEncode = "L2FwaS92MS90ZXN0P3BhZ2U9MQoxNTEwOTg2NDY1"

hmac_sha1 carries SecretKey encryption then base64 url safe encode:

sign = "MLKnFIdI-0TOQ4mHn5TyCcmWACU="

The final administrative credentials are:

note: stitching headerName Space AccessKey:sign:signingStrBase64UrlSafeEncode

larsignToken = "Larsign test:MLKnFIdI-0TOQ4mHn5TyCcmWACU=:L2FwaS92MS90ZXN0P3BhZ2U9MQoxNTEwOTg2NDY1"

Add http header:

note: header key in config/larsign.php -> headerName

Larsign:Larsign test:MLKnFIdI-0TOQ4mHn5TyCcmWACU=:L2FwaS92MS90ZXN0P3BhZ2U9MQoxNTEwOTg2NDY1
Client signature authorization failed
Http Response: 403
Testing
$ phpunit
License

The MIT License (MIT). Please see License File for more information.

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/26195.html

相關(guān)文章

  • HTTP API 設(shè)計(jì)入坑指南(二)

    摘要:而只需要服務(wù)端生成,客戶端保存,每次請(qǐng)求在頭部中使用攜帶,服務(wù)端認(rèn)證解析就可。如果緩存不清理,驗(yàn)證碼就會(huì)一直有效,不安全。 一、授權(quán) 參考文獻(xiàn):https://blog.risingstack.com/... 1. Basic authentication (最簡單,適用于沒有第三方的請(qǐng)求接口中) 客戶端發(fā)送authorization,內(nèi)容為 Basic Base64編碼(usern...

    JayChen 評(píng)論0 收藏0
  • HTTP API 設(shè)計(jì)入坑指南(二)

    摘要:而只需要服務(wù)端生成,客戶端保存,每次請(qǐng)求在頭部中使用攜帶,服務(wù)端認(rèn)證解析就可。如果緩存不清理,驗(yàn)證碼就會(huì)一直有效,不安全。 一、授權(quán) 參考文獻(xiàn):https://blog.risingstack.com/... 1. Basic authentication (最簡單,適用于沒有第三方的請(qǐng)求接口中) 客戶端發(fā)送authorization,內(nèi)容為 Basic Base64編碼(usern...

    pingan8787 評(píng)論0 收藏0
  • Laravel Passport里的授權(quán)類型介紹

    摘要:模糊授權(quán),跟上面的認(rèn)證碼授權(quán)類似,不同的是,我們的資源服務(wù)器,返回的直接就是準(zhǔn)入令牌,而不是認(rèn)證碼。 本文來自pilishen.com----原文鏈接; 歡迎來和pilishen一起學(xué)習(xí)php&Laravel;學(xué)習(xí)群:109256050 OAuth2是一個(gè)安全框架,控制著程序受保護(hù)部分的準(zhǔn)入,主要是控制不同的客戶端如何來調(diào)取API,保證它們?cè)谡?qǐng)求相應(yīng)資源的時(shí)候有相應(yīng)的權(quán)限。 Larav...

    RobinTang 評(píng)論0 收藏0
  • JWT、OAuth 2.0、session 用戶授權(quán)實(shí)戰(zhàn)

    摘要:為用戶提供授權(quán)以允許用戶操作非公開資源,有很多種方式。具體的代碼根據(jù)不同的授權(quán)方案而有所不同。使用授權(quán)原理利用來驗(yàn)證用戶,有兩種機(jī)制實(shí)現(xiàn)。使用來實(shí)現(xiàn)用戶授權(quán)主要用于簽發(fā)如果有將異步的簽名。注意這里的與之前用于簽發(fā)的應(yīng)該是同一個(gè)。 在很多應(yīng)用中,我們都需要向服務(wù)端提供自己的身份憑證來獲得訪問一些非公開資源的授權(quán)。比如在一個(gè)博客平臺(tái),我們要修改自己的博客,那么服務(wù)端要求我們能夠證明 我是...

    Jochen 評(píng)論0 收藏0
  • 淺析微信支付:微信支付簡單介紹(小程序、公眾號(hào)、App、H5

    摘要:本文是淺析微信支付系列文章的第二篇,主要講解一下普通商戶接入的支付方式以及其中的不同之處。淺析微信支付前篇大綱微信支付是集成在微信客戶端的支付功能,用戶可以通過手機(jī)完成快速的支付流程。目前微信支付支持手機(jī)系統(tǒng)有蘋果安卓和。 本文是【淺析微信支付】系列文章的第二篇,主要講解一下普通商戶接入的支付方式以及其中的不同之處。 上篇文章講了本系列的大綱,沒有看過的朋友們可以看一下。 淺析微信支...

    shadowbook 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<