punktde/oauth2-server

Neos Flow 框架的 OAuth 2.0 服务器

安装数: 3,717

依赖项: 0

建议者: 0

安全性: 0

星标: 4

关注者: 6

分支: 5

开放问题: 0

类型:neos-package

3.0.1 2022-05-04 14:33 UTC

This package is auto-updated.

Last update: 2024-09-04 19:28:20 UTC


README

Travis Build Status Latest Stable Version Total Downloads

Flow 包提供基于 The PHP League OAuth Server 的 OAuth 2.0 服务器。

设置

安装

使用 composer 进行安装

composer require punktde/oauth2-server

运行 doctrine 迁移

./flow doctrine:migrate

可选:定义路由位置

Routes are per default included without any position parameter. If routes are positioned wrong adjust the position accordig to the [Flow Route documentation](https://flowframework.readthedocs.io/en/stable/TheDefinitiveGuide/PartIII/Routing.html#subroutes-from-settings)

配置

在设置中启用所需的授权类型

PunktDe:
  OAuth2:
    Server:
      grantTypes:
        client_credentials:
          enabled: false
        authorization_code:
          enabled: false

查看 Settings.PunktDe.yaml 获取更多配置值。

生成服务器密钥

./flow oauthserver:generateserverkeys

创建客户端凭据

./flow oauthserver:createclientcredentials <identifier> <name> <grant-type>

实现授权

thephpleague.com 上有所有 OAuth2 授权类型的良好列表,这应该有助于您找到适合您应用程序的类型。

以下 OAuth 2.0 授权类型已实现

客户端凭据授权

如果您授权一台机器访问资源且不需要用户权限来访问这些资源,则应实现客户端凭据授权。

授权码授权

如果客户端是一个具有服务器端组件的 Web 应用程序,则应实现授权码授权。

要使用的 URL 为

  • 访问令牌 URL: <YourDomain>/oauth/token
  • 授权 URL: <YourDomain>/oauth/authorize
  • 授权批准 URL: oauth/approveauthorization

当前授权码授权使用请求应用程序的隐式授权。

在授权过程中验证用户

如果没有经过身份验证的 Flow 账户调用 /oauth/authorize,则用户将被自动重定向到可配置的 URL。身份验证后,用户应被转发到 /oauth/approveauthorization 以批准之前启动的授权会话。

自定义授权请求批准

身份验证请求批准可以扩展以满足您项目的需求。您可以将自定义逻辑放入实现 ApprovalStrategyInterface 的类中。