Use Mattermost as Oauth provider #11346

Open
opened 2025-11-02 09:34:57 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @flamevip on GitHub (Jul 27, 2023).

Feature Description

I found that the oauth2 authentication source gitea and mattermost's oauth2 are very similar. Through my practice, I registered the oauth2 application for gitea in my existing mattermost and docked with gitea. An expected error occurred

The reason for this error is that the type of the returned user information id field is inconsistent, gitea is int, and mattermost is string. Can I add an oauth2 provider for mattermost to be compatible with the user interface of mattermost, or can I change the relevant id field? type to handle this error

Related Links:
https://docs.gitea.com/development/oauth2-provider#examples
https://developers.mattermost.com/integrate/apps/authentication/oauth2/

2023/07/26 03:39:50 ...rs/web/auth/oauth.go:939:SignInOAuthCallback() [E] UserSignIn: json: cannot unmarshal string into Go struct field .id of type int 2023/07/26 03:39:50 ...eb/routing/logger.go:102:func1() [I] router: completed GET /user/oauth2/test/callback?code=95qz4xfw3iypdewnmqqt6g1ctaynom4w3ru3fxjgqgo3r4my1m3r&state=a8b4a59f-4d4d-44fb-a9e6-37810c81d26b for 172.104.84.32:29686, 500 Internal Server Error in 2353.8ms @ auth/oauth.go:888(auth.SignInOAuthCallback) 2023/07/26 03:40:13 ...rs/web/auth/oauth.go:939:SignInOAuthCallback() [E] UserSignIn: could not find a matching session for this request 2023/07/26 03:40:13 ...eb/routing/logger.go:102:func1() [I] router: completed GET /user/oauth2/test/callback?code=95qz4xfw3iypdewnmqqt6g1ctaynom4w3ru3fxjgqgo3r4my1m3r&state=a8b4a59f-4d4d-44fb-a9e6-37810c81d26b for 172.104.84.32:29734, 500 Internal Server Error in 4.0ms @ auth/oauth.go:888(auth.SignInOAuthCallback)
gitea.com/api/v1/user
The returned content is as follows

{ "id": 2, "login": "test123", "login_name": "", "full_name": "", "email": "test123@test.com", "avatar_url": "http://127.0.0.1:3000/avatar/14f93380e5b0602cebc91ddda86fcbd0", "language": "zh-CN", "is_admin": false, "last_login": "2023-07-26T18:16:02Z", "created": "2023-07-26T18:16:02Z", "restricted": false, "active": true, "prohibit_login": false, "location": "", "website": "", "description": "", "visibility": "public", "followers_count": 0, "following_count": 0, "starred_repos_count": 0, "username": "test123" }

mattermost.com/api/v4/users/me
The returned content is as follows

{"id":"ozfz3ge3qpybzri4n7d5c1k3ya","create_at":1683517619664,"update_at":1690433537229,"delete_at":0,"username":"flame","auth_data":"","auth_service":"","email":"test@test.com","email_verified":true,"nickname":"","first_name":"","last_name":"","position":"","roles":"system_admin system_user","props":{"last_search_pointer":"4"},"notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","desktop_threads":"all","email":"false","email_threads":"all","first_name":"false","mention_keys":"","push":"all","push_status":"away","push_threads":"all"},"last_password_update":1683517930044,"last_picture_update":1683528181237,"locale":"zh-CN","timezone":{"automaticTimezone":"Asia/Shanghai","manualTimezone":"","useAutomaticTimezone":"true"},"disable_welcome_email":false}

Screenshots

20230727141847

Originally created by @flamevip on GitHub (Jul 27, 2023). ### Feature Description I found that the oauth2 authentication source gitea and mattermost's oauth2 are very similar. Through my practice, I registered the oauth2 application for gitea in my existing mattermost and docked with gitea. An expected error occurred The reason for this error is that the type of the returned user information id field is inconsistent, gitea is int, and mattermost is string. Can I add an oauth2 provider for mattermost to be compatible with the user interface of mattermost, or can I change the relevant id field? type to handle this error Related Links: https://docs.gitea.com/development/oauth2-provider#examples https://developers.mattermost.com/integrate/apps/authentication/oauth2/ `2023/07/26 03:39:50 ...rs/web/auth/oauth.go:939:SignInOAuthCallback() [E] UserSignIn: json: cannot unmarshal string into Go struct field .id of type int 2023/07/26 03:39:50 ...eb/routing/logger.go:102:func1() [I] router: completed GET /user/oauth2/test/callback?code=95qz4xfw3iypdewnmqqt6g1ctaynom4w3ru3fxjgqgo3r4my1m3r&state=a8b4a59f-4d4d-44fb-a9e6-37810c81d26b for 172.104.84.32:29686, 500 Internal Server Error in 2353.8ms @ auth/oauth.go:888(auth.SignInOAuthCallback) 2023/07/26 03:40:13 ...rs/web/auth/oauth.go:939:SignInOAuthCallback() [E] UserSignIn: could not find a matching session for this request 2023/07/26 03:40:13 ...eb/routing/logger.go:102:func1() [I] router: completed GET /user/oauth2/test/callback?code=95qz4xfw3iypdewnmqqt6g1ctaynom4w3ru3fxjgqgo3r4my1m3r&state=a8b4a59f-4d4d-44fb-a9e6-37810c81d26b for 172.104.84.32:29734, 500 Internal Server Error in 4.0ms @ auth/oauth.go:888(auth.SignInOAuthCallback)` gitea.com/api/v1/user The returned content is as follows `{ "id": 2, "login": "test123", "login_name": "", "full_name": "", "email": "test123@test.com", "avatar_url": "http://127.0.0.1:3000/avatar/14f93380e5b0602cebc91ddda86fcbd0", "language": "zh-CN", "is_admin": false, "last_login": "2023-07-26T18:16:02Z", "created": "2023-07-26T18:16:02Z", "restricted": false, "active": true, "prohibit_login": false, "location": "", "website": "", "description": "", "visibility": "public", "followers_count": 0, "following_count": 0, "starred_repos_count": 0, "username": "test123" }` mattermost.com/api/v4/users/me The returned content is as follows `{"id":"ozfz3ge3qpybzri4n7d5c1k3ya","create_at":1683517619664,"update_at":1690433537229,"delete_at":0,"username":"flame","auth_data":"","auth_service":"","email":"test@test.com","email_verified":true,"nickname":"","first_name":"","last_name":"","position":"","roles":"system_admin system_user","props":{"last_search_pointer":"4"},"notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","desktop_threads":"all","email":"false","email_threads":"all","first_name":"false","mention_keys":"","push":"all","push_status":"away","push_threads":"all"},"last_password_update":1683517930044,"last_picture_update":1683528181237,"locale":"zh-CN","timezone":{"automaticTimezone":"Asia/Shanghai","manualTimezone":"","useAutomaticTimezone":"true"},"disable_welcome_email":false}` ### Screenshots ![20230727141847](https://github.com/go-gitea/gitea/assets/41901255/040a7cdb-3076-4330-92b0-6a4e1dac3d6e)
GiteaMirror added the type/proposal label 2025-11-02 09:34:57 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11346