Skip to content

Commit e81c2ad

Browse files
cbcoutinhoclaude
andcommitted
docs: Update upstream OAuth status with completed oidc app PRs [skip ci]
Update oauth-upstream-status.md to clarify patch requirements and document completed upstream work: **Clarifications:** - CORSMiddleware patch is for Nextcloud core server (not user_oidc app) - Root cause: CORS middleware logs out sessions without CSRF tokens - Solution: Allow Bearer tokens to bypass CORS/CSRF checks - Updated all references with actual PR number: nextcloud/server#55878 **Completed oidc app PRs (now documented):** - ✅ H2CK/oidc#586: User consent management (v1.11.0+) - ✅ H2CK/oidc#585: JWT tokens, introspection, scope validation (v1.10.0+) - ✅ H2CK/oidc#584: PKCE support (RFC 7636) (v1.10.0+) **Updated sections:** - "What Works Without Patches" - Added JWT, scopes, consent features - "Upstream PRs Status" - Added completed PRs table - "Monitoring Upstream Progress" - Focus on remaining work - Last updated date: 2025-11-02 All OAuth features except app-specific APIs now work out of the box with oidc app v1.10.0+. Only CORSMiddleware patch remains pending. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 2336048 commit e81c2ad

File tree

2 files changed

+85
-27
lines changed

2 files changed

+85
-27
lines changed

app-hooks/post-installation/20-apply-cors-bearer-token-patch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# authentication issues with app-specific APIs (Notes, Calendar, etc.)
77
# when using OAuth/OIDC Bearer tokens.
88
#
9-
# Upstream PR: https://github.com/nextcloud/server/pull/XXXXX
9+
# Upstream PR: https://github.com/nextcloud/server/pull/55878
1010
# Commit: 8fb5e77db82 (fix(cors): Allow Bearer token authentication)
1111
#
1212

docs/oauth-upstream-status.md

Lines changed: 84 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,79 @@ While the core OAuth flow works, there are **pending upstream improvements** tha
1616

1717
**Status**: 🟡 **Patch Required** (Pending Upstream)
1818

19-
**Affected Component**: `user_oidc` app
19+
**Affected Component**: **Nextcloud core server** (`CORSMiddleware`)
2020

2121
**Issue**: Bearer token authentication fails for app-specific APIs (Notes, Calendar, etc.) with `401 Unauthorized` errors, even though OCS APIs work correctly.
2222

23-
**Root Cause**: The `CORSMiddleware` in Nextcloud logs out sessions created by Bearer token authentication when CSRF tokens are missing, which breaks API requests.
23+
**Root Cause**: The `CORSMiddleware` in Nextcloud core server logs out sessions when CSRF tokens are missing. Bearer token authentication creates a session (via `user_oidc` app), but doesn't include CSRF tokens (stateless authentication). The middleware detects the logged-in session without CSRF token and calls `session->logout()`, invalidating the request.
2424

25-
**Solution**: Set the `app_api` session flag during Bearer token authentication to bypass CSRF checks.
25+
**Solution**: Allow Bearer token requests to bypass CORS/CSRF checks in `CORSMiddleware`, since Bearer tokens are stateless and don't require CSRF protection.
2626

