Skip to content

Refactored the code and added flow manager for Oauth setup#125

Merged
raghavaggarwal2308 merged 12 commits intooauth_epicfrom
flow_setup
Mar 12, 2025
Merged

Refactored the code and added flow manager for Oauth setup#125
raghavaggarwal2308 merged 12 commits intooauth_epicfrom
flow_setup

Conversation

@Kshitij-Katiyar
Copy link
Copy Markdown
Contributor

@Kshitij-Katiyar Kshitij-Katiyar commented Jan 16, 2025

Summary

  • Added flow manager for Oauth Setup
  • Refactored the code and moved code needed for the flow manager to the main package
  • Updated plugin configuration to store Oauth configurations
  • Added functions to test Confluence base URL

Screenshots

Screenshot from 2025-01-16 18-45-10
Screenshot from 2025-01-16 18-45-18
Screenshot from 2025-01-16 18-45-58
Screenshot from 2025-01-16 18-46-09
Screenshot from 2025-01-16 18-46-17
Screenshot from 2025-01-16 18-46-26

For confluence server version < 9

Screenshot from 2025-01-16 18-46-45

For confluence server version > 9

Screenshot from 2025-01-16 18-47-36
Screenshot from 2025-01-16 18-47-53
Screenshot from 2025-01-16 18-48-00
Screenshot from 2025-01-16 19-08-57
Screenshot from 2025-01-16 19-04-32

@Kshitij-Katiyar Kshitij-Katiyar added the 2: Dev Review Requires review by a core committer label Jan 16, 2025
@Kshitij-Katiyar Kshitij-Katiyar self-assigned this Jan 16, 2025
@Kshitij-Katiyar Kshitij-Katiyar changed the base branch from master to oauth_epic January 16, 2025 14:07
Copy link
Copy Markdown
Contributor

@fmartingr fmartingr left a comment

Choose a reason for hiding this comment

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

Did a first pass. As a global question, is there a reason the controller package files where moved to the main server package?

@Kshitij-Katiyar
Copy link
Copy Markdown
Contributor Author

Did a first pass. As a global question, is there a reason the controller package files where moved to the main server package?

@fmartingr Yes, the controller functions were to be used in the flow manager and related files but importing controller into the main was causing the import cycle

@fmartingr fmartingr requested review from BenCookie95 and removed request for wiggin77 February 25, 2025 16:59
@davidkrauser
Copy link
Copy Markdown

Hi @Kshitij-Katiyar, I'm new jumping in here and trying to understand context 👋. The PRs from #125 - #129 have summaries that describe a bit of what changed, but I'd love a bit more detail if possible. Would you mind expanding the descriptions on all of the PRs in that range to include the rationale behind why each change is necessary, and a bit more context on why you chose the proposed solutions?

Apologies as I know that most of this has probably been discussed before elsewhere, but it would be very helpful for me when reviewing these changes to have the context plainly outlined here 🙂

A few examples on this PR:

  • Why did the code need to be refactored? What was the goal of that refactoring?
  • Why did you add an oauth manager? What are it's responsibilities?
  • This adds new external dependencies - why are they needed?
  • This adds telemetry, but that's not specified in the description. What is that for?

@fmartingr fmartingr requested review from davidkrauser and removed request for BenCookie95 February 27, 2025 16:24
@Kshitij-Katiyar
Copy link
Copy Markdown
Contributor Author

Kshitij-Katiyar commented Feb 28, 2025

Hi @Kshitij-Katiyar, I'm new jumping in here and trying to understand context 👋. The PRs from #125 - #129 have summaries that describe a bit of what changed, but I'd love a bit more detail if possible. Would you mind expanding the descriptions on all of the PRs in that range to include the rationale behind why each change is necessary, and a bit more context on why you chose the proposed solutions?

Apologies as I know that most of this has probably been discussed before elsewhere, but it would be very helpful for me when reviewing these changes to have the context plainly outlined here 🙂

A few examples on this PR:

  • Why did the code need to be refactored? What was the goal of that refactoring?
  • Why did you add an oauth manager? What are it's responsibilities?
  • This adds new external dependencies - why are they needed?
  • This adds telemetry, but that's not specified in the description. What is that for?

Hey @davidkrauser, here is the initial conversation messages. https://hub.mattermost.com/partners/pl/8ezhsep5nbb1fd9w9ayim48bbo
https://hub.mattermost.com/partners/pl/pnqqofskn7bp9pkwpeiteo3mmy

To summarize, the existing flow of the Confluence plugin is:

  • installing and configuring the Confluence plugin on your MM
  • Downloading an OBR file from the plugin config
  • Uploading the OBR file to your confluence admin settings.

