Merge pull request #10200 from influxdata/tg-auth
httpd/meta: use open auth when unrestrictedpull/10215/head
commit
df001c117c
|
@ -475,8 +475,12 @@ func (h *Handler) serveQuery(w http.ResponseWriter, r *http.Request, user meta.U
|
|||
}
|
||||
|
||||
if h.Config.AuthEnabled {
|
||||
// The current user determines the authorized actions.
|
||||
opts.Authorizer = user
|
||||
if user != nil && user.AuthorizeUnrestricted() {
|
||||
opts.Authorizer = query.OpenAuthorizer
|
||||
} else {
|
||||
// The current user determines the authorized actions.
|
||||
opts.Authorizer = user
|
||||
}
|
||||
} else {
|
||||
// Auth is disabled, so allow everything.
|
||||
opts.Authorizer = query.OpenAuthorizer
|
||||
|
|
|
@ -1579,6 +1579,7 @@ type UserInfo struct {
|
|||
type User interface {
|
||||
query.Authorizer
|
||||
ID() string
|
||||
AuthorizeUnrestricted() bool
|
||||
}
|
||||
|
||||
func (u *UserInfo) ID() string {
|
||||
|
@ -1604,6 +1605,11 @@ func (u *UserInfo) AuthorizeSeriesWrite(database string, measurement []byte, tag
|
|||
return true
|
||||
}
|
||||
|
||||
// AuthorizeUnrestricted allows admins to shortcut access checks.
|
||||
func (u *UserInfo) AuthorizeUnrestricted() bool {
|
||||
return u.Admin
|
||||
}
|
||||
|
||||
// clone returns a deep copy of si.
|
||||
func (ui UserInfo) clone() UserInfo {
|
||||
other := ui
|
||||
|
|
Loading…
Reference in New Issue