altelma/laravel-hydra 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

altelma/laravel-hydra

最新稳定版本:v0.0.3

Composer 安装命令:

composer require altelma/laravel-hydra

包简介

Hydra API client for Laravel

README 文档

README

Latest Version on Packagist Total Downloads

Laravel Hydra is a package that provides Client API for Hydra support Laravel and following the newest of PHP version.

Laravel Hydra Cover

What is Hydra?

Hydra is an OAuth 2.0 and OpenID Connect Provider. In other words, an implementation of the OAuth 2.0 Authorization Framework as well as the OpenID Connect Core 1.0 framework. As such, it issues OAuth 2.0 Access, Refresh, and ID Tokens that enable third-parties to access your APIs in the name of your users.

Inspiration ❤️❤️❤️

This is not the official Ory Hydra SDK for php. If you want to use the official SDK, please use the official Ory Hydra SDK

Installation

composer require altelma/laravel-hydra

Usage

Create OAuth Client

// Create OAuth Client
$adminApi = new AdminApi();
$adminApi->createOAuth2Client([
    "client_id" => "my-client-id",
    "client_name" => "My Client ID",
    "client_secret" => Str::random(32),
    "scope" => "offline offline_access openid phone email profile",
    "owner" => "Your company or your 3rd",
    "client_uri" => "https://your-company.com",
    "logo_uri" => "https://your-client-app.com/logo.png",
    "redirect_uris" => [
        "http://localhost:8000/hydra/callback",
    ],
    "grant_types" => [
        "authorization_code|refresh_token"
    ],
    "response_types" => [
        "code|id_token"
    ],
]);

Token Verification

// Example in middleware
public function __construct(private AdminApi $oauthAdminApi)
{
}

public function handle(Request $request, Closure $next)
{
    $token = $request->bearerToken();
    $tokenVerification = $this->oauthAdminApi->introspectOAuth2Token($token)->active;
    if (!$tokenVerification) {
        throw new UnauthorizedHttpException('Bearer', 'Invalid access token');
    }

    return $next($request);
}

Reference

HTTP API Documentation: https://www.ory.sh/hydra/docs/reference/api

สนับสนุนผมได้นะ ☕

สวัสดีเพื่อนๆ ทุกคนนะครับ หากมีข้อเสนอแนะอะไร แนะนำมาได้นะครับ นอกจากนี้ เพื่อนๆ สามารถแวะไปอ่านบทความของผมเพิ่มเติมได้ ที่นี่ ครับ

Bug Report

This package is not perfect right, but can be improve together. If you found bug or have any suggestion. Send that to me or new issue. Thank you to use it.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固