No OAuth/Login was required to get the notifications for the Confluence event on your MM.

A user raised an issue that the Plugin stopped working for him after he Upgraded his Confluence version to 9 and above.
We tried fixing the issue for the OBR file setup for Confluence version 9 but could not do so.
So we came up with the solution of adding Oauth flow and basic Webhook setup.

Telemetry is added to most of the plugins maintained by Mattermost like Jira etc so added it here too.

Let me know if we need to update the PR description on each on of them

@davidkrauser
Copy link
Copy Markdown

@Kshitij-Katiyar wrote:

So we came up with the solution of adding Oauth flow and basic Webhook setup.

Thank you for the additional context and background on the issue. That's useful 👍

I would like to see this sort of thing added to your open PR descriptions. It helps reviewers jump in and understand what they're reviewing. With this information, they won't need to ask as many questions, and the information can be useful to look back on when we want to understand why a change was made.

Additionally, I would like to see details added to the description that explain why your solution is implemented in the way that it is. I understand what you're trying to achieve, but the rationale behind each specific code change in this PR is not readily apparent. An outline of that rationale would answer questions like I posted above (and provide context for questions I didn't even think to ask!):

Why did the code need to be refactored? What was the goal of that refactoring?
Why did you add an oauth manager? What are it's responsibilities?
This adds new external dependencies - why are they needed?
This adds telemetry, but that's not specified in the description. What is that for?

This would also help us avoid questions like these that Felipe asked above:

As a global question, is there a reason the controller package files where moved to the main server package? #125 (review)

Why was it added in this PR instead of working with telemetry in a separate PR? #125 (comment)

You are the expert on this code change, so details explaining why you made the specific code changes you made are enormously valuable. Not only that, it will enable us to give you better feedback on your changes. 🙂

@Kshitij-Katiyar
Copy link
Copy Markdown
Contributor Author

@davidkrauser Sure, implemented your suggestions for PR descriptions.

@raghavaggarwal2308 raghavaggarwal2308 merged commit a28d27e into oauth_epic Mar 12, 2025
3 checks passed
@raghavaggarwal2308 raghavaggarwal2308 deleted the flow_setup branch March 12, 2025 17:00
Kshitij-Katiyar added a commit that referenced this pull request Mar 20, 2025
… than 9 (#134)

* Refactored the code and added flow manager for Oauth setup (#125)

* refactored the code and added flow manager

* removed unused code

* fixed lint

* removed unwanted code and added mutliple status code handling

* fixed lint

* fixed step title

* removed extra lines in flow instructions

* review fixes

* fixed lint

* review fixes

* removed unused code

* fixed go mod enteries

* Added Oauth setup and connect disconnect command (#126)

* refactored the code and added flow manager

* removed unused code

* fixed lint

* added oauth setup and connect disconnect command

* removed unrelated changes from package lock

* fixed lint

* fixed missing go mod entry

* removed unwanted code and added mutliple status code handling

* fixed lint

* fixed step title

* removed unwanted variables

* removed extra lines in flow instructions

* updated flow messages

* review fixes

* fixed callJSONwithURL call

* review fixes

* fixed lint

* fixed lint

* Added support for notification with server version greater than 9 (#127)

* Added support for notification with server version > 9

* fixed disconnect error

* fixed lint issues

* refactored code and added constants

* fixed lint

* review fixes and removed unused codes

* fixed lint

* moved types out of functions

* review fixes

* review fixes

* fixed lint

* review fixes

* removed unused code

* review fixes

* review fixes

* removed unused code

* fixed go mod enteries

* removed external css sheet

* review fixes

* Added support for generic notification when user is not connected (#128)

* refactored the code and added flow manager

* removed unused code

* fixed lint

* added oauth setup and connect disconnect command

* removed unrelated changes from package lock

* fixed lint

* fixed missing go mod entry

* Added support for notification with server version > 9

* fixed disconnect error

* fixed lint issues

* removed unwanted code and added mutliple status code handling

* fixed lint

* fixed step title

* removed unwanted variables

* refactored code and added constants

* fixed lint

* added support for generic notification when user not connected

* fixed lint

* removed extra lines in flow instructions

* updated flow messages

* review fixes and removed unused codes

* fixed lint

* moved types out of functions

* add more log information

* fixed log info

* review fixes

* review fixes

* review fixes

* fixed callJSONwithURL call

* review fixes

* fixed lint

* fixed lint

* fixed lint

* Added support for notification with server version greater than 9 (#127)

* Added support for notification with server version > 9

* fixed disconnect error

* fixed lint issues

* refactored code and added constants

* fixed lint

* review fixes and removed unused codes

* fixed lint

* moved types out of functions

* review fixes

* review fixes

* fixed lint

* review fixes

* removed unused code

* fixed missing var

* review fixes

* review fixes

* review fixes

* removed unused code

* fixed go mod enteries

* removed external css sheet

* review fixes

* Added support for using admin API token for webhook notifications (#129)

* refactored the code and added flow manager

* removed unused code

* fixed lint

* added oauth setup and connect disconnect command

* removed unrelated changes from package lock

* fixed lint

* fixed missing go mod entry

* Added support for notification with server version > 9

* fixed disconnect error

* fixed lint issues

* removed unwanted code and added mutliple status code handling

* fixed lint

* fixed step title

* removed unwanted variables

* refactored code and added constants

* fixed lint

* added support for generic notification when user not connected

* fixed lint

* added support for admin api token

* removed unused code

* fixed lint

* fixed import issues

* removed extra lines in flow instructions

* saved server version in plugin config

* updated flow messages

* review fixes and removed unused codes

* fixed lint

* moved types out of functions

* add more log information

* fixed log info

* removed unwanted code and improved logs

* fixed type in config descriptions

* updated config descriptions

* review fixes

* review fixes

* review fixes

* fixed callJSONwithURL call

* review fixes

* fixed lint

* fixed lint

* fixed lint

* removed unused variables

* Added support for notification with server version greater than 9 (#127)

* Added support for notification with server version > 9

* fixed disconnect error

* fixed lint issues

* refactored code and added constants

* fixed lint

* review fixes and removed unused codes

* fixed lint

* moved types out of functions

* review fixes

* review fixes

* fixed lint

* review fixes

* removed unused code

* review fixes

* fixed missing var

* added comment to notification logic

* review fixes

* review fixes

* review fixes

* fixed lint

* review fixes

* removed unused code

* fixed go mod enteries

* replaced marshalling with byte conversion

* removed external css sheet

* review fixes

* Update server/confluence_cloud.go log info

Co-authored-by: Raghav Aggarwal <raghav.aggarwal@brightscout.com>

* removed unused vars

---------

Co-authored-by: Raghav Aggarwal <raghav.aggarwal@brightscout.com>

* Removed encryption for admin API token (#133)

* refactored the code and added flow manager

* removed unused code

* fixed lint

* added oauth setup and connect disconnect command

* removed unrelated changes from package lock

* fixed lint

* fixed missing go mod entry

* Added support for notification with server version > 9

* fixed disconnect error

* fixed lint issues

* removed unwanted code and added mutliple status code handling

* fixed lint

* fixed step title

* removed unwanted variables

* refactored code and added constants

* fixed lint

* added support for generic notification when user not connected

* fixed lint

* added support for admin api token

* removed unused code

* fixed lint

* fixed import issues

* removed extra lines in flow instructions

* saved server version in plugin config

* updated flow messages

* review fixes and removed unused codes

* fixed lint

* moved types out of functions

* add more log information

* fixed log info

* removed unwanted code and improved logs

* fixed type in config descriptions

* updated config descriptions

* review fixes

* review fixes

* review fixes

* fixed callJSONwithURL call

* review fixes

* fixed lint

* fixed lint

* fixed lint

* removed unused variables

* Added support for notification with server version greater than 9 (#127)

* Added support for notification with server version > 9

* fixed disconnect error

* fixed lint issues

* refactored code and added constants

* fixed lint

* review fixes and removed unused codes

* fixed lint

* moved types out of functions

* review fixes

* review fixes

* fixed lint

* review fixes

* removed unused code

* review fixes

* fixed missing var

* added comment to notification logic

* review fixes

* review fixes

* review fixes

* fixed lint

* review fixes

* removed unused code

* fixed go mod enteries

* replaced marshalling with byte conversion

* removed external css sheet

* review fixes

* Update server/confluence_cloud.go log info

Co-authored-by: Raghav Aggarwal <raghav.aggarwal@brightscout.com>

* removed encryption for admin api token

* improved help text for encryption key

* removed unused var in plugin struct

---------

Co-authored-by: Raghav Aggarwal <raghav.aggarwal@brightscout.com>

* fix issues reported by QA

* Fixed lint and testcases

* fixed import orders

* fixed issue of system admin required for API call

* removed unused vars

* updated the system admin check for webapp based slash command

* updated message for system admin commands

* updated msg for non admin user running confluence commands for server version < 9

---------

Co-authored-by: Raghav Aggarwal <raghav.aggarwal@brightscout.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: Dev Review Requires review by a core committer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants