nextagencyio/graphql_oauth_fix
Composer 安装命令:
composer require nextagencyio/graphql_oauth_fix
包简介
Fixes OAuth integration with GraphQL in Drupal 11 by providing OAuth-aware access checks for GraphQL requests.
README 文档
README
Overview
This custom module fixes OAuth integration with GraphQL in Drupal 11 by providing OAuth-aware access checks for GraphQL requests. It addresses the integration issue between Simple OAuth 6.0 and GraphQL where OAuth bearer token authentication doesn't properly establish user context for GraphQL access checks.
Problem Description
In Drupal 11 with Simple OAuth 6.0 and GraphQL Compose, OAuth bearer token authentication works correctly (tokens are generated and validated), but the GraphQL access check system doesn't recognize the authenticated user context. This results in OAuth-authenticated requests being treated as anonymous requests, causing "permission required" errors even when valid bearer tokens are provided.
Solution
This module provides:
-
OAuthAuthenticationSubscriber: An event subscriber that detects GraphQL requests with OAuth bearer tokens and stores the authenticated user context in request attributes.
-
OAuthAwareQueryAccessCheck: A custom access check service that overrides the default GraphQL query access check to properly handle OAuth-authenticated users by:
- Checking the current user service for authenticated users
- Looking for OAuth authentication flags in request attributes
- Using the OAuth-authenticated account for permission checks
Technical Details
Event Subscriber
- Runs on
KernelEvents::REQUESTwith priority 10 - Detects GraphQL requests by checking path patterns and request attributes
- Stores OAuth authentication context in request attributes
Access Check Override
- Replaces
access_check.graphql.queryservice viagraphql_oauth_fix.services.yml - Implements the same permission logic as the original GraphQL access check
- Adds OAuth-awareness by checking multiple sources for authenticated user context
Configuration
No additional configuration is required. The module automatically:
- Detects GraphQL requests
- Processes OAuth bearer tokens
- Applies proper permission checks
Status
✅ Implemented: OAuth-aware GraphQL access checks ✅ Working: GraphQL permission system recognizes OAuth authentication ⚠️ Pending: Simple OAuth 6.0 scope configuration requires additional setup
Known Issue: Simple OAuth 6.0 Scope Requirements
Simple OAuth 6.0 requires scope parameters even when scopes are disabled in configuration. This is a separate OAuth server configuration issue, not related to the GraphQL integration fix provided by this module.
Workaround: Configure appropriate OAuth scopes or use alternative OAuth flow.
Usage
Once enabled, OAuth-authenticated GraphQL requests will work correctly:
# Generate OAuth token curl -X POST \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&scope=basic" \ http://your-site.com/oauth/token # Use token for GraphQL requests curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d '{"query":"{ route(path: \"/\") { ... on NodeLanding { title } } }"}' \ http://your-site.com/graphql
Dependencies
graphql:graphqlsimple_oauth:simple_oauth
Author
Created for DrupalX project to resolve OAuth + GraphQL integration issues in Drupal 11.
nextagencyio/graphql_oauth_fix 适用场景与选型建议
nextagencyio/graphql_oauth_fix 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Authentication」 「oauth」 「drupal」 「graphql」 「drupal-11」 「simple-oauth」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nextagencyio/graphql_oauth_fix 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nextagencyio/graphql_oauth_fix 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nextagencyio/graphql_oauth_fix 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
WeChat OAuth SDK
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
Ory-Hydra OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Library for ORCID web services
Provides an add-on purchasable entity.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-06-23