Skip to content

fix(oauth2): adjust db schemas when migrating from owncloud - #50193

Merged
AndyScherzinger merged 1 commit into
masterfrom
fix/oauth2/owncloud-migration
Feb 5, 2025
Merged

fix(oauth2): adjust db schemas when migrating from owncloud#50193
AndyScherzinger merged 1 commit into
masterfrom
fix/oauth2/owncloud-migration

Conversation

@st3iny

@st3inyst3iny commented Jan 15, 2025

Copy link
Copy Markdown
Member

Summary

See also #49075

This PR fixes two issues:

  1. Not being able to create or auth using OAuth2 clients after migrating from ownCloud.
  2. Not being able to refresh legacy tokens from ownCloud after migrating to Nextcloud.

It does not aim to migrate legacy access tokens from ownCloud as this incurs a lot of work and tokens are only valid for an hour. So, it does not make sense as the migration window set by admins is probably longer than their lifetime anyway.

What I tested

  1. Install ownCloud (latest) and install/enable the oauth2 app.
  2. Add an oauth2 client, use it to generate an access token and refresh it at least once.
  3. Dump related tables: mysqldump owncloud oc_oauth2_access_tokens oc_oauth2_refresh_tokens oc_oauth2_clients
  4. Import dumped tables into Nextcloud.
  5. Reset all oauth2 migrations and drop oauth2 tables (oc_oauth2_access_tokens, oc_oauth2_refresh_tokens and oc_oauth2_clients).
  6. Import dumped tables.
  7. Migrate oauth2 and run repair steps: occ migrations:migrate oauth2 && occ maintenance:repair
  8. Refresh the token generated in step 2 using your oauth2 client (might be necessary to adjust the token URL if Nextcloud is on another domain).
  9. Observe that the refreshed access token can still be used to log into Nextcloud.

TODO

  • Needs to be tested with a live ownCloud instance (see above)

Checklist

Comment threadlib/private/Repair/Owncloud/MigrateOauthTables.php Outdated
@st3iny
st3iny marked this pull request as ready for review January 16, 2025 10:51
@st3inyst3iny added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jan 16, 2025
Comment threadlib/private/Repair.php Outdated

@ChristophWurstChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far

Comment threadlib/private/Repair/Owncloud/MigrateOauthTables.php
@st3iny

Copy link
Copy Markdown
MemberAuthor

/backport! to stable29

@AndyScherzinger
AndyScherzingerforce-pushed the fix/oauth2/owncloud-migration branch from 91c93e1 to 0fc1f08CompareFebruary 5, 2025 17:34
@AndyScherzinger

Copy link
Copy Markdown
Member

/backport to stable30

@AndyScherzinger

Copy link
Copy Markdown
Member

/backport to stable31

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
@st3iny
st3inyforce-pushed the fix/oauth2/owncloud-migration branch from 0fc1f08 to 754a047CompareFebruary 5, 2025 20:56
@st3iny

Copy link
Copy Markdown
MemberAuthor

/backport to stable29

Let's recreate the backport as it was incomplete.

@st3inyst3iny added this to the Nextcloud 32 milestone Feb 5, 2025
@st3inyst3iny added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Feb 5, 2025
\OC::$server->getConfig()
),
new MigrateOauthTables(\OC::$server->get(Connection::class)),
\OC::$server->get(MigrateOauthTables::class),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\OC::$server->get(MigrateOauthTables::class),
\OCP\Server::get(MigrateOauthTables::class),

Next time 😉

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to releaseReady to be released and/or waiting for tests to finishbugfeature: authenticationfeature: owncloud migration

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[Bug]: The schema of oc_oauth2_access_tokens is not adjusted properly and its data is not migrated correctly when migrating from ownCloud

5 participants

@st3iny@AndyScherzinger@nickvergessen@ChristophWurst@skjnldsv