27-
**Upstream PR**: [nextcloud/user_oidc#1221](https://github.com/nextcloud/user_oidc/issues/1221)
27+
**Upstream PR**: [nextcloud/server#55878](https://github.com/nextcloud/server/pull/55878)
2828

29-
**Workaround**: Manually apply the patch to `lib/User/Backend.php` in the `user_oidc` app
29+
**Workaround**: Manually apply the patch to `lib/private/AppFramework/Middleware/Security/CORSMiddleware.php` in Nextcloud core server
3030

3131
**Impact**:
3232
-**Works**: OCS APIs (`/ocs/v2.php/cloud/capabilities`)
3333
-**Requires Patch**: App APIs (`/apps/notes/api/`, `/apps/calendar/`, etc.)
3434

35-
**Files Modified**: `lib/User/Backend.php` in `user_oidc` app
35+
**Files Modified**: `lib/private/AppFramework/Middleware/Security/CORSMiddleware.php` in **Nextcloud core server**
3636

3737
**Patch Summary**:
3838
```php
39-
// Add before successful Bearer token authentication returns
40-
$this->session->set('app_api', true);
39+
// Allow Bearer token authentication for CORS requests
40+
// Bearer tokens are stateless and don't require CSRF protection
41+
$authorizationHeader = $this->request->getHeader('Authorization');
42+
if (!empty($authorizationHeader) && str_starts_with($authorizationHeader, 'Bearer ')) {
43+
return;
44+
}
4145
```
4246

43-
This is added at lines ~243, ~310, ~315, and ~337 in `Backend.php`.
47+
This is added before the CSRF check at line ~73 in `CORSMiddleware.php`.
48+
49+
---
50+
51+
### 2. JWT Token Support, Introspection, and Scope Validation
52+
53+
**Status**: ✅ **Complete** (Merged Upstream)
54+
55+
**Affected Component**: `oidc` app
56+
57+
**Issue**: The OIDC app needed support for JWT tokens, token introspection, and enhanced scope validation for fine-grained authorization.
58+
59+
**Resolution**: Complete JWT and scope validation support has been implemented and merged:
60+
61+
**Upstream PR**: [H2CK/oidc#585](https://github.com/H2CK/oidc/pull/585) - ✅ **Merged**
62+
- **Changes**:
63+
- JWT token generation and validation
64+
- Token introspection endpoint (RFC 7662)
65+
- Enhanced scope validation and parsing
66+
- Custom scope support for Nextcloud apps
67+
- **Status**: Merged and available in v1.10.0+ of the `oidc` app
68+
69+
---
70+
71+
### 3. User Consent Management
72+
73+
**Status**: ✅ **Complete** (Merged Upstream)
74+
75+
**Affected Component**: `oidc` app
76+
77+
**Issue**: The OIDC app needed proper user consent management for OAuth authorization flows.
78+
79+
**Resolution**: Complete user consent management has been implemented and merged:
80+
81+
**Upstream PR**: [H2CK/oidc#586](https://github.com/H2CK/oidc/pull/586) - ✅ **Merged**
82+
- **Changes**:
83+
- User consent UI for OAuth authorization
84+
- Consent expiration and cleanup
85+
- Admin control for user consent settings
86+
- Consent tracking and management
87+
- **Status**: Merged and available in v1.11.0+ of the `oidc` app
4488

4589
---
4690

47-
### 2. PKCE Support (RFC 7636)
91+
### 4. PKCE Support (RFC 7636)
4892

4993
**Status**: ✅ **Complete** (Merged Upstream)
5094

@@ -97,24 +141,34 @@ This is added at lines ~243, ~310, ~315, and ~337 in `Backend.php`.
97141

98142
| PR/Issue | Component | Status | Priority | Notes |
99143
|----------|-----------|--------|----------|-------|
100-
| [user_oidc#1221](https://github.com/nextcloud/user_oidc/issues/1221) | `user_oidc` | 🟡 Open | High | Required for app-specific APIs |
101-
| [H2CK/oidc#584](https://github.com/H2CK/oidc/pull/584) | `oidc` | ✅ Merged | ~~Medium~~ | ✅ PKCE advertisement complete (v1.10.0+) |
144+
| [server#55878](https://github.com/nextcloud/server/pull/55878) | Nextcloud core server | 🟡 Open | High | CORSMiddleware patch for Bearer tokens |
145+
| [H2CK/oidc#586](https://github.com/H2CK/oidc/pull/586) | `oidc` | ✅ Merged | Medium | ✅ User consent complete (v1.11.0+) |
146+
| [H2CK/oidc#585](https://github.com/H2CK/oidc/pull/585) | `oidc` | ✅ Merged | Medium | ✅ JWT tokens, introspection, scope validation (v1.10.0+) |
147+
| [H2CK/oidc#584](https://github.com/H2CK/oidc/pull/584) | `oidc` | ✅ Merged | ~~High~~ | ✅ PKCE support (RFC 7636) (v1.10.0+) |
102148

103149
## What Works Without Patches
104150

105151
The following functionality works **out of the box** without any patches:
106152

107-
**OAuth Flow**:
108-
- OIDC discovery with full PKCE support (requires `oidc` app v1.10.0+)
153+
**OAuth Flow** (requires `oidc` app v1.10.0+):
154+
- OIDC discovery with full PKCE support (RFC 7636)
109155
- Dynamic client registration
110156
- Authorization code flow with PKCE (S256 and plain methods)
111157
- Token exchange with code_verifier verification
158+
- User consent management
112159
- Userinfo endpoint
113160

161+
**Token Features** (requires `oidc` app v1.10.0+):
162+
- JWT token generation and validation
163+
- Token introspection endpoint (RFC 7662)
164+
- Enhanced scope validation and parsing
165+
- Custom scope support for Nextcloud apps
166+
114167
**MCP Server as Resource Server**:
115168
- Token validation via userinfo
116169
- Per-user client instances
117170
- Token caching
171+
- Scope-based authorization
118172

119173
**Nextcloud OCS APIs**:
120174
- Capabilities endpoint
@@ -124,7 +178,7 @@ The following functionality works **out of the box** without any patches:
124178

125179
The following functionality requires upstream patches:
126180

127-
🟡 **App-Specific APIs** (Requires user_oidc#1221):
181+
🟡 **App-Specific APIs** (Requires Nextcloud core server CORSMiddleware patch):
128182
- Notes API (`/apps/notes/api/`)
129183
- Calendar API (CalDAV)
130184
- Contacts API (CardDAV)
@@ -198,19 +252,23 @@ uv run pytest tests/client/test_oauth_playwright.py --browser firefox -v
198252

199253
## Monitoring Upstream Progress
200254

201-
To track progress on these issues:
255+
To track progress on remaining issues:
202256

203-
1. **Watch the upstream repositories**:
204-
- [nextcloud/user_oidc](https://github.com/nextcloud/user_oidc)
205-
- [nextcloud/oidc](https://github.com/nextcloud/oidc)
257+
1. **Watch the upstream repository**:
258+
- [nextcloud/server](https://github.com/nextcloud/server)
206259

207-
2. **Subscribe to specific issues**:
208-
- [user_oidc#1221](https://github.com/nextcloud/user_oidc/issues/1221) - Bearer token support
260+
2. **Subscribe to the CORSMiddleware PR**:
261+
- [server#55878](https://github.com/nextcloud/server/pull/55878) - CORSMiddleware Bearer token support
209262

210-
3. **Check Nextcloud release notes** for mentions of:
263+
3. **Check Nextcloud server release notes** for mentions of:
211264
- Bearer token authentication improvements
212-
- OIDC/OAuth enhancements
213-
- AppAPI compatibility
265+
- CORS middleware enhancements
266+
- OAuth/OIDC API compatibility
267+
268+
4. **Completed upstream work** (no monitoring needed):
269+
-[H2CK/oidc#584](https://github.com/H2CK/oidc/pull/584) - PKCE support (v1.10.0+)
270+
-[H2CK/oidc#585](https://github.com/H2CK/oidc/pull/585) - JWT, introspection, scopes (v1.10.0+)
271+
-[H2CK/oidc#586](https://github.com/H2CK/oidc/pull/586) - User consent (v1.11.0+)
214272

215273
## Contributing
216274

@@ -237,6 +295,6 @@ Want to help get these patches merged?
237295

238296
---
239297

240-
**Last Updated**: 2025-10-20
298+
**Last Updated**: 2025-11-02
241299

242-
**Next Review**: When issue #1221 (Bearer token support) has activity
300+
**Next Review**: When Nextcloud server CORSMiddleware PR has activity

0 commit comments

Comments
 (0)