[MM-29845] Add a new handler to allow authentication via CWS API Key (#16319)
* Add a new handler to allow authentication via CWS API Key * Make error better * Add tests and cases for new handler functions * Move some code around * Add test for GetCloudSession function * unset the env after test completion * Remove white space * Change Info to Warn Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
@@ -19,6 +19,7 @@ const (
|
||||
TokenLocationHeader
|
||||
TokenLocationCookie
|
||||
TokenLocationQueryString
|
||||
TokenLocationCloudHeader
|
||||
)
|
||||
|
||||
func (tl TokenLocation) String() string {
|
||||
@@ -31,6 +32,8 @@ func (tl TokenLocation) String() string {
|
||||
return "Cookie"
|
||||
case TokenLocationQueryString:
|
||||
return "QueryString"
|
||||
case TokenLocationCloudHeader:
|
||||
return "CloudHeader"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
@@ -281,5 +284,9 @@ func ParseAuthTokenFromRequest(r *http.Request) (string, TokenLocation) {
|
||||
return token, TokenLocationQueryString
|
||||
}
|
||||
|
||||
if token := r.Header.Get(model.HEADER_CLOUD_TOKEN); token != "" {
|
||||
return token, TokenLocationCloudHeader
|
||||
}
|
||||
|
||||
return "", TokenLocationNotFound
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user