1
1
/*
2
2
* MinIO Go Library for Amazon S3 Compatible Cloud Storage
3
- * Copyright 2019-2021 MinIO, Inc.
3
+ * Copyright 2019-2022 MinIO, Inc.
4
4
*
5
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
6
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import (
24
24
"io/ioutil"
25
25
"net/http"
26
26
"net/url"
27
+ "strings"
27
28
"time"
28
29
)
29
30
@@ -105,22 +106,6 @@ func LDAPIdentityExpiryOpt(d time.Duration) LDAPIdentityOpt {
105
106
}
106
107
}
107
108
108
- func stripPassword (err error ) error {
109
- urlErr , ok := err .(* url.Error )
110
- if ok {
111
- u , _ := url .Parse (urlErr .URL )
112
- if u == nil {
113
- return urlErr
114
- }
115
- values := u .Query ()
116
- values .Set ("LDAPPassword" , "xxxxx" )
117
- u .RawQuery = values .Encode ()
118
- urlErr .URL = u .String ()
119
- return urlErr
120
- }
121
- return err
122
- }
123
-
124
109
// NewLDAPIdentityWithSessionPolicy returns new credentials object that uses
125
110
// LDAP Identity with a specified session policy. The `policy` parameter must be
126
111
// a JSON string specifying the policy document.
@@ -156,16 +141,16 @@ func (k *LDAPIdentity) Retrieve() (value Value, err error) {
156
141
v .Set ("DurationSeconds" , fmt .Sprintf ("%d" , int (k .RequestedExpiry .Seconds ())))
157
142
}
158
143
159
- u .RawQuery = v .Encode ()
160
-
161
- req , err := http .NewRequest (http .MethodPost , u .String (), nil )
144
+ req , err := http .NewRequest (http .MethodPost , u .String (), strings .NewReader (v .Encode ()))
162
145
if err != nil {
163
- return value , stripPassword ( err )
146
+ return value , err
164
147
}
165
148
149
+ req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
150
+
166
151
resp , err := k .Client .Do (req )
167
152
if err != nil {
168
- return value , stripPassword ( err )
153
+ return value , err
169
154
}
170
155
171
156
defer resp .Body .Close ()
0 commit comments