-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Separate the storage-users and graph to handle vault storage #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1b5ed3c
be87e5b
3f827ba
d76b0d6
0300dc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package auth | ||
|
|
||
| import ( | ||
|
Comment on lines
+1
to
+3
|
||
| "context" | ||
|
|
||
| provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" | ||
| rstatus "github.com/owncloud/reva/v2/pkg/rgrpc/status" | ||
| "github.com/rs/zerolog/log" | ||
| "google.golang.org/grpc" | ||
| "google.golang.org/grpc/codes" | ||
| grpcstatus "google.golang.org/grpc/status" | ||
| ) | ||
|
|
||
| func mfaResponse(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo) (interface{}, error) { | ||
| const msg = "MFA required to access vault storage" | ||
| switch req.(type) { | ||
| case *provider.StatRequest: | ||
| return &provider.StatResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.ListContainerRequest: | ||
| return &provider.ListContainerResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.GetPathRequest: | ||
| return &provider.GetPathResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.GetQuotaRequest: | ||
| return &provider.GetQuotaResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.InitiateFileDownloadRequest: | ||
| return &provider.InitiateFileDownloadResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.InitiateFileUploadRequest: | ||
| return &provider.InitiateFileUploadResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.CreateContainerRequest: | ||
| return &provider.CreateContainerResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.TouchFileRequest: | ||
| return &provider.TouchFileResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.DeleteRequest: | ||
| return &provider.DeleteResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.MoveRequest: | ||
| return &provider.MoveResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.CreateHomeRequest: | ||
| return &provider.CreateHomeResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.AddGrantRequest: | ||
| return &provider.AddGrantResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.RemoveGrantRequest: | ||
| return &provider.RemoveGrantResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.UpdateGrantRequest: | ||
| return &provider.UpdateGrantResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.ListGrantsRequest: | ||
| return &provider.ListGrantsResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.ListFileVersionsRequest: | ||
| return &provider.ListFileVersionsResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.RestoreFileVersionRequest: | ||
| return &provider.RestoreFileVersionResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.ListRecycleRequest: | ||
| return &provider.ListRecycleResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.RestoreRecycleItemRequest: | ||
| return &provider.RestoreRecycleItemResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.PurgeRecycleRequest: | ||
| return &provider.PurgeRecycleResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.SetArbitraryMetadataRequest: | ||
| return &provider.SetArbitraryMetadataResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.UnsetArbitraryMetadataRequest: | ||
| return &provider.UnsetArbitraryMetadataResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.ListStorageSpacesRequest: | ||
| return &provider.ListStorageSpacesResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.CreateStorageSpaceRequest: | ||
| return &provider.CreateStorageSpaceResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.UpdateStorageSpaceRequest: | ||
| return &provider.UpdateStorageSpaceResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| case *provider.DeleteStorageSpaceRequest: | ||
| return &provider.DeleteStorageSpaceResponse{Status: rstatus.NewPermissionDenied(ctx, nil, msg)}, nil | ||
| default: | ||
| log.Debug().Str("method", info.FullMethod).Msg("mfa: blocking unknown request type") | ||
| return nil, grpcstatus.Errorf(codes.PermissionDenied, "mfa: %s: %T", msg, req) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
| "errors" | ||
| "fmt" | ||
| "net/http" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "regexp" | ||
|
|
@@ -204,8 +205,15 @@ func (s *svc) writeHTTPError(rw http.ResponseWriter, err error) { | |
| s.log.Error().Msg(err.Error()) | ||
|
|
||
| switch err.(type) { | ||
| case errtypes.NotFound, errtypes.PermissionDenied: | ||
| case errtypes.NotFound: | ||
| rw.WriteHeader(http.StatusNotFound) | ||
| case errtypes.PermissionDenied: | ||
| if strings.Contains(err.Error(), "MFA required") { | ||
| rw.Header().Set("X-Ocis-Mfa-Required", "true") | ||
| rw.WriteHeader(http.StatusForbidden) | ||
| } else { | ||
| rw.WriteHeader(http.StatusNotFound) | ||
| } | ||
|
Comment on lines
+210
to
+216
|
||
| case manager.ErrMaxSize, manager.ErrMaxFileCount: | ||
| rw.WriteHeader(http.StatusRequestEntityTooLarge) | ||
| case errtypes.BadRequest: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -553,6 +553,13 @@ func (s *svc) executeSpacesCopy(ctx context.Context, w http.ResponseWriter, sele | |||||
| } | ||||||
|
|
||||||
| func (s *svc) prepareCopy(ctx context.Context, w http.ResponseWriter, r *http.Request, srcRef, dstRef *provider.Reference, log *zerolog.Logger, destInShareJail bool) *copy { | ||||||
| // restict copy from the vault | ||||||
|
||||||
| // restict copy from the vault | |
| // restrict copy from the vault |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use the same error code, and StatusConflict doesn't seem a good one to use here. If there is anything else in place (HandleWebdavError might do things), we probably need some comment explaining why the errors are different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the same pattern as in the Copy and Move functions, most of the errors are handled the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to at least reference the original code so we know this piece has been copied, and where it has been copied from.
I'm pretty sure that later I'll see this code and think that it's a bug and make the change. The comment will help to double-check, and it will also help to know that there are multiple places with the same problem (if it's a problem)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be handled by the service. Some services might allow access to some parts to anyone while accessing to other parts might require additional privileges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, but it is out of the vault storage scope in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can leave it for now... all the services should have the MFA disabled except the vault, so it should be fine in the short term. Maybe a TODO comment as a reminder to move this piece is good enough.