-
Notifications
You must be signed in to change notification settings - Fork 84
Support plugin only request during plugin initialization #221
Conversation
@ben181231, thanks for your PR! By analyzing the annotation information on this pull request, we identified @rickmak to be a potential reviewer |
ee8c871
to
219787e
Compare
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 isFormPlugin() should only have effect if there is present of master_key
. Not either one present.
skyerr.PluginUnavailable, | ||
"plugins are unavailable at the moment", | ||
) | ||
return http.StatusServiceUnavailable |
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 think a test case for this preprocessor is needed as it become more complicated.
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.
Agree.
return http.StatusOK | ||
|
||
if p.PluginContext.IsInitialized() { | ||
if !payload.HasMasterKey() || !payload.IsFromPlugin() { |
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 isFormPlugin() should only have effect if there is present of master_key
.
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.
Okay. Maybe I should rename it to IsPluginRequest()
219787e
to
e0f74a6
Compare
I will leave more comments |
@@ -119,6 +119,9 @@ const ( | |||
// PluginTimeout occurs when an operation carried by a plugin is timed out | |||
PluginTimeout | |||
|
|||
// PluginInitializing occurs when any of the plugins are initializing |
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.
“Error codes for expected error condition should be placed above this line.”
i.e. do not insert errors in the middle of a list
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.
Oh. I see.
// IsValidPluginRequest returns true when the payload indicate that the | ||
// request is from plugin AND the master key is used | ||
func (p Payload) IsValidPluginRequest() bool { | ||
fromPlugin, _ := p.Data["_from_plugin"].(bool) |
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.
It is the job of a preprocessor to decide whether the request is a valid plugin request, not the Request
struct. Move this function out of here.
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.
Especially that the “HasMasterKey” function only returns valid value after a auth preprocessor update it.
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.
Does it conflict with this comment ?
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.
Follow UserAuthenticator
in preprocessor/auth.go
} else if h.AccessKeyRequired { | ||
h.preprocessors = h.PreprocessorList.GetByNames( | ||
"plugin", "authenticator") | ||
"authenticator", |
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.
do you need access_key
here? (and above)
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 access_key
is needed since the plugin handler is setting AccessKeyRequired
to be true.
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.
Ah I see now, either accesskey
or authenticator
is required. So authenticator
fits the bill here.
e0f74a6
to
135042b
Compare
His comments are addressed in my review.
connect #219