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

Fix refresh token issue #9

Merged
merged 5 commits into from
Jun 21, 2022

Conversation

manojmalik20
Copy link
Contributor

Summary

Chimera didn't contain the functionality to refresh the OAuth token. This PR adds that functionality.

Related Links

mattermost/mattermost-plugin-gitlab#298
mattermost/mattermost-plugin-gitlab#298 (comment)

Added some validation while fetching grant type and refresh token from the request
Added the ability to refresh the token based on the grant type
@DHaussermann
Copy link

Hi @Szymongib

  1. Are you able to provide review on this? I'm not sure if there is someone else who may own this.
  2. Do you have any idea on how this may be testable and who could help? Perhaps a change could be deployed only to the test.mattermost.cloud servers first? (I have no visibility into how this gets deployed and who does it)

@Szymongib
Copy link
Contributor

Hey @DHaussermann,
Yes, I will have a look.

Copy link
Contributor

@Szymongib Szymongib left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, looks good. I think we should add a unit test for the new case.

internal/api/handler_test.go Outdated Show resolved Hide resolved
internal/api/handler.go Show resolved Hide resolved
Copy link
Contributor

@Szymongib Szymongib left a comment

Choose a reason for hiding this comment

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

Thanks, @manojmalik20! Looks good!

@Szymongib
Copy link
Contributor

@DHaussermann I am going to merge it and deploy it to the Test environment, after that you should be able to test with test.mattermost.cloud servers.

@Szymongib Szymongib merged commit e6a5814 into mattermost:main Jun 21, 2022
@manojmalik20 manojmalik20 deleted the fix_refresh_token_issue branch June 21, 2022 13:15
@DHaussermann
Copy link

@manojmalik20 I have tested this and I don't see the issue resolved.

I spun up a server with /cloud and still see the issue. I opened a new issue here. #10

cc @Szymongib unless I've misunderstood something - the change is being deployed when I spin up a cloud server now. Please advise.

@Szymongib
Copy link
Contributor

@DHaussermann just to make sure, you tested this with modified version of plugin from mattermost/mattermost-plugin-gitlab#298 right?

@DHaussermann
Copy link

@Szymongib I did not test with that specific PR branch but I tested with the v1.4.1 release https://github.com/mattermost/mattermost-plugin-gitlab/releases/tag/v1.4.1 which contains the same fix.

@Szymongib
Copy link
Contributor

@DHaussermann could you share plugin logs? Does it error in any way?

@DHaussermann
Copy link

Hi @Szymongib
yes, sorry I forgot to post the logs.

{"timestamp":"2022-07-08 17:12:47.749 Z","level":"debug","msg":"Using Chimera Proxy OAuth configuration","caller":"app/plugin_api.go:934","plugin_id":"com.github.manland.mattermost-plugin-gitlab"}
{"timestamp":"2022-07-08 17:12:47.758 Z","level":"debug","msg":"Using Chimera Proxy OAuth configuration","caller":"app/plugin_api.go:934","plugin_id":"com.github.manland.mattermost-plugin-gitlab"}
{"timestamp":"2022-07-08 17:12:47.826 Z","level":"debug","msg":"Received HTTP request","caller":"web/handlers.go:156","method":"POST","url":"/api/v4/channels/members/me/view","request_id":"sbzqsxso97n6dqq7yzc5qafqxw","status_code":"200"}
{"timestamp":"2022-07-08 17:12:47.920 Z","level":"debug","msg":"Received HTTP request","caller":"web/handlers.go:156","method":"GET","url":"/api/v4/channels/88hq7ex5iff338yzh8nmjgey7c/posts","request_id":"a36sparu93d3jxgi7fqkf8b3ya","status_code":"200"}
{"timestamp":"2022-07-08 17:12:47.939 Z","level":"error","msg":"can't list merge-request where author in GitLab API","caller":"app/plugin_api.go:940","plugin_id":"com.github.manland.mattermost-plugin-gitlab","err":"GET https://gitlab.com/api/v4/merge_requests: 401 {error: invalid_token}, {error_description: Token is expired. You can either do re-authorization or token refresh.}"}
{"timestamp":"2022-07-08 17:12:47.952 Z","level":"error","msg":"unable to list unreads in GitLab API","caller":"app/plugin_api.go:940","plugin_id":"com.github.manland.mattermost-plugin-gitlab","err":"can't list todo in GitLab api: GET https://gitlab.com/api/v4/todos: 401 {error: invalid_token}, {error_description: Token is expired. You can either do re-authorization or token refresh.}"}
{"timestamp":"2022-07-08 17:12:48.478 Z","level":"debug","msg":"Received HTTP request","caller":"web/handlers.go:156","method":"GET","url":"/api/v4/system/ping","request_id":"uop8nkeei7yyuj5qbgwcfq78or","status_code":"200"}
{"timestamp":"2022-07-08 17:12:48.478 Z","level":"debug","msg":"Received HTTP request","caller":"web/handlers.go:156","method":"GET","url":"/api/v4/system/ping","request_id":"3mracsun4pdpfn9k3ushx5npze","status_code":"200"}
{"timestamp":"2022-07-08 17:12:50.634 Z","level":"debug","msg":"Received HTTP request","caller":"web/handlers.go:156","method":"POST","url":"/api/v4/channels/members/me/view","request_id":"hqedhygnxjngfbzag856q68z6c","status_code":"200"}
{"timestamp":"2022-07-08 17:12:53.478 Z","level":"debug","msg":"Received HTTP request","caller":"web/handlers.go:156","method":"GET","url":"/api/v4/system/ping","request_id":"d84z6eretig19cbzmr6ocq47jc","status_code":"200"}
{"timestamp":"2022-07-08 17:12:54.618 Z","level":"debug","msg":"2022/07/08 17:12:54 [DEBUG] memberlist: Stream connection from=100.127.88.78:35616\n","caller":"cluster/log_parser.go:64","source":"memberlist"}
{"timestamp":"2022-07-08 17:12:54.618 Z","level":"debug","msg":"Received HTTP request","caller":"web/handlers.go:156","method":"GET","url":"/api/v4/analytics/old","request_id":"o8xtqm7npj8xjjsmn9fdnu1xsy","status_code":"200"}
{"timestamp":"2022-07-08 17:12:54.689 Z","level":"debug","msg":"Received HTTP request","caller":"web/handlers.go:156","method":"GET","url":"/api/v4/trial-license/prev","request_id":"zz3354d8wjfbfgzizubzqs5b6r","status_code":"200"}
{"timestamp":"2022-07-08 17:12:55.419 Z","level":"debug","msg":"2022/07/08 17:12:55 [DEBUG] memberlist: Stream connection from=100.127.88.78:35618\n","caller":"cluster/log_parser.go:64","source":"memberlist"}

I will post this on #10 so we have all the info and discussion in i place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants