[#73] Add missed CORS

Allow X-Bearer-For-All-Users, X-Bearer-Lifetime headers.
Add CORS to /auth/bearer route.

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-10-06 17:40:14 +03:00 committed by Alex Vanin
parent b2fdb8c5f8
commit feaea15aa7
8 changed files with 247 additions and 1 deletions

View file

@ -74,6 +74,9 @@ func NewNeofsRestGwAPI(spec *loads.Document) *NeofsRestGwAPI {
OptionsAuthHandler: OptionsAuthHandlerFunc(func(params OptionsAuthParams) middleware.Responder {
return middleware.NotImplemented("operation OptionsAuth has not yet been implemented")
}),
OptionsAuthBearerHandler: OptionsAuthBearerHandlerFunc(func(params OptionsAuthBearerParams) middleware.Responder {
return middleware.NotImplemented("operation OptionsAuthBearer has not yet been implemented")
}),
OptionsContainersEACLHandler: OptionsContainersEACLHandlerFunc(func(params OptionsContainersEACLParams) middleware.Responder {
return middleware.NotImplemented("operation OptionsContainersEACL has not yet been implemented")
}),
@ -174,6 +177,8 @@ type NeofsRestGwAPI struct {
ListContainersHandler ListContainersHandler
// OptionsAuthHandler sets the operation handler for the options auth operation
OptionsAuthHandler OptionsAuthHandler
// OptionsAuthBearerHandler sets the operation handler for the options auth bearer operation
OptionsAuthBearerHandler OptionsAuthBearerHandler
// OptionsContainersEACLHandler sets the operation handler for the options containers e ACL operation
OptionsContainersEACLHandler OptionsContainersEACLHandler
// OptionsContainersGetDeleteHandler sets the operation handler for the options containers get delete operation
@ -305,6 +310,9 @@ func (o *NeofsRestGwAPI) Validate() error {
if o.OptionsAuthHandler == nil {
unregistered = append(unregistered, "OptionsAuthHandler")
}
if o.OptionsAuthBearerHandler == nil {
unregistered = append(unregistered, "OptionsAuthBearerHandler")
}
if o.OptionsContainersEACLHandler == nil {
unregistered = append(unregistered, "OptionsContainersEACLHandler")
}
@ -477,6 +485,10 @@ func (o *NeofsRestGwAPI) initHandlerCache() {
if o.handlers["OPTIONS"] == nil {
o.handlers["OPTIONS"] = make(map[string]http.Handler)
}
o.handlers["OPTIONS"]["/auth/bearer"] = NewOptionsAuthBearer(o.context, o.OptionsAuthBearerHandler)
if o.handlers["OPTIONS"] == nil {
o.handlers["OPTIONS"] = make(map[string]http.Handler)
}
o.handlers["OPTIONS"]["/containers/{containerId}/eacl"] = NewOptionsContainersEACL(o.context, o.OptionsContainersEACLHandler)
if o.handlers["OPTIONS"] == nil {
o.handlers["OPTIONS"] = make(map[string]http.Handler)