-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Implement token exchange from OCM #57234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
enriquepablo
wants to merge
80
commits into
nextcloud:master
Choose a base branch
from
enriquepablo:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
c2ec5bc
feat: Bearer auth aware Sabre HTTP client
enriquepablo 345c198
feat(dav): Add token endpoint to exchange refresh tokens for access t…
enriquepablo 78f752e
feat(dav): Add Bearer auth backend for webdav requests
enriquepablo 4ca65de
feat(dav): New method doTryTokenLogin to allow to try token login wit…
enriquepablo 7e998e7
feat(federatedfilesharing): Create permanent refresh token when creat…
enriquepablo e5387f4
feat(federatedfilesharing): When a remote requests a share with a tok…
enriquepablo 1bd0dad
feat(files_sharing): When requesting a remote share with bearer auth,…
enriquepablo ed02c1f
feat: adapt to guzzle api
enriquepablo f8c13fe
feat(cloud_federation_api): adapt to new format for share creation
enriquepablo 7073b01
feat(cloud_federation_api): support multi protocol for share creation
enriquepablo 86a1bd8
fix(dav): data sent to token endpoint must be application/x-www-form-…
enriquepablo a1d4dc1
fix(dav): when receiving a share, account for the must-exchange-token…
enriquepablo 2f186bf
fix(federatedfilesharing): POSTs to token endpoint should be signed
enriquepablo f877cb3
fix(federatedfilesharing): POSTs to token endpoint MUST be signed
enriquepablo b237bc2
fix: federated share provider tests
enriquepablo a8511ab
fix: share manager test
enriquepablo f711f5a
fix(federatedfilesharing): fix federated share provider tests
enriquepablo 8d2e2ab
fix(federatedfilesharing): fixing federated share provider tests
enriquepablo beb7e9e
fix(federatedfilesharing): fixing federated share provider tests
enriquepablo 34a6149
fix: fixing code style
enriquepablo c396801
fix: fixing openapi specs
enriquepablo 095e9e5
fix: fix psalm issues
enriquepablo c61eb44
fix: reorder import
enriquepablo 0133f83
fix(dav): do not import from NCU ns
enriquepablo 18cfcfc
fix: fix sqlite integration tests
enriquepablo 6c79511
fix(federatedfilesharing): order of imports
enriquepablo f8fce1c
fix: fix session tests using Session::loginWithToken
enriquepablo b1b535d
fix: fix public key token provider test
enriquepablo e0e0df7
fix: Fixed undefined $request variable
enriquepablo ce02995
fix(files_external): Added missing doTryTokenLogin() method to implem…
enriquepablo 1f6e483
fix: Fixed parent::getType() to use ->getter('type') to avoid Psalm m…
enriquepablo f3d72ff
fix: Added getTokenEndPoint() and setTokenEndPoint() methods that sho…
enriquepablo 0a7bc64
fix: fix session tests
enriquepablo 45f4b53
fix(federatedfilesharing): remove unused import
enriquepablo d176331
fix: fix user session tests
enriquepablo ba8321b
test: test token controller
enriquepablo b6083c6
test: test doTryTokenLogin method
enriquepablo 3de9f1b
fix(dav): remove unused import in TokenController test
enriquepablo 74c276a
feat(dav): refresh expired tokens
enriquepablo 8f03056
fix(files_sharing): refactor refreshing access tokens
enriquepablo f16e356
fix(dav): keep refresh tokens in its own db table
enriquepablo 63f7dcf
fix(dav): validate token exchange response before using it
enriquepablo 891d9fa
fix(dav): keep refresh tokens in its own db table, add migration for …
enriquepablo 800f415
fix(files_sharing): keep access tokens in its own field in the extern…
enriquepablo a2b2ec3
fix(files_sharing): prevent concurrent requests to refresh token inde…
enriquepablo da9227e
fix(dav): cleanup expired access tokens
enriquepablo ec06f3c
fix(files_sharing): prevent infinite loop trying unsuccessfully to re…
enriquepablo 39b36bc
fix(files_sharing): missing autoloads
enriquepablo 9a97620
test(dav): test bearer token login
enriquepablo 820d1e8
test(dav): test cleanup of expired access tokens
enriquepablo 3326f9e
test(federatedfilesharing): test federated shares
enriquepablo 7d2cf7b
test(files_sharing): test access tokens
enriquepablo c07011e
fix(files_sharing): correct access level for appConfig
enriquepablo bd35874
fix: backwards compatibility for shares from instances before upgrading
enriquepablo 4288574
fix: backwards compatibility for shares for instances before upgrading
enriquepablo 8679743
fix: backwards compatibility for shares for instances before upgrading
enriquepablo 22e9ef8
fix: re-order imports
enriquepablo ccdf77c
fix: avoid changing the IUserSession interface
enriquepablo 2f0d28e
fix[dav]: composer autoload
enriquepablo 83fd9d0
fix[federatedfilesharing]: replace deprecated import
enriquepablo a1a53bc
chore: bump 3rdparty and update psalm baseline
mickenordin fb23f93
fix(dav): respect storage scheme when discovering token endpoint
mickenordin 89f640d
fix(auth): allow OCM access tokens via Bearer header
mickenordin f04aefb
chore: add missing `Override` attributes flagged by psalm
mickenordin b479af5
fix(dav): regenerate composer autoloader for new migration
mickenordin 9e293af
feat(JWT): Switch the access_token to a JWT
mickenordin 9918b54
feat[dav]: add bearer auth backend to dav endpoints
enriquepablo 3e3d9e5
fix[cloud_federation_api]: move access token machinery to cloud_feder…
enriquepablo aaea1f6
fix(dav): revert useless change
enriquepablo 9ac299b
fix(cloud_federation_api): pick token endpoint params in the method's…
enriquepablo 5c97992
fix(files_sahring, federatedfilesharing): rename share token to refre…
enriquepablo d7d2313
fix(files_sharing): do not log (a fragment of) the refresh token
enriquepablo a8f7519
fix: regex for token string was matching 15 - 32 instead of 15 | 32
enriquepablo 9359868
feat(federatedfilesharing): add OCMCapabilities class with OCM capabi…
enriquepablo e2b11a3
fix(dav): add types to DAV properties
enriquepablo e7ddbd6
fix(dav): better variable name for tokens
enriquepablo 60f6033
fix(dav): remove semicolon accidentally added in previous commit
enriquepablo 8080007
feat(files_sharing): make sabre http client that transparently handle…
enriquepablo 4b134de
fix(dav): cleanup of code no longer needed
enriquepablo a90d003
fix(files_sharing): the access_token field in the shares_external db …
enriquepablo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/cloud_federation_api/lib/BackgroundJob/CleanupExpiredOcmTokensJob.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\CloudFederationAPI\BackgroundJob; | ||
|
|
||
| use OCA\CloudFederationAPI\Db\OcmTokenMapMapper; | ||
| use OCP\AppFramework\Utility\ITimeFactory; | ||
| use OCP\BackgroundJob\TimedJob; | ||
|
|
||
| /** | ||
| * Periodically purge expired OCM access token mappings from ocm_token_map. | ||
| * | ||
| * The corresponding oc_authtoken entries (TEMPORARY_TOKEN with an expires | ||
| * timestamp) are cleaned up by Nextcloud's own token expiry jobs. | ||
| */ | ||
| class CleanupExpiredOcmTokensJob extends TimedJob { | ||
| public function __construct( | ||
| ITimeFactory $timeFactory, | ||
| private readonly OcmTokenMapMapper $mapper, | ||
| ) { | ||
| parent::__construct($timeFactory); | ||
|
|
||
| $this->setInterval(6 * 60 * 60); // run every 6 hours | ||
| $this->setTimeSensitivity(self::TIME_INSENSITIVE); | ||
| } | ||
|
|
||
| #[\Override] | ||
| protected function run($argument): void { | ||
| $this->mapper->deleteExpired($this->time->getTime()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to
knowwhich type of auth it is, instead of guessing, maybe with token-exchange capabilityThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The request we are receiving may be for a share that does not correspond with the remote's capabilities, for example because it is old