forked from TrueCloudLab/frostfs-s3-gw
[#65] Allow no sign requests
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
12b92a31c6
commit
8185b71462
3 changed files with 13 additions and 12 deletions
|
@ -70,7 +70,7 @@ func (c *center) Authenticate(r *http.Request) (*token.BearerToken, error) {
|
||||||
|
|
||||||
authHeaderField := r.Header["Authorization"]
|
authHeaderField := r.Header["Authorization"]
|
||||||
if len(authHeaderField) != 1 {
|
if len(authHeaderField) != 1 {
|
||||||
return nil, errors.New("unsupported request: wrong length of Authorization header field")
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
sms1 := c.reg.getSubmatches(authHeaderField[0])
|
sms1 := c.reg.getSubmatches(authHeaderField[0])
|
||||||
|
|
|
@ -130,18 +130,12 @@ func (n *layer) GetBucketInfo(ctx context.Context, name string) (*BucketInfo, er
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list, err := n.containerList(ctx)
|
containerID := new(cid.ID)
|
||||||
if err != nil {
|
if err := containerID.Parse(name); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, bkt := range list {
|
return n.containerInfo(ctx, containerID)
|
||||||
if bkt.Name == name {
|
|
||||||
return bkt, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, status.Error(codes.NotFound, "bucket not found")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListBuckets returns all user containers. Name of the bucket is a container
|
// ListBuckets returns all user containers. Name of the bucket is a container
|
||||||
|
|
|
@ -26,8 +26,15 @@ func AttachUserAuth(router *mux.Router, center auth.Center, log *zap.Logger) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
h.ServeHTTP(w, r.WithContext(
|
var ctx context.Context
|
||||||
context.WithValue(r.Context(), BearerTokenKey, token)))
|
if token == nil {
|
||||||
|
log.Info("couldn't receive bearer token, switch to use neofs-key")
|
||||||
|
ctx = r.Context()
|
||||||
|
} else {
|
||||||
|
ctx = context.WithValue(r.Context(), BearerTokenKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
h.ServeHTTP(w, r.WithContext(ctx))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue