Skip to content

Commit 124655f

Browse files
harshavardhanavdombrovski
authored andcommitted
update all deps to new changes (minio#3489)
1 parent 15017b1 commit 124655f

File tree

7 files changed

+82
-87
lines changed

7 files changed

+82
-87
lines changed

api/client.go

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"io"
24+
"net/http"
2425
"path"
2526
"strings"
2627
"time"
@@ -299,6 +300,7 @@ type ConsoleCredentialsI interface {
299300
type ConsoleCredentials struct {
300301
ConsoleCredentials *credentials.Credentials
301302
AccountAccessKey string
303+
CredContext *credentials.CredContext
302304
}
303305

304306
func (c ConsoleCredentials) GetAccountAccessKey() string {
@@ -307,7 +309,7 @@ func (c ConsoleCredentials) GetAccountAccessKey() string {
307309

308310
// Get implements *Login.Get()
309311
func (c ConsoleCredentials) Get() (credentials.Value, error) {
310-
return c.ConsoleCredentials.Get()
312+
return c.ConsoleCredentials.GetWithContext(c.CredContext)
311313
}
312314

313315
// Expire implements *Login.Expire()
@@ -322,6 +324,10 @@ type consoleSTSAssumeRole struct {
322324
stsAssumeRole *credentials.STSAssumeRole
323325
}
324326

327+
func (s consoleSTSAssumeRole) RetrieveWithCredContext(cc *credentials.CredContext) (credentials.Value, error) {
328+
return s.stsAssumeRole.RetrieveWithCredContext(cc)
329+
}
330+
325331
func (s consoleSTSAssumeRole) Retrieve() (credentials.Value, error) {
326332
return s.stsAssumeRole.Retrieve()
327333
}
@@ -330,7 +336,7 @@ func (s consoleSTSAssumeRole) IsExpired() bool {
330336
return s.stsAssumeRole.IsExpired()
331337
}
332338

333-
func stsCredentials(minioURL, accessKey, secretKey, location, clientIP string) (*credentials.Credentials, error) {
339+
func stsCredentials(minioURL, accessKey, secretKey, location string, client *http.Client) (*credentials.Credentials, error) {
334340
if accessKey == "" || secretKey == "" {
335341
return nil, errors.New("credentials endpoint, access and secret key are mandatory for AssumeRoleSTS")
336342
}
@@ -341,59 +347,56 @@ func stsCredentials(minioURL, accessKey, secretKey, location, clientIP string) (
341347
DurationSeconds: int(xjwt.GetConsoleSTSDuration().Seconds()),
342348
}
343349
stsAssumeRole := &credentials.STSAssumeRole{
344-
Client: GetConsoleHTTPClient(clientIP),
350+
Client: client,
345351
STSEndpoint: minioURL,
346352
Options: opts,
347353
}
348354
consoleSTSWrapper := consoleSTSAssumeRole{stsAssumeRole: stsAssumeRole}
349355
return credentials.New(consoleSTSWrapper), nil
350356
}
351357

352-
func NewConsoleCredentials(accessKey, secretKey, location, clientIP string) (*credentials.Credentials, error) {
358+
func NewConsoleCredentials(accessKey, secretKey, location string, client *http.Client) (*credentials.Credentials, error) {
353359
minioURL := getMinIOServer()
354360

355-
// Future authentication methods can be added under this switch statement
356-
switch {
357361
// LDAP authentication for Console
358-
case ldap.GetLDAPEnabled():
359-
{
360-
creds, err := auth.GetCredentialsFromLDAP(GetConsoleHTTPClient(clientIP), minioURL, accessKey, secretKey)
361-
if err != nil {
362-
return nil, err
363-
}
362+
if ldap.GetLDAPEnabled() {
363+
creds, err := auth.GetCredentialsFromLDAP(client, minioURL, accessKey, secretKey)
364+
if err != nil {
365+
return nil, err
366+
}
364367

365-
// We verify if LDAP credentials are correct and no error is returned
366-
_, err = creds.Get()
368+
credContext := &credentials.CredContext{
369+
Client: client,
370+
}
367371

368-
if err != nil && strings.Contains(strings.ToLower(err.Error()), "not found") {
369-
// We try to use STS Credentials in case LDAP credentials are incorrect.
370-
stsCreds, errSTS := stsCredentials(minioURL, accessKey, secretKey, location, clientIP)
372+
// We verify if LDAP credentials are correct and no error is returned
373+
_, err = creds.GetWithContext(credContext)
371374

372-
// If there is an error with STS too, then we return the original LDAP error
373-
if errSTS != nil {
374-
LogError("error in STS credentials for LDAP case: %v ", errSTS)
375+
if err != nil && strings.Contains(strings.ToLower(err.Error()), "not found") {
376+
// We try to use STS Credentials in case LDAP credentials are incorrect.
377+
stsCreds, errSTS := stsCredentials(minioURL, accessKey, secretKey, location, client)
375378

376-
// We return LDAP result
377-
return creds, nil
378-
}
379+
// If there is an error with STS too, then we return the original LDAP error
380+
if errSTS != nil {
381+
LogError("error in STS credentials for LDAP case: %v ", errSTS)
379382

380-
_, err := stsCreds.Get()
381-
// There is an error with STS credentials, We return the result of LDAP as STS is not a priority in this case.
382-
if err != nil {
383-
return creds, nil
384-
}
383+
// We return LDAP result
384+
return creds, nil
385+
}
385386

386-
return stsCreds, nil
387+
_, err := stsCreds.GetWithContext(credContext)
388+
// There is an error with STS credentials, We return the result of LDAP as STS is not a priority in this case.
389+
if err != nil {
390+
return creds, nil
387391
}
388392

389-
return creds, nil
390-
}
391-
// default authentication for Console is via STS (Security Token Service) against MinIO
392-
default:
393-
{
394-
return stsCredentials(minioURL, accessKey, secretKey, location, clientIP)
393+
return stsCreds, nil
395394
}
395+
396+
return creds, nil
396397
}
398+
399+
return stsCredentials(minioURL, accessKey, secretKey, location, client)
397400
}
398401

399402
// getConsoleCredentialsFromSession returns the *consoleCredentials.Login associated to the

api/user_account.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func getChangePasswordResponse(session *models.Principal, params accountApi.Acco
5858
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
5959
defer cancel()
6060
clientIP := getClientIP(params.HTTPRequest)
61+
client := GetConsoleHTTPClient(clientIP)
6162

6263
// changePassword operations requires an AdminClient initialized with parent account credentials not
6364
// STS credentials
@@ -79,7 +80,7 @@ func getChangePasswordResponse(session *models.Principal, params accountApi.Acco
7980
}
8081
// user credentials are updated at this point, we need to generate a new admin client and authenticate using
8182
// the new credentials
82-
credentials, err := getConsoleCredentials(accessKey, newSecretKey, clientIP)
83+
credentials, err := getConsoleCredentials(accessKey, newSecretKey, client)
8384
if err != nil {
8485
return nil, ErrorWithContext(ctx, ErrInvalidLogin, nil, err)
8586
}

api/user_buckets.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"encoding/json"
2222
"errors"
2323
"fmt"
24+
"net/http"
2425
"strings"
2526
"time"
2627

@@ -29,6 +30,7 @@ import (
2930
"github.com/minio/madmin-go/v3"
3031
"github.com/minio/mc/cmd"
3132
"github.com/minio/mc/pkg/probe"
33+
"github.com/minio/minio-go/v7/pkg/credentials"
3234
"github.com/minio/minio-go/v7/pkg/sse"
3335
"github.com/minio/minio-go/v7/pkg/tags"
3436

@@ -1067,8 +1069,7 @@ func getMaxShareLinkExpirationResponse(session *models.Principal, params bucketA
10671069
// getMaxShareLinkExpirationSeconds returns the max share link expiration time in seconds which is the sts token expiration time
10681070
func getMaxShareLinkExpirationSeconds(session *models.Principal) (int64, error) {
10691071
creds := getConsoleCredentialsFromSession(session)
1070-
1071-
val, err := creds.Get()
1072+
val, err := creds.GetWithContext(&credentials.CredContext{Client: http.DefaultClient})
10721073
if err != nil {
10731074
return 0, err
10741075
}

api/user_login.go

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,10 @@ import (
2020
"context"
2121
"encoding/base64"
2222
"encoding/json"
23-
stderrors "errors"
2423
"fmt"
25-
"net"
2624
"net/http"
27-
"net/url"
2825
"strings"
2926

30-
"github.com/go-openapi/errors"
31-
3227
"github.com/go-openapi/runtime"
3328
"github.com/go-openapi/runtime/middleware"
3429
"github.com/minio/console/api/operations"
@@ -39,6 +34,7 @@ import (
3934
"github.com/minio/madmin-go/v3"
4035
"github.com/minio/minio-go/v7/pkg/credentials"
4136
"github.com/minio/pkg/v3/env"
37+
xnet "github.com/minio/pkg/v3/net"
4238
)
4339

4440
func registerLoginHandlers(api *operations.ConsoleAPI) {
@@ -114,14 +110,17 @@ func getAccountInfo(ctx context.Context, client MinioAdmin) (*madmin.AccountInfo
114110
}
115111

116112
// getConsoleCredentials will return ConsoleCredentials interface
117-
func getConsoleCredentials(accessKey, secretKey, clientIP string) (*ConsoleCredentials, error) {
118-
creds, err := NewConsoleCredentials(accessKey, secretKey, GetMinIORegion(), clientIP)
113+
func getConsoleCredentials(accessKey, secretKey string, client *http.Client) (*ConsoleCredentials, error) {
114+
creds, err := NewConsoleCredentials(accessKey, secretKey, GetMinIORegion(), client)
119115
if err != nil {
120116
return nil, err
121117
}
122118
return &ConsoleCredentials{
123119
ConsoleCredentials: creds,
124120
AccountAccessKey: accessKey,
121+
CredContext: &credentials.CredContext{
122+
Client: client,
123+
},
125124
}, nil
126125
}
127126

@@ -130,25 +129,24 @@ func getLoginResponse(params authApi.LoginParams) (*models.LoginResponse, *Coded
130129
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
131130
defer cancel()
132131
lr := params.Body
132+
133+
clientIP := getClientIP(params.HTTPRequest)
134+
client := GetConsoleHTTPClient(clientIP)
135+
133136
var err error
134137
var consoleCreds *ConsoleCredentials
135138
// if we receive an STS we use that instead of the credentials
136139
if lr.Sts != "" {
137-
creds := credentials.NewStaticV4(lr.AccessKey, lr.SecretKey, lr.Sts)
138140
consoleCreds = &ConsoleCredentials{
139-
ConsoleCredentials: creds,
141+
ConsoleCredentials: credentials.NewStaticV4(lr.AccessKey, lr.SecretKey, lr.Sts),
140142
AccountAccessKey: lr.AccessKey,
141-
}
142-
143-
credsVerificate, _ := creds.Get()
144-
145-
if credsVerificate.SessionToken == "" || credsVerificate.SecretAccessKey == "" || credsVerificate.AccessKeyID == "" {
146-
return nil, ErrorWithContext(ctx, errors.New(401, "Invalid STS Params"))
143+
CredContext: &credentials.CredContext{
144+
Client: client,
145+
},
147146
}
148147
} else {
149-
clientIP := getClientIP(params.HTTPRequest)
150148
// prepare console credentials
151-
consoleCreds, err = getConsoleCredentials(lr.AccessKey, lr.SecretKey, clientIP)
149+
consoleCreds, err = getConsoleCredentials(lr.AccessKey, lr.SecretKey, client)
152150
if err != nil {
153151
return nil, ErrorWithContext(ctx, err, ErrInvalidLogin)
154152
}
@@ -160,11 +158,8 @@ func getLoginResponse(params authApi.LoginParams) (*models.LoginResponse, *Coded
160158
}
161159
sessionID, err := login(consoleCreds, sf)
162160
if err != nil {
163-
var urlErr *url.Error
164-
if stderrors.As(err, &urlErr) {
165-
if _, isNetErr := urlErr.Err.(net.Error); isNetErr {
166-
return nil, ErrorWithContext(ctx, ErrNetworkError)
167-
}
161+
if xnet.IsNetworkOrHostDown(err, true) {
162+
return nil, ErrorWithContext(ctx, ErrNetworkError)
168163
}
169164
return nil, ErrorWithContext(ctx, err, ErrInvalidLogin)
170165
}
@@ -265,6 +260,7 @@ func getLoginOauth2AuthResponse(params authApi.LoginOauth2AuthParams, openIDProv
265260
r := params.HTTPRequest
266261
lr := params.Body
267262

263+
client := GetConsoleHTTPClient(getClientIP(params.HTTPRequest))
268264
if len(openIDProviders) > 0 {
269265
// we read state
270266
rState := *lr.State
@@ -288,8 +284,7 @@ func getLoginOauth2AuthResponse(params authApi.LoginOauth2AuthParams, openIDProv
288284
}
289285

290286
// Initialize new identity provider with new oauth2Client per IDPName
291-
oauth2Client, err := providerCfg.GetOauth2Provider(IDPName, nil, r,
292-
GetConsoleHTTPClient(getClientIP(params.HTTPRequest)))
287+
oauth2Client, err := providerCfg.GetOauth2Provider(IDPName, nil, r, client)
293288
if err != nil {
294289
return nil, ErrorWithContext(ctx, err)
295290
}
@@ -309,6 +304,7 @@ func getLoginOauth2AuthResponse(params authApi.LoginOauth2AuthParams, openIDProv
309304
token, err := login(&ConsoleCredentials{
310305
ConsoleCredentials: userCredentials,
311306
AccountAccessKey: "",
307+
CredContext: &credentials.CredContext{Client: client},
312308
}, nil)
313309
if err != nil {
314310
return nil, ErrorWithContext(ctx, err)

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ require (
2121
github.com/minio/cli v1.24.2
2222
github.com/minio/highwayhash v1.0.3
2323
github.com/minio/kes v0.23.0
24-
github.com/minio/madmin-go/v3 v3.0.81
24+
github.com/minio/madmin-go/v3 v3.0.85
2525
github.com/minio/mc v0.0.0-20241215225040-f4dd5e4a07ff
26-
github.com/minio/minio-go/v7 v7.0.82
26+
github.com/minio/minio-go/v7 v7.0.83-0.20241230094935-5757f2c8544a
2727
github.com/minio/selfupdate v0.6.0
2828
github.com/minio/websocket v1.6.0
2929
github.com/mitchellh/go-homedir v1.1.0
@@ -33,15 +33,15 @@ require (
3333
github.com/tidwall/gjson v1.17.3 // indirect
3434
github.com/unrolled/secure v1.15.0
3535
golang.org/x/crypto v0.31.0
36-
golang.org/x/net v0.32.0
36+
golang.org/x/net v0.33.0
3737
golang.org/x/oauth2 v0.24.0
3838
// Added to include security fix for
3939
// https://github.com/golang/go/issues/56152
4040
golang.org/x/text v0.21.0 // indirect
4141
gopkg.in/yaml.v2 v2.4.0 // indirect
4242
)
4343

44-
require github.com/minio/pkg/v3 v3.0.24
44+
require github.com/minio/pkg/v3 v3.0.25
4545

4646
require (
4747
aead.dev/mem v0.2.0 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,18 @@ github.com/minio/kes v0.23.0 h1:T0zHtyDoI3JdKrVvzdM4xwVryYYyh5pKwNUVBoqxsNs=
179179
github.com/minio/kes v0.23.0/go.mod h1:vvXVGcgu9mYLkbVWlEvFFl6bYR196RQlOU2Q+rHApl8=
180180
github.com/minio/kes-go v0.2.1 h1:KnqS+p6xoSFJZbQhmJaz/PbxeA6nQyRqT/ywrn5lU2o=
181181
github.com/minio/kes-go v0.2.1/go.mod h1:76xf7l41Wrh+IifisABXK2S8uZWYgWV1IGBKC3GdOJk=
182-
github.com/minio/madmin-go/v3 v3.0.81 h1:sEGhX3gEHciUT6H5O2qyOJ4Nr31vssQUikDcygMcPms=
183-
github.com/minio/madmin-go/v3 v3.0.81/go.mod h1:QAZPX3xx4gdZbZ8t85SieFSwXMOQhFx7bVjldhyc6Bk=
182+
github.com/minio/madmin-go/v3 v3.0.85 h1:bP63oKd5YclvjuUw58BtE8cME0VAoZwvwUV50lEvES4=
183+
github.com/minio/madmin-go/v3 v3.0.85/go.mod h1:pMLdj9OtN0CANNs5tdm6opvOlDFfj0WhbztboZAjRWE=
184184
github.com/minio/mc v0.0.0-20241215225040-f4dd5e4a07ff h1:KOiKIGERKan7dcg8T9hSFj1/DFSw3X1r7p+NFGFsGBo=
185185
github.com/minio/mc v0.0.0-20241215225040-f4dd5e4a07ff/go.mod h1:kKjtUlsNcehsP5f2ji9SicURHyTdlZ9kY2/sCwHKOVk=
186186
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
187187
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
188-
github.com/minio/minio-go/v7 v7.0.82 h1:tWfICLhmp2aFPXL8Tli0XDTHj2VB/fNf0PC1f/i1gRo=
189-
github.com/minio/minio-go/v7 v7.0.82/go.mod h1:84gmIilaX4zcvAWWzJ5Z1WI5axN+hAbM5w25xf8xvC0=
188+
github.com/minio/minio-go/v7 v7.0.83-0.20241230094935-5757f2c8544a h1:nPw29aor4WGYpmBZy5jQT/cW5wtFrG8tEOCNeltMcq8=
189+
github.com/minio/minio-go/v7 v7.0.83-0.20241230094935-5757f2c8544a/go.mod h1:57YXpvc5l3rjPdhqNrDsvVlY0qPI6UTk1bflAe+9doY=
190190
github.com/minio/mux v1.9.0 h1:dWafQFyEfGhJvK6AwLOt83bIG5bxKxKJnKMCi0XAaoA=
191191
github.com/minio/mux v1.9.0/go.mod h1:1pAare17ZRL5GpmNL+9YmqHoWnLmMZF9C/ioUCfy0BQ=
192-
github.com/minio/pkg/v3 v3.0.24 h1:DyaUMvPYueuEn3Tx0kDlU3qFHx/Ygfw9q/2bEp3erR8=
193-
github.com/minio/pkg/v3 v3.0.24/go.mod h1:mIaN552nu0D2jiSk5BQC8LB25f44ytbOBJCuLtksX7Q=
192+
github.com/minio/pkg/v3 v3.0.25 h1:bfxBcxN77uLNiI+qY4/0fxXF4lVdJulwkcJNZcvc1xg=
193+
github.com/minio/pkg/v3 v3.0.25/go.mod h1:mIaN552nu0D2jiSk5BQC8LB25f44ytbOBJCuLtksX7Q=
194194
github.com/minio/selfupdate v0.6.0 h1:i76PgT0K5xO9+hjzKcacQtO7+MjJ4JKA8Ak8XQ9DDwU=
195195
github.com/minio/selfupdate v0.6.0/go.mod h1:bO02GTIPCMQFTEvE5h4DjYB58bCoZ35XLeBf0buTDdM=
196196
github.com/minio/websocket v1.6.0 h1:CPvnQvNvlVaQmvw5gtJNyYQhg4+xRmrPNhBbv8BdpAE=
@@ -326,8 +326,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
326326
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
327327
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
328328
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
329-
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
330-
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
329+
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
330+
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
331331
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
332332
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
333333
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

0 commit comments

Comments
 (0)