diff --git a/models/max_share_link_exp_response.go b/models/max_share_link_exp_response.go
new file mode 100644
index 000000000..e91c57741
--- /dev/null
+++ b/models/max_share_link_exp_response.go
@@ -0,0 +1,88 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2023 MinIO, Inc.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+
+package models
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "context"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/swag"
+ "github.com/go-openapi/validate"
+)
+
+// MaxShareLinkExpResponse max share link exp response
+//
+// swagger:model maxShareLinkExpResponse
+type MaxShareLinkExpResponse struct {
+
+ // exp
+ // Required: true
+ Exp *int64 `json:"exp"`
+}
+
+// Validate validates this max share link exp response
+func (m *MaxShareLinkExpResponse) Validate(formats strfmt.Registry) error {
+ var res []error
+
+ if err := m.validateExp(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
+
+func (m *MaxShareLinkExpResponse) validateExp(formats strfmt.Registry) error {
+
+ if err := validate.Required("exp", "body", m.Exp); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// ContextValidate validates this max share link exp response based on context it is used
+func (m *MaxShareLinkExpResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
+ return nil
+}
+
+// MarshalBinary interface implementation
+func (m *MaxShareLinkExpResponse) MarshalBinary() ([]byte, error) {
+ if m == nil {
+ return nil, nil
+ }
+ return swag.WriteJSON(m)
+}
+
+// UnmarshalBinary interface implementation
+func (m *MaxShareLinkExpResponse) UnmarshalBinary(b []byte) error {
+ var res MaxShareLinkExpResponse
+ if err := swag.ReadJSON(b, &res); err != nil {
+ return err
+ }
+ *m = res
+ return nil
+}
diff --git a/portal-ui/src/api/consoleApi.ts b/portal-ui/src/api/consoleApi.ts
index a566cbea5..8a1514552 100644
--- a/portal-ui/src/api/consoleApi.ts
+++ b/portal-ui/src/api/consoleApi.ts
@@ -1499,6 +1499,11 @@ export interface LdapPolicyEntity {
groups?: string[];
}
+export interface MaxShareLinkExpResponse {
+ /** @format int64 */
+ exp: number;
+}
+
export type QueryParamsType = Record;
export type ResponseFormat = keyof Omit;
@@ -2916,6 +2921,24 @@ export class Api<
format: "json",
...params,
}),
+
+ /**
+ * No description
+ *
+ * @tags Bucket
+ * @name GetMaxShareLinkExp
+ * @summary Get max expiration time for share link in seconds
+ * @request GET:/buckets/max-share-exp
+ * @secure
+ */
+ getMaxShareLinkExp: (params: RequestParams = {}) =>
+ this.request({
+ path: `/buckets/max-share-exp`,
+ method: "GET",
+ secure: true,
+ format: "json",
+ ...params,
+ }),
};
listExternalBuckets = {
/**
diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go
index 224090802..487ea7ef7 100644
--- a/restapi/embedded_spec.go
+++ b/restapi/embedded_spec.go
@@ -911,6 +911,29 @@ func init() {
}
}
},
+ "/buckets/max-share-exp": {
+ "get": {
+ "tags": [
+ "Bucket"
+ ],
+ "summary": "Get max expiration time for share link in seconds",
+ "operationId": "GetMaxShareLinkExp",
+ "responses": {
+ "200": {
+ "description": "A successful response.",
+ "schema": {
+ "$ref": "#/definitions/maxShareLinkExpResponse"
+ }
+ },
+ "default": {
+ "description": "Generic error response.",
+ "schema": {
+ "$ref": "#/definitions/ApiError"
+ }
+ }
+ }
+ }
+ },
"/buckets/multi-lifecycle": {
"post": {
"tags": [
@@ -7094,6 +7117,18 @@ func init() {
}
}
},
+ "maxShareLinkExpResponse": {
+ "type": "object",
+ "required": [
+ "exp"
+ ],
+ "properties": {
+ "exp": {
+ "type": "number",
+ "format": "int64"
+ }
+ }
+ },
"metadata": {
"type": "object",
"properties": {
@@ -9941,6 +9976,29 @@ func init() {
}
}
},
+ "/buckets/max-share-exp": {
+ "get": {
+ "tags": [
+ "Bucket"
+ ],
+ "summary": "Get max expiration time for share link in seconds",
+ "operationId": "GetMaxShareLinkExp",
+ "responses": {
+ "200": {
+ "description": "A successful response.",
+ "schema": {
+ "$ref": "#/definitions/maxShareLinkExpResponse"
+ }
+ },
+ "default": {
+ "description": "Generic error response.",
+ "schema": {
+ "$ref": "#/definitions/ApiError"
+ }
+ }
+ }
+ }
+ },
"/buckets/multi-lifecycle": {
"post": {
"tags": [
@@ -16325,6 +16383,18 @@ func init() {
}
}
},
+ "maxShareLinkExpResponse": {
+ "type": "object",
+ "required": [
+ "exp"
+ ],
+ "properties": {
+ "exp": {
+ "type": "number",
+ "format": "int64"
+ }
+ }
+ },
"metadata": {
"type": "object",
"properties": {
diff --git a/restapi/operations/bucket/get_max_share_link_exp.go b/restapi/operations/bucket/get_max_share_link_exp.go
new file mode 100644
index 000000000..180734e78
--- /dev/null
+++ b/restapi/operations/bucket/get_max_share_link_exp.go
@@ -0,0 +1,88 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2023 MinIO, Inc.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+
+package bucket
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the generate command
+
+import (
+ "net/http"
+
+ "github.com/go-openapi/runtime/middleware"
+
+ "github.com/minio/console/models"
+)
+
+// GetMaxShareLinkExpHandlerFunc turns a function with the right signature into a get max share link exp handler
+type GetMaxShareLinkExpHandlerFunc func(GetMaxShareLinkExpParams, *models.Principal) middleware.Responder
+
+// Handle executing the request and returning a response
+func (fn GetMaxShareLinkExpHandlerFunc) Handle(params GetMaxShareLinkExpParams, principal *models.Principal) middleware.Responder {
+ return fn(params, principal)
+}
+
+// GetMaxShareLinkExpHandler interface for that can handle valid get max share link exp params
+type GetMaxShareLinkExpHandler interface {
+ Handle(GetMaxShareLinkExpParams, *models.Principal) middleware.Responder
+}
+
+// NewGetMaxShareLinkExp creates a new http.Handler for the get max share link exp operation
+func NewGetMaxShareLinkExp(ctx *middleware.Context, handler GetMaxShareLinkExpHandler) *GetMaxShareLinkExp {
+ return &GetMaxShareLinkExp{Context: ctx, Handler: handler}
+}
+
+/*
+ GetMaxShareLinkExp swagger:route GET /buckets/max-share-exp Bucket getMaxShareLinkExp
+
+Get max expiration time for share link in seconds
+*/
+type GetMaxShareLinkExp struct {
+ Context *middleware.Context
+ Handler GetMaxShareLinkExpHandler
+}
+
+func (o *GetMaxShareLinkExp) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
+ route, rCtx, _ := o.Context.RouteInfo(r)
+ if rCtx != nil {
+ *r = *rCtx
+ }
+ var Params = NewGetMaxShareLinkExpParams()
+ uprinc, aCtx, err := o.Context.Authorize(r, route)
+ if err != nil {
+ o.Context.Respond(rw, r, route.Produces, route, err)
+ return
+ }
+ if aCtx != nil {
+ *r = *aCtx
+ }
+ var principal *models.Principal
+ if uprinc != nil {
+ principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
+ }
+
+ if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
+ o.Context.Respond(rw, r, route.Produces, route, err)
+ return
+ }
+
+ res := o.Handler.Handle(Params, principal) // actually handle the request
+ o.Context.Respond(rw, r, route.Produces, route, res)
+
+}
diff --git a/restapi/operations/bucket/get_max_share_link_exp_parameters.go b/restapi/operations/bucket/get_max_share_link_exp_parameters.go
new file mode 100644
index 000000000..4b39aa3cb
--- /dev/null
+++ b/restapi/operations/bucket/get_max_share_link_exp_parameters.go
@@ -0,0 +1,63 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2023 MinIO, Inc.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+
+package bucket
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "net/http"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/runtime/middleware"
+)
+
+// NewGetMaxShareLinkExpParams creates a new GetMaxShareLinkExpParams object
+//
+// There are no default values defined in the spec.
+func NewGetMaxShareLinkExpParams() GetMaxShareLinkExpParams {
+
+ return GetMaxShareLinkExpParams{}
+}
+
+// GetMaxShareLinkExpParams contains all the bound params for the get max share link exp operation
+// typically these are obtained from a http.Request
+//
+// swagger:parameters GetMaxShareLinkExp
+type GetMaxShareLinkExpParams struct {
+
+ // HTTP Request Object
+ HTTPRequest *http.Request `json:"-"`
+}
+
+// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
+// for simple values it will use straight method calls.
+//
+// To ensure default values, the struct must have been initialized with NewGetMaxShareLinkExpParams() beforehand.
+func (o *GetMaxShareLinkExpParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
+ var res []error
+
+ o.HTTPRequest = r
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
diff --git a/restapi/operations/bucket/get_max_share_link_exp_responses.go b/restapi/operations/bucket/get_max_share_link_exp_responses.go
new file mode 100644
index 000000000..0a5da47fa
--- /dev/null
+++ b/restapi/operations/bucket/get_max_share_link_exp_responses.go
@@ -0,0 +1,135 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2023 MinIO, Inc.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+
+package bucket
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "net/http"
+
+ "github.com/go-openapi/runtime"
+
+ "github.com/minio/console/models"
+)
+
+// GetMaxShareLinkExpOKCode is the HTTP code returned for type GetMaxShareLinkExpOK
+const GetMaxShareLinkExpOKCode int = 200
+
+/*
+GetMaxShareLinkExpOK A successful response.
+
+swagger:response getMaxShareLinkExpOK
+*/
+type GetMaxShareLinkExpOK struct {
+
+ /*
+ In: Body
+ */
+ Payload *models.MaxShareLinkExpResponse `json:"body,omitempty"`
+}
+
+// NewGetMaxShareLinkExpOK creates GetMaxShareLinkExpOK with default headers values
+func NewGetMaxShareLinkExpOK() *GetMaxShareLinkExpOK {
+
+ return &GetMaxShareLinkExpOK{}
+}
+
+// WithPayload adds the payload to the get max share link exp o k response
+func (o *GetMaxShareLinkExpOK) WithPayload(payload *models.MaxShareLinkExpResponse) *GetMaxShareLinkExpOK {
+ o.Payload = payload
+ return o
+}
+
+// SetPayload sets the payload to the get max share link exp o k response
+func (o *GetMaxShareLinkExpOK) SetPayload(payload *models.MaxShareLinkExpResponse) {
+ o.Payload = payload
+}
+
+// WriteResponse to the client
+func (o *GetMaxShareLinkExpOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
+
+ rw.WriteHeader(200)
+ if o.Payload != nil {
+ payload := o.Payload
+ if err := producer.Produce(rw, payload); err != nil {
+ panic(err) // let the recovery middleware deal with this
+ }
+ }
+}
+
+/*
+GetMaxShareLinkExpDefault Generic error response.
+
+swagger:response getMaxShareLinkExpDefault
+*/
+type GetMaxShareLinkExpDefault struct {
+ _statusCode int
+
+ /*
+ In: Body
+ */
+ Payload *models.APIError `json:"body,omitempty"`
+}
+
+// NewGetMaxShareLinkExpDefault creates GetMaxShareLinkExpDefault with default headers values
+func NewGetMaxShareLinkExpDefault(code int) *GetMaxShareLinkExpDefault {
+ if code <= 0 {
+ code = 500
+ }
+
+ return &GetMaxShareLinkExpDefault{
+ _statusCode: code,
+ }
+}
+
+// WithStatusCode adds the status to the get max share link exp default response
+func (o *GetMaxShareLinkExpDefault) WithStatusCode(code int) *GetMaxShareLinkExpDefault {
+ o._statusCode = code
+ return o
+}
+
+// SetStatusCode sets the status to the get max share link exp default response
+func (o *GetMaxShareLinkExpDefault) SetStatusCode(code int) {
+ o._statusCode = code
+}
+
+// WithPayload adds the payload to the get max share link exp default response
+func (o *GetMaxShareLinkExpDefault) WithPayload(payload *models.APIError) *GetMaxShareLinkExpDefault {
+ o.Payload = payload
+ return o
+}
+
+// SetPayload sets the payload to the get max share link exp default response
+func (o *GetMaxShareLinkExpDefault) SetPayload(payload *models.APIError) {
+ o.Payload = payload
+}
+
+// WriteResponse to the client
+func (o *GetMaxShareLinkExpDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
+
+ rw.WriteHeader(o._statusCode)
+ if o.Payload != nil {
+ payload := o.Payload
+ if err := producer.Produce(rw, payload); err != nil {
+ panic(err) // let the recovery middleware deal with this
+ }
+ }
+}
diff --git a/restapi/operations/bucket/get_max_share_link_exp_urlbuilder.go b/restapi/operations/bucket/get_max_share_link_exp_urlbuilder.go
new file mode 100644
index 000000000..707af8b0b
--- /dev/null
+++ b/restapi/operations/bucket/get_max_share_link_exp_urlbuilder.go
@@ -0,0 +1,104 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// This file is part of MinIO Console Server
+// Copyright (c) 2023 MinIO, Inc.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+
+package bucket
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the generate command
+
+import (
+ "errors"
+ "net/url"
+ golangswaggerpaths "path"
+)
+
+// GetMaxShareLinkExpURL generates an URL for the get max share link exp operation
+type GetMaxShareLinkExpURL struct {
+ _basePath string
+}
+
+// WithBasePath sets the base path for this url builder, only required when it's different from the
+// base path specified in the swagger spec.
+// When the value of the base path is an empty string
+func (o *GetMaxShareLinkExpURL) WithBasePath(bp string) *GetMaxShareLinkExpURL {
+ o.SetBasePath(bp)
+ return o
+}
+
+// SetBasePath sets the base path for this url builder, only required when it's different from the
+// base path specified in the swagger spec.
+// When the value of the base path is an empty string
+func (o *GetMaxShareLinkExpURL) SetBasePath(bp string) {
+ o._basePath = bp
+}
+
+// Build a url path and query string
+func (o *GetMaxShareLinkExpURL) Build() (*url.URL, error) {
+ var _result url.URL
+
+ var _path = "/buckets/max-share-exp"
+
+ _basePath := o._basePath
+ if _basePath == "" {
+ _basePath = "/api/v1"
+ }
+ _result.Path = golangswaggerpaths.Join(_basePath, _path)
+
+ return &_result, nil
+}
+
+// Must is a helper function to panic when the url builder returns an error
+func (o *GetMaxShareLinkExpURL) Must(u *url.URL, err error) *url.URL {
+ if err != nil {
+ panic(err)
+ }
+ if u == nil {
+ panic("url can't be nil")
+ }
+ return u
+}
+
+// String returns the string representation of the path with query string
+func (o *GetMaxShareLinkExpURL) String() string {
+ return o.Must(o.Build()).String()
+}
+
+// BuildFull builds a full url with scheme, host, path and query string
+func (o *GetMaxShareLinkExpURL) BuildFull(scheme, host string) (*url.URL, error) {
+ if scheme == "" {
+ return nil, errors.New("scheme is required for a full url on GetMaxShareLinkExpURL")
+ }
+ if host == "" {
+ return nil, errors.New("host is required for a full url on GetMaxShareLinkExpURL")
+ }
+
+ base, err := o.Build()
+ if err != nil {
+ return nil, err
+ }
+
+ base.Scheme = scheme
+ base.Host = host
+ return base, nil
+}
+
+// StringFull returns the string representation of a complete url
+func (o *GetMaxShareLinkExpURL) StringFull(scheme, host string) string {
+ return o.Must(o.BuildFull(scheme, host)).String()
+}
diff --git a/restapi/operations/console_api.go b/restapi/operations/console_api.go
index c2618b8a1..6b1f273fb 100644
--- a/restapi/operations/console_api.go
+++ b/restapi/operations/console_api.go
@@ -256,6 +256,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
IdpGetLDAPEntitiesHandler: idp.GetLDAPEntitiesHandlerFunc(func(params idp.GetLDAPEntitiesParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation idp.GetLDAPEntities has not yet been implemented")
}),
+ BucketGetMaxShareLinkExpHandler: bucket.GetMaxShareLinkExpHandlerFunc(func(params bucket.GetMaxShareLinkExpParams, principal *models.Principal) middleware.Responder {
+ return middleware.NotImplemented("operation bucket.GetMaxShareLinkExp has not yet been implemented")
+ }),
ObjectGetObjectMetadataHandler: object.GetObjectMetadataHandlerFunc(func(params object.GetObjectMetadataParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation object.GetObjectMetadata has not yet been implemented")
}),
@@ -731,6 +734,8 @@ type ConsoleAPI struct {
IdpGetConfigurationHandler idp.GetConfigurationHandler
// IdpGetLDAPEntitiesHandler sets the operation handler for the get l d a p entities operation
IdpGetLDAPEntitiesHandler idp.GetLDAPEntitiesHandler
+ // BucketGetMaxShareLinkExpHandler sets the operation handler for the get max share link exp operation
+ BucketGetMaxShareLinkExpHandler bucket.GetMaxShareLinkExpHandler
// ObjectGetObjectMetadataHandler sets the operation handler for the get object metadata operation
ObjectGetObjectMetadataHandler object.GetObjectMetadataHandler
// PolicyGetSAUserPolicyHandler sets the operation handler for the get s a user policy operation
@@ -1190,6 +1195,9 @@ func (o *ConsoleAPI) Validate() error {
if o.IdpGetLDAPEntitiesHandler == nil {
unregistered = append(unregistered, "idp.GetLDAPEntitiesHandler")
}
+ if o.BucketGetMaxShareLinkExpHandler == nil {
+ unregistered = append(unregistered, "bucket.GetMaxShareLinkExpHandler")
+ }
if o.ObjectGetObjectMetadataHandler == nil {
unregistered = append(unregistered, "object.GetObjectMetadataHandler")
}
@@ -1824,6 +1832,10 @@ func (o *ConsoleAPI) initHandlerCache() {
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
+ o.handlers["GET"]["/buckets/max-share-exp"] = bucket.NewGetMaxShareLinkExp(o.context, o.BucketGetMaxShareLinkExpHandler)
+ if o.handlers["GET"] == nil {
+ o.handlers["GET"] = make(map[string]http.Handler)
+ }
o.handlers["GET"]["/buckets/{bucket_name}/objects/metadata"] = object.NewGetObjectMetadata(o.context, o.ObjectGetObjectMetadataHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
diff --git a/restapi/user_buckets.go b/restapi/user_buckets.go
index 3a589d4fa..92170a570 100644
--- a/restapi/user_buckets.go
+++ b/restapi/user_buckets.go
@@ -36,6 +36,7 @@ import (
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/swag"
"github.com/minio/console/models"
+ "github.com/minio/console/pkg/auth/token"
"github.com/minio/console/restapi/operations"
bucketApi "github.com/minio/console/restapi/operations/bucket"
"github.com/minio/minio-go/v7/pkg/policy"
@@ -178,6 +179,14 @@ func registerBucketsHandlers(api *operations.ConsoleAPI) {
}
return bucketApi.NewGetBucketRewindOK().WithPayload(getBucketRewind)
})
+ // get max allowed share link expiration time
+ api.BucketGetMaxShareLinkExpHandler = bucketApi.GetMaxShareLinkExpHandlerFunc(func(params bucketApi.GetMaxShareLinkExpParams, session *models.Principal) middleware.Responder {
+ val, err := getMaxShareLinkExpirationResponse(session, params)
+ if err != nil {
+ return bucketApi.NewGetMaxShareLinkExpDefault(err.Code).WithPayload(err.APIError)
+ }
+ return bucketApi.NewGetMaxShareLinkExpOK().WithPayload(val)
+ })
}
type VersionState string
@@ -1067,3 +1076,31 @@ func getBucketRewindResponse(session *models.Principal, params bucketApi.GetBuck
Objects: rewindItems,
}, nil
}
+
+func getMaxShareLinkExpirationResponse(session *models.Principal, params bucketApi.GetMaxShareLinkExpParams) (*models.MaxShareLinkExpResponse, *CodedAPIError) {
+ ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
+ defer cancel()
+
+ maxShareLinkExpSeconds, err := getMaxShareLinkExpirationSeconds(session)
+ if err != nil {
+ return nil, ErrorWithContext(ctx, err)
+ }
+ return &models.MaxShareLinkExpResponse{Exp: swag.Int64(maxShareLinkExpSeconds)}, nil
+}
+
+// getMaxShareLinkExpirationSeconds returns the max share link expiration time in seconds which is the sts token expiration time
+func getMaxShareLinkExpirationSeconds(session *models.Principal) (int64, error) {
+ creds := getConsoleCredentialsFromSession(session)
+
+ val, err := creds.Get()
+ if err != nil {
+ return 0, err
+ }
+
+ if val.SignerType.IsAnonymous() {
+ return 0, ErrAccessDenied
+ }
+ maxShareLinkExp := token.GetConsoleSTSDuration()
+
+ return int64(maxShareLinkExp.Seconds()), nil
+}
diff --git a/restapi/user_buckets_test.go b/restapi/user_buckets_test.go
index 3af669cce..aff9bd836 100644
--- a/restapi/user_buckets_test.go
+++ b/restapi/user_buckets_test.go
@@ -20,10 +20,12 @@ import (
"context"
"errors"
"fmt"
+ "os"
"reflect"
"testing"
"time"
+ "github.com/minio/console/pkg/auth/token"
"github.com/minio/console/pkg/utils"
"github.com/go-openapi/swag"
@@ -1212,3 +1214,75 @@ func Test_getAccountBuckets(t *testing.T) {
})
}
}
+
+func Test_getMaxShareLinkExpirationSeconds(t *testing.T) {
+ type args struct {
+ session *models.Principal
+ }
+ tests := []struct {
+ name string
+ args args
+ want int64
+ wantErr bool
+ preFunc func()
+ postFunc func()
+ }{
+ {
+ name: "empty session returns error",
+ args: args{
+ session: nil,
+ },
+ want: 0,
+ wantErr: true,
+ },
+ {
+ name: "invalid/expired session returns error",
+ args: args{
+ session: &models.Principal{
+ STSAccessKeyID: "",
+ STSSecretAccessKey: "",
+ STSSessionToken: "",
+ },
+ },
+ want: 0,
+ wantErr: true,
+ },
+ {
+ name: "valid session, returns value from env variable",
+ args: args{
+ session: &models.Principal{
+ STSAccessKeyID: "VQH975JV49JYDLK7F81G",
+ STSSecretAccessKey: "zZ2oMQrZwPWGEf1yyHneWFK2JBlGkVjYTJnfw75X",
+ STSSessionToken: "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJWUUg5NzVKVjQ5SllETEs3RjgxRyIsImV4cCI6MTY5Nzc0Mzg1MywicGFyZW50IjoibWluaW9hZG1pbiJ9.tRJVb3gbRFswKyNsxz_Dbw1SHoIQRRgA3xmXpXE4shScCsQXDydc7U_F9QOjL_BQDcgs65ZqWo3N2CIPmWoGDA",
+ },
+ },
+ want: 3600,
+ wantErr: false,
+ preFunc: func() {
+ os.Setenv(token.ConsoleSTSDuration, "1h")
+ },
+ postFunc: func() {
+ os.Unsetenv(token.ConsoleSTSDuration)
+ },
+ },
+ }
+ for _, tt := range tests {
+ tt := tt
+ t.Run(tt.name, func(t *testing.T) {
+ if tt.preFunc != nil {
+ tt.preFunc()
+ }
+ expTime, err := getMaxShareLinkExpirationSeconds(tt.args.session)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("getMaxShareLinkExpirationSeconds() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(expTime, tt.want) {
+ t.Errorf("getMaxShareLinkExpirationSeconds() got = %v, want %v", expTime, tt.want)
+ }
+ if tt.postFunc != nil {
+ tt.postFunc()
+ }
+ })
+ }
+}
diff --git a/swagger.yml b/swagger.yml
index 9fc45d5cb..ee5786fe7 100644
--- a/swagger.yml
+++ b/swagger.yml
@@ -884,50 +884,6 @@ paths:
tags:
- Bucket
- /list-external-buckets:
- post:
- summary: Lists an External list of buckets using custom credentials
- operationId: ListExternalBuckets
- parameters:
- - name: body
- in: body
- required: true
- schema:
- $ref: "#/definitions/listExternalBucketsParams"
- responses:
- 200:
- description: A successful response.
- schema:
- $ref: "#/definitions/listBucketsResponse"
- default:
- description: Generic error response.
- schema:
- $ref: "#/definitions/ApiError"
- tags:
- - Bucket
-
- /buckets-replication:
- post:
- summary: Sets Multi Bucket Replication in multiple Buckets
- operationId: SetMultiBucketReplication
- parameters:
- - name: body
- in: body
- required: true
- schema:
- $ref: "#/definitions/multiBucketReplication"
- responses:
- 200:
- description: A successful response.
- schema:
- $ref: "#/definitions/multiBucketResponseState"
- default:
- description: Generic error response.
- schema:
- $ref: "#/definitions/ApiError"
- tags:
- - Bucket
-
/buckets/{bucket_name}/replication:
get:
summary: Bucket Replication
@@ -1339,6 +1295,66 @@ paths:
tags:
- Bucket
+ /buckets/max-share-exp:
+ get:
+ summary: Get max expiration time for share link in seconds
+ operationId: GetMaxShareLinkExp
+ responses:
+ 200:
+ description: A successful response.
+ schema:
+ $ref: "#/definitions/maxShareLinkExpResponse"
+ default:
+ description: Generic error response.
+ schema:
+ $ref: "#/definitions/ApiError"
+ tags:
+ - Bucket
+
+ /list-external-buckets:
+ post:
+ summary: Lists an External list of buckets using custom credentials
+ operationId: ListExternalBuckets
+ parameters:
+ - name: body
+ in: body
+ required: true
+ schema:
+ $ref: "#/definitions/listExternalBucketsParams"
+ responses:
+ 200:
+ description: A successful response.
+ schema:
+ $ref: "#/definitions/listBucketsResponse"
+ default:
+ description: Generic error response.
+ schema:
+ $ref: "#/definitions/ApiError"
+ tags:
+ - Bucket
+
+ /buckets-replication:
+ post:
+ summary: Sets Multi Bucket Replication in multiple Buckets
+ operationId: SetMultiBucketReplication
+ parameters:
+ - name: body
+ in: body
+ required: true
+ schema:
+ $ref: "#/definitions/multiBucketReplication"
+ responses:
+ 200:
+ description: A successful response.
+ schema:
+ $ref: "#/definitions/multiBucketResponseState"
+ default:
+ description: Generic error response.
+ schema:
+ $ref: "#/definitions/ApiError"
+ tags:
+ - Bucket
+
/service-accounts:
get:
summary: List User's Service Accounts
@@ -6120,3 +6136,12 @@ definitions:
type: array
items:
type: string
+
+ maxShareLinkExpResponse:
+ type: object
+ properties:
+ exp:
+ type: number
+ format: int64
+ required:
+ - exp