Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 34... Línea 34...
34
    /** @var integer */
34
    /** @var integer */
35
    private $authenticationAttempts;
35
    private $authenticationAttempts;
Línea 36... Línea 36...
36
 
36
 
37
    /** @var integer */
37
    /** @var integer */
-
 
38
    private $tokenFileReadAttempts;
-
 
39
    /** @var string */
Línea 38... Línea 40...
38
    private $tokenFileReadAttempts;
40
    private $source;
39
 
41
 
40
    /**
42
    /**
41
     * The constructor attempts to load config from environment variables.
43
     * The constructor attempts to load config from environment variables.
42
     * If not set, the following config options are used:
44
     * If not set, the following config options are used:
43
     *  - WebIdentityTokenFile: full path of token filename
45
     *  - WebIdentityTokenFile: full path of token filename
-
 
46
     *  - RoleArn: arn of role to be assumed
-
 
47
     *  - SessionName: (optional) set by SDK if not provided
44
     *  - RoleArn: arn of role to be assumed
48
     *  - source: To identify if the provider was sourced by a profile or
45
     *  - SessionName: (optional) set by SDK if not provided
49
     *    from environment definition. Default will be `sts_web_id_token`.
46
     *
50
     *
47
     * @param array $config Configuration options
51
     * @param array $config Configuration options
48
     * @throws \InvalidArgumentException
52
     * @throws \InvalidArgumentException
Línea 64... Línea 68...
64
        }
68
        }
Línea 65... Línea 69...
65
 
69
 
66
        $this->retries = (int) getenv(self::ENV_RETRIES) ?: (isset($config['retries']) ? $config['retries'] : 3);
70
        $this->retries = (int) getenv(self::ENV_RETRIES) ?: (isset($config['retries']) ? $config['retries'] : 3);
67
        $this->authenticationAttempts = 0;
71
        $this->authenticationAttempts = 0;
68
        $this->tokenFileReadAttempts = 0;
-
 
69
 
72
        $this->tokenFileReadAttempts = 0;
70
        $this->session = isset($config['SessionName'])
-
 
71
            ? $config['SessionName']
73
        $this->session = $config['SessionName']
72
            : 'aws-sdk-php-' . round(microtime(true) * 1000);
-
 
73
 
74
            ?? 'aws-sdk-php-' . round(microtime(true) * 1000);
74
        $region = isset($config['region'])
-
 
75
            ? $config['region']
-
 
76
            : 'us-east-1';
-
 
77
 
75
        $region = $config['region'] ?? 'us-east-1';
78
        if (isset($config['client'])) {
76
        if (isset($config['client'])) {
79
            $this->client = $config['client'];
77
            $this->client = $config['client'];
80
        } else {
78
        } else {
81
            $this->client = new StsClient([
79
            $this->client = new StsClient([
82
                'credentials' => false,
80
                'credentials' => false,
83
                'region' => $region,
81
                'region' => $region,
84
                'version' => 'latest'
82
                'version' => 'latest'
85
            ]);
83
            ]);
-
 
84
        }
-
 
85
 
-
 
86
        $this->source = $config['source']
86
        }
87
            ?? CredentialSources::STS_WEB_ID_TOKEN;
Línea 87... Línea 88...
87
    }
88
    }
88
 
89
 
89
    /**
90
    /**
Línea 158... Línea 159...
158
                    );
159
                    );
159
                }
160
                }
160
                $this->authenticationAttempts++;
161
                $this->authenticationAttempts++;
161
            }
162
            }
Línea 162... Línea 163...
162
 
163
 
-
 
164
            yield $this->client->createCredentials(
-
 
165
                $result,
-
 
166
                $this->source
163
            yield $this->client->createCredentials($result);
167
            );
164
        });
168
        });
165
    }
169
    }