Skip to content

Commit 9a818cc

Browse files
committed
fix: category validation for permission
1 parent 61f07f5 commit 9a818cc

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

plugins/auth/middleware.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,10 @@ func (a *Auth) basicAuth(h http.HandlerFunc) http.HandlerFunc {
167167
return
168168
}
169169

170-
log.Println("THIS IS THE THING HERE", *reqCategory, *reqCategory == category.ReactiveSearch, reqUser.HasCategory(category.ReactiveSearch))
171-
if reqCategory.IsFromES() {
172-
authenticated = true
173-
} else if *reqCategory == category.ReactiveSearch && reqUser.HasCategory(category.ReactiveSearch) {
174-
authenticated = true
170+
if reqCategory.IsFromES() || reqCategory.IsFromRS() {
171+
authenticated = *reqUser.IsAdmin
175172
} else {
176-
errorMsg = "credential is only allowed to access elasticsearch"
173+
authenticated = true
177174
}
178175

179176
if !authenticated {
@@ -200,12 +197,10 @@ func (a *Auth) basicAuth(h http.HandlerFunc) http.HandlerFunc {
200197
}
201198

202199
log.Println("THIS IS THE THING HERE", *reqCategory, *reqCategory == category.ReactiveSearch, reqPermission.HasCategory(category.ReactiveSearch))
203-
if reqCategory.IsFromES() {
204-
authenticated = true
205-
} else if *reqCategory == category.ReactiveSearch && reqPermission.HasCategory(category.ReactiveSearch) {
200+
if reqPermission.HasCategory(*reqCategory) {
206201
authenticated = true
207202
} else {
208-
errorMsg = "credential is only allowed to access elasticsearch"
203+
errorMsg = "credential is not allowed to access" + *reqCategory.String()
209204
}
210205

211206
// cache the permission

0 commit comments

Comments
 (0)