[#65] Allow no sign requests

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2021-06-11 14:52:03 +03:00
parent 12b92a31c6
commit 8185b71462
3 changed files with 13 additions and 12 deletions

View file

@ -26,8 +26,15 @@ func AttachUserAuth(router *mux.Router, center auth.Center, log *zap.Logger) {
return
}
h.ServeHTTP(w, r.WithContext(
context.WithValue(r.Context(), BearerTokenKey, token)))
var ctx context.Context
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))
})
})
}