MCPcopy
hub / github.com/minio/minio-go / RetrieveWithCredContext

Method RetrieveWithCredContext

pkg/credentials/sts_web_identity.go:224–260  ·  view source on GitHub ↗

RetrieveWithCredContext is like Retrieve with optional cred context.

(cc *CredContext)

Source from the content-addressed store, hash-verified

222
223// RetrieveWithCredContext is like Retrieve with optional cred context.
224func (m *STSWebIdentity) RetrieveWithCredContext(cc *CredContext) (Value, error) {
225 if cc == nil {
226 cc = defaultCredContext
227 }
228
229 client := m.Client
230 if client == nil {
231 client = cc.Client
232 }
233 if client == nil {
234 client = defaultCredContext.Client
235 }
236
237 stsEndpoint := m.STSEndpoint
238 if stsEndpoint == "" {
239 stsEndpoint = cc.Endpoint
240 }
241 if stsEndpoint == "" {
242 return Value{}, errors.New("STS endpoint unknown")
243 }
244
245 a, err := getWebIdentityCredentials(client, stsEndpoint, m.RoleARN, m.roleSessionName, m.Policy, m.GetWebIDTokenExpiry, m.TokenRevokeType)
246 if err != nil {
247 return Value{}, err
248 }
249
250 // Expiry window is set to 10secs.
251 m.SetExpiration(a.Result.Credentials.Expiration, DefaultExpiryWindow)
252
253 return Value{
254 AccessKeyID: a.Result.Credentials.AccessKey,
255 SecretAccessKey: a.Result.Credentials.SecretKey,
256 SessionToken: a.Result.Credentials.SessionToken,
257 Expiration: a.Result.Credentials.Expiration,
258 SignerType: SignatureV4,
259 }, nil
260}
261
262// Retrieve retrieves credentials from the MinIO service.
263// Error will be returned if the request fails.

Callers 2

RetrieveMethod · 0.95

Calls 2

SetExpirationMethod · 0.80

Tested by

no test coverage detected