承接 udarajay/dunbar 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

udarajay/dunbar

Composer 安装命令:

composer require udarajay/dunbar

包简介

Easy to use proxy for your Laravel APIs

README 文档

README

Dunbar

Easy to use (thin) proxy for your Laravel APIs.

Latest Stable Version Total Downloads License

If you're consuming your Laravel API from any public client, like a single-page web app or a mobile/desktop app, chances are you're going to have to store the client-secret credentials somewhere in there. It's super easy for anyone to inspect you code and grab your secure tokens.

Using a 'thin' (server-side) proxy is the fastest way to secure your client APIs; simply put, this poxy will sit between your frontend clients and backend apis. Where you would normally make an authentication call to the API with a client-id and client-secret like so:

POST /auth HTTP/1.1
Host: api.example.com

grant_type=password
&client_id=webapp
&client_secret=a-secret-code-no-one-should-see
&username=admin
&password=password

You'd now be making the same API call to the proxy endpoint, in our case example.com/dunbar, minus the client-secret. The proxy will take the request, add the client-secret and forward the request to your backend API.

The server would normally respond with the access tokens and refresh tokens like so:

{
    "access_token": "Jcncdj32CXdsdiUYtxnt6H8vCjndiCbdsu",
    "refresh_token": "83JCd97cdkalc53nB2DHJui3d83NcdicS",
    "token_type": "Bearer",
    "expires": 1535645629
}

But with our thin proxy, it'll simply create an encrypted cookie that only the proxy can decrypt.

Now, for all future call to the API:

GET /ajax/resource/123 HTTP/1.1
Cookie: <encrypted cookie with tokens>
Host: example.com

The proxy will decrypt the cookie, add the Authorization header to the request and forward it on to the API like so:

GET /resource/some-protected-resource HTTP/1.1
Authorization: Bearer the-access-token-form-the-cookie
Host: api.example.com

The responses will be passed directly back to the browser or app exactly like you define in your API.

So what exactly does this "thin" proxy do?

Simply put, the proxy lets you hard code the client-secret credentials into this thin server-side component (proxy) that you can trust. It authenticates your client APIs for you and returns an encrypted cookie with the user credentials (eg. access token) that only the proxy can decrypt. All you need to do to access protected resources after you've authenticated via the proxy is to pass this cookie with all your calls.

What more?

Teh further secure your API, you can lock it down to only accept requests from the proxy. Additionally you can also roll your client-secret on a schedule or anytime you need to without having to update any front-end clients.

Installation

  1. Install Dunbar via composer
composer require udarajay/dunbar
  1. Publish the configuration
php artisan vendor:publish
  1. Edit the file app/config/dunbar.php to suit your needs. Primarily you can edit it to change the name of the cookie and the proxy endpoint.

You may also need to regenrate your route and config cache on Laravel using php artisan config:clear and php artisan route:cache.

Usage

The package will automatically register a proxy endpoint (default being yourdomain.com/dunbar). Make all your API calls to the proxy endpoint like so to authenticate:

POST dunbar/example.com/oauth/token HTTP/1.1
Host: example.com

&grant_type=password
&client_id=webapp
&username=admin
&password=mypassword

And requests to all protected resources like so:

POST dunbar/example.com/protected_resource HTTP/1.1
Host: example.com

If the access_token expires and you have got a refresh_token, Dunbar will call the OAuth server for you and refresh the access_token with a new one and update the cookie.

Features

  • Dead-simple proxy for securing your Laravel API. Works seamlessly with Passport or the League OAuth2 server that is maintained by Andy Millington and Simon Hamp.
  • [ Upcoming] Interact with database (Passport defaults first), to access client secrets directly from the OAuth provider.
  • [ Upcoming] Auto-roll client secrets on a schedule.

Questions?

Create an issue and tag it with question. I'll try to help & answer best I can.

Contribute?

Please do :) Just create a PR.

License

This package is released under the MIT License.

udarajay/dunbar 适用场景与选型建议

udarajay/dunbar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 96 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 10 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「oauth」 「proxy」 「laravel」 「passport」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 udarajay/dunbar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 udarajay/dunbar 我们能提供哪些服务?
定制开发 / 二次开发

基于 udarajay/dunbar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-30