-
Notifications
You must be signed in to change notification settings - Fork 58
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
[GH-84] Add the concept of plugin admins #93
[GH-84] Add the concept of plugin admins #93
Conversation
@@ -77,34 +89,61 @@ func (p *Plugin) SaveLinks(links []autolink.Autolink) error { | |||
return nil | |||
} | |||
|
|||
func (p *Plugin) UpdateConfig(f func(conf *Config)) Config { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value was never used.
@@ -55,6 +57,259 @@ func TestPlugin(t *testing.T) { | |||
assert.Equal(t, "Welcome to [Mattermost](https://mattermost.com)!", rpost.Message) | |||
} | |||
|
|||
type SuiteAuthorization struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the liberty of not being consistent with other tests in this file, as using testing suite approach IMO is cleaner and we are already using testing suites in e.g. mattermost-server
repo.
74f6058
to
0149686
Compare
@crspeller Done, ready for another pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, @vespian! I really appreciate the additional tests and descriptive nature of your discussion. I've only a few nit-picking suggestions to address before approving
aaf42da
to
bb32075
Compare
@jfrerich Done, changes in commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, @vespian!
@vespian I pinged them on the community server. Sorry for the delay! |
Sorry for the delay on this @vespian , thanks for your contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, LGTM @vespian
Sorry @vespian is this a general addition for "Admins" on "Plugins" or just for the Autolink plugin? Just want to make sure I'm understanding correctly. If we have a general purpose "Admin Users" for plugins....we need to think this through a bit more. It likely would need to be limited to Enterprise Edition licences (ie: Only EE licenced MM servers would have a centralized plce for admins of plugins). |
@aaronrothschild This is only for autolink plugin :) |
@vespian I'm seeing an odd bug here. The list of authorized user is clearing itself out and it seem related maybe to when the functionality is used to change autolink settings. It seems like it only works once for a non-admin user and then the list empties. Steps:
Can you please see if you can also repro this? Please reach out if there is anymore clarification or details I can provide. |
@DHaussermann Thanks a lot for checking my work, and a detailed bug report! I will take a closer look into it during the weekend, maybe earlier but no promises. |
Codecov Report
@@ Coverage Diff @@
## master #93 +/- ##
==========================================
+ Coverage 36.43% 40.28% +3.85%
==========================================
Files 6 6
Lines 538 561 +23
==========================================
+ Hits 196 226 +30
+ Misses 320 313 -7
Partials 22 22
Continue to review full report at Codecov.
|
Co-Authored-By: Jason Frerich <[email protected]>
8991513
to
daefa31
Compare
@DHaussermann Fixed in commit daefa31 Let me know if you find anything more. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vespian for this fix! This is now working as expected.
- Tested that designated plugin admin could use slash commands including those that modify data
- Ensured previously found issue was resolved
- No other issues found
LGTM!
Added test for this to release testing.
…ost-community#93) * Add the concept of plugin admins * Review fixes mattermost-community#1 Co-Authored-By: Jason Frerich <[email protected]> * Review fixes mattermost-community#2 Co-authored-by: Jason Frerich <[email protected]>
Summary
This plugin adds the concept of plugin admin users. A new plugin configuratoin option was added which lists comma-separated usernames for which modifying the configuration of the plugin is allowed (no auto-compleate, see [3]). Please see below for the sample config window:
and sample interaction with the plugin as a user who first did not have admin privileges, and then was granted ones:
While working on this change I have also changed how the
Config
is handled/passed around. In Go, function arguments are passed by value [1], so if. e.g. the underlying array of theConfig.Links
changed (i.e. new entries were added, causing reallocation), the other copies would be still using the old underlying array which could lead to weird errors. Also, based on the plugin template[2], the thread-safety seems to be guaranteed by passing around the reference to the plugin's config, so that if one goroutine updates the config, the other still has the consistent view on the old configuration as it is holding the old reference. Happy to discuss!Do we still need
EnableAdminCommand
config option in this plugin, now that we have plugin administrators? Do we want to allow also adding userIds in the new field?[1] https://stackoverflow.com/a/47486724
[2] https://github.com/mattermost/mattermost-plugin-starter-template/blob/282a8cf227849a25e306caff11597a0e4ba4cd01/server/configuration.go
[3] #84 (comment)
Ticket Link
Fixes
mattermost/mattermost#84Fixes #84 (jfrerich 2/28/20)