introduce max and default quota
This commit is contained in:
1 parent
ee39ac90b0
commit
baaaa774b3
8 files changed
+89
-11
No files matched your search
@@ -227,6 +227,7 @@ func loadMiddlewares(ctx context.Context, logger log.Logger, cfg *config.Config)
|
||||
middleware.Logger(logger),
|
||||
middleware.TokenManagerConfig(*cfg.TokenManager),
|
||||
middleware.RevaGatewayClient(revaClient),
|
||||
middleware.DefaultSpaceQuota(cfg.DefaultSpaceQuota),
|
||||
),
|
||||
middleware.PublicShareAuth(
|
||||
middleware.Logger(logger),
|
||||
|
||||
@@ -33,6 +33,7 @@ type Config struct {
|
||||
EnableBasicAuth bool `yaml:"enable_basic_auth" env:"PROXY_ENABLE_BASIC_AUTH" desc:"Set this to true to enable 'basic' (username/password) authentication."`
|
||||
InsecureBackends bool `yaml:"insecure_backends" env:"PROXY_INSECURE_BACKENDS" desc:"Disable TLS certificate validation for all HTTP backend connections."`
|
||||
AuthMiddleware AuthMiddleware `yaml:"auth_middleware"`
|
||||
DefaultSpaceQuota string `yaml:"default_space_quota" env:"OCIS_DEFAULT_SPACE_QUOTA" desc:"The default quota for personal spaces in bytes"`
|
||||
|
||||
Context context.Context `yaml:"-" json:"-"`
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
revactx "github.com/cs3org/reva/v2/pkg/ctx"
|
||||
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
|
||||
"github.com/cs3org/reva/v2/pkg/utils"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
@@ -22,6 +23,7 @@ func CreateHome(optionSetters ...Option) func(next http.Handler) http.Handler {
|
||||
next: next,
|
||||
logger: logger,
|
||||
revaGatewayClient: options.RevaGatewayClient,
|
||||
defaultQuota: options.DefaultSpaceQuota,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +32,7 @@ type createHome struct {
|
||||
next http.Handler
|
||||
logger log.Logger
|
||||
revaGatewayClient gateway.GatewayAPIClient
|
||||
defaultQuota string
|
||||
}
|
||||
|
||||
func (m createHome) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
@@ -45,8 +48,10 @@ func (m createHome) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
ctx := metadata.AppendToOutgoingContext(req.Context(), revactx.TokenHeader, token)
|
||||
|
||||
createHomeReq := &provider.CreateHomeRequest{}
|
||||
if m.defaultQuota != "" {
|
||||
createHomeReq.Opaque = utils.AppendPlainToOpaque(nil, "quota", m.defaultQuota)
|
||||
}
|
||||
createHomeRes, err := m.revaGatewayClient.CreateHome(ctx, createHomeReq)
|
||||
|
||||
if err != nil {
|
||||
m.logger.Err(err).Msg("error calling CreateHome")
|
||||
} else if createHomeRes.Status.Code != rpc.Code_CODE_OK {
|
||||
|
||||
@@ -60,6 +60,8 @@ type Options struct {
|
||||
AccessTokenVerifyMethod string
|
||||
// JWKS sets the options for fetching the JWKS from the IDP
|
||||
JWKS config.JWKS
|
||||
// DefaultSpaceQuota is the default space quota for personal drives
|
||||
DefaultSpaceQuota string
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
@@ -212,3 +214,10 @@ func JWKSOptions(jo config.JWKS) Option {
|
||||
o.JWKS = jo
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultSpaceQuota ssets the default space quota for personal spaces
|
||||
func DefaultSpaceQuota(q string) Option {
|
||||
return func(o *Options) {
|
||||
o.DefaultSpaceQuota = q
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user