This class handles the creation of profile based providers. NOTE: This class is only intended for internal use. This class handles the creation and ordering of the various credential providers that primarly source their configuration from the shared config. This is needed to enable
| 175 | |
| 176 | |
| 177 | class ProfileProviderBuilder: |
| 178 | """This class handles the creation of profile based providers. |
| 179 | |
| 180 | NOTE: This class is only intended for internal use. |
| 181 | |
| 182 | This class handles the creation and ordering of the various credential |
| 183 | providers that primarly source their configuration from the shared config. |
| 184 | This is needed to enable sharing between the default credential chain and |
| 185 | the source profile chain created by the assume role provider. |
| 186 | """ |
| 187 | |
| 188 | def __init__( |
| 189 | self, |
| 190 | session, |
| 191 | cache=None, |
| 192 | region_name=None, |
| 193 | sso_token_cache=None, |
| 194 | signin_token_cache=None, |
| 195 | ): |
| 196 | self._session = session |
| 197 | self._cache = cache |
| 198 | self._region_name = region_name |
| 199 | self._sso_token_cache = sso_token_cache |
| 200 | self._signin_token_cache = signin_token_cache |
| 201 | |
| 202 | def providers(self, profile_name, disable_env_vars=False): |
| 203 | return [ |
| 204 | self._create_web_identity_provider( |
| 205 | profile_name, |
| 206 | disable_env_vars, |
| 207 | ), |
| 208 | self._create_sso_provider(profile_name), |
| 209 | self._create_shared_credential_provider(profile_name), |
| 210 | self._create_login_provider(profile_name), |
| 211 | self._create_process_provider(profile_name), |
| 212 | self._create_config_provider(profile_name), |
| 213 | ] |
| 214 | |
| 215 | def _create_process_provider(self, profile_name): |
| 216 | return ProcessProvider( |
| 217 | profile_name=profile_name, |
| 218 | load_config=lambda: self._session.full_config, |
| 219 | ) |
| 220 | |
| 221 | def _create_shared_credential_provider(self, profile_name): |
| 222 | credential_file = self._session.get_config_variable('credentials_file') |
| 223 | return SharedCredentialProvider( |
| 224 | profile_name=profile_name, |
| 225 | creds_filename=credential_file, |
| 226 | ) |
| 227 | |
| 228 | def _create_config_provider(self, profile_name): |
| 229 | config_file = self._session.get_config_variable('config_file') |
| 230 | return ConfigProvider( |
| 231 | profile_name=profile_name, |
| 232 | config_filename=config_file, |
| 233 | ) |
| 234 |
no outgoing calls