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

Method RetrieveWithCredContext

pkg/credentials/assume_role.go:227–263  ·  view source on GitHub ↗

RetrieveWithCredContext retrieves credentials from the MinIO service. Error will be returned if the request fails, optional cred context.

(cc *CredContext)

Source from the content-addressed store, hash-verified

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

Callers 1

RetrieveMethod · 0.95

Calls 2

getAssumeRoleCredentialsFunction · 0.85
SetExpirationMethod · 0.80

Tested by

no test coverage detected