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

Error Data too long when authenticating via Gitea OAuth #516

Closed
gytisrepecka opened this issue Nov 28, 2021 · 8 comments · Fixed by #618
Closed

Error Data too long when authenticating via Gitea OAuth #516

gytisrepecka opened this issue Nov 28, 2021 · 8 comments · Fixed by #618
Labels
Milestone

Comments

@gytisrepecka
Copy link
Contributor

Describe the bug

Following error is returned when loggin in via Gitea:

{"error":"Error 1406: Data too long for column 'access_token' at row 1"}

Steps to reproduce

Steps to reproduce the behavior:

  1. Attempt to login to WriteFreely via Gitea OAuth;
  2. When redirected from Gitea back to WriteFreely above error is displayed.

Expected behavior

Should successfully login.

Application configuration

  • Single mode or Multi-user mode? Multi-user
  • Database? [mysql/sqlite] MySQL
  • Open registration? [yes/no] No
  • Federation enabled? [yes/no] Yes

Version or last commit: v0.13.1

@gytisrepecka
Copy link
Contributor Author

Problem originates from table oauth_users structure:

CREATE TABLE `oauth_users` (
  `user_id` int(11) NOT NULL,
  `remote_user_id` varchar(128) NOT NULL,
  `provider` varchar(24) NOT NULL DEFAULT '',
  `client_id` varchar(128) NOT NULL DEFAULT '',
  `access_token` varchar(512) NOT NULL DEFAULT '',
  UNIQUE KEY `oauth_users_uk` (`user_id`,`provider`,`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Notice access_token is defined as varchar(512). While testing OAuth with Gitea server v1.15.3 returned token is longer - 858 positions, therefore need to extend target column.

This query fixes the problem:

ALTER TABLE `oauth_users`
MODIFY `access_token`
varchar(1024);

What would be the best way to include this statement into migrations?

@thebaer thebaer added the bug label Dec 3, 2021
@thebaer
Copy link
Member

thebaer commented Dec 3, 2021

Thanks for reporting this, @gytisrepecka! To add this migration, you can follow the example of this commit: 5de4d20

@gytisrepecka
Copy link
Contributor Author

gytisrepecka commented Dec 3, 2021

Thanks, I will create a Pull Request.

Or shall I perhaps use wf_db abstraction layer like this migration does?

@decentral1se
Copy link

Thanks for raising this, ran into it too integrating with Keycloak! Good to see a fix coming down the tubes ❤️

@p00rt
Copy link

p00rt commented Dec 6, 2021

@gytisrepecka if you're creating a PR, could you make the column 2048 chars long? Keycloak gives very long auth tokens (>1300 bytes). Thanks!

@gytisrepecka
Copy link
Contributor Author

@gytisrepecka if you're creating a PR, could you make the column 2048 chars long? Keycloak gives very long auth tokens (>1300 bytes). Thanks!

Since it's varchar, I don't see a problem. Will try it out and create a Pull Request 👍

@Tealk
Copy link

Tealk commented Feb 26, 2023

With authentik there is also the problem, there I had to increase the size to 2048

@thebaer
Copy link
Member

thebaer commented Jul 8, 2023

This should be fixed with #618, which will be in the next release.

@thebaer thebaer added this to the 0.14 milestone Jul 8, 2023
@thebaer thebaer linked a pull request Jul 8, 2023 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

5 participants