Skip to content
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

Make oauth2 client secret column larger #38770

Merged
merged 3 commits into from
Jun 14, 2023

Conversation

julien-nc
Copy link
Member

@julien-nc julien-nc commented Jun 12, 2023

refs #38398 (comment)

This also adds a simple test inserting a client with a long secret.

@kesselb Any idea how much chars we can expect at most by giving a 64 chars to https://github.com/nextcloud/server/blob/master/lib/private/Security/Crypto.php#L93 ?

$client->setRedirectUri('https://example.com/');
$client->setSecret('b81dc8e2dc178817bf28ca7b37265aa96559ca02e6dcdeb74b42221d096ed5ef63681e836ae0ba1077b5fb5e6c2fa7748c78463f66fe0110c8dcb8dd7eb0305b16d0cd993e2ae275879994a2abf88c68|e466d9befa6b0102341458e45ecd551a|013af9e277374483123437f180a3b0371a411ad4f34c451547909769181a7d7cc191f0f5c2de78376d124dd7751b8c9660aabdd913f5e071fc6b819ba2e3d919|3');
$this->clientMapper->insert($client);
}
Copy link
Member

Choose a reason for hiding this comment

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

forgot a addToAssertCount(1) or assertTrue(true). I think phpunit will warn that the test doesn't assert anything

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Done.

Copy link
Member

Choose a reason for hiding this comment

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

$this->

@ChristophWurst
Copy link
Member

nit: reorder your commits and push the test only. we should see failing CI. Then you push the fix and we should see green ci.

@@ -49,7 +49,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table = $schema->getTable('oauth2_clients');
if ($table->hasColumn('secret')) {
$column = $table->getColumn('secret');
$column->setLength(256);
$column->setLength(512);
Copy link
Member

Choose a reason for hiding this comment

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

Changing migrations later on feels iffy

Copy link
Member Author

Choose a reason for hiding this comment

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

@rullzer Not sure what to do here.

If we keep Version011601Date20230522143227 with 256 and add a step that just changes the column length we don't prevent problems when the existing secrets will be encrypted and the update will fail because we try to store values that are too long.

We could:

  • change the value in Version011601Date20230522143227 so that people who never ran it have the correct column length before encrypting the existing values
  • add a step that changes the column length to 512 again for people who already ran the previous step successfully

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I see the trouble
But you need indeed another one for people that did already run the migration

@julien-nc julien-nc force-pushed the fix/38398/oauth-encrypted-secret-length branch 3 times, most recently from 0179d34 to 372d271 Compare June 14, 2023 08:23
@julien-nc
Copy link
Member Author

nit: reorder your commits and push the test only. we should see failing CI. Then you push the fix and we should see green ci.

Test only: running.

@julien-nc
Copy link
Member Author

julien-nc commented Jun 14, 2023

@julien-nc julien-nc force-pushed the fix/38398/oauth-encrypted-secret-length branch 2 times, most recently from 864a35e to ed56f2f Compare June 14, 2023 11:25
@julien-nc
Copy link
Member Author

And tests are passing now.

@rullzer So the length has been changed in the previous migration and a new step that changes the length has also been added. This way we make sure:

  • people who already ran the Version011601Date20230522143227 step will have the size changed by the new step (this can only happen by using a git working copy of server)
  • people who didn't run Version011601Date20230522143227 will have the correct column size before encrypting existing values

…evious step has run when it was setting it to 256

Signed-off-by: Julien Veyssier <[email protected]>
@julien-nc julien-nc force-pushed the fix/38398/oauth-encrypted-secret-length branch from ed56f2f to 578bf8c Compare June 14, 2023 15:21
@julien-nc julien-nc merged commit 8c7e2cd into master Jun 14, 2023
@julien-nc julien-nc deleted the fix/38398/oauth-encrypted-secret-length branch June 14, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants