@@ -409,33 +409,20 @@ func getConfigProviders(d *schema.ResourceData, auth string) ([]oci_common.Confi
409409
410410 configProviders = append (configProviders , cfg )
411411 case strings .ToLower (globalvar .AuthSecurityToken ):
412- _ , ok := utils .CheckIncompatibleAttrsForApiKeyAuth (d , ApiKeyConfigAttributes )
413- if ! ok {
414- log .Printf ("[DEBUG] Ignoring all user credentials for %v authentication" , auth )
415- }
416-
417- region , ok := d .GetOk (globalvar .RegionAttrName )
418- if ! ok {
419- return nil , fmt .Errorf ("can not get %s from Terraform configuration (SecurityToken)" , globalvar .RegionAttrName )
420- }
421- // if region is part of the provider block make sure it is part of the final configuration too, and overwrites the region in the profile. +
422- regionProvider := oci_common .NewRawConfigurationProvider ("" , "" , region .(string ), "" , "" , nil )
423- configProviders = append (configProviders , regionProvider )
424-
425412 profile , ok := d .GetOk (globalvar .ConfigFileProfileAttrName )
426413 if ! ok {
427414 return nil , fmt .Errorf ("missing profile in provider block %v" , globalvar .ConfigFileProfileAttrName )
428415 }
416+ privateKeyPassword := d .Get (globalvar .PrivateKeyPasswordAttrName )
417+ privateKeyPasswordString := privateKeyPassword .(string )
429418 profileString := profile .(string )
430419 defaultPath := path .Join (utils .GetHomeFolder (), globalvar .DefaultConfigDirName , globalvar .DefaultConfigFileName )
431420 if err := utils .CheckProfile (profileString , defaultPath ); err != nil {
432421 return nil , err
433422 }
434- securityTokenBasedAuthConfigProvider := oci_common .CustomProfileConfigProvider (defaultPath , profileString )
435-
436- keyId , err := securityTokenBasedAuthConfigProvider .KeyID ()
437- if err != nil || ! strings .HasPrefix (keyId , "ST$" ) {
438- return nil , fmt .Errorf ("Security token is invalid " )
423+ securityTokenBasedAuthConfigProvider , err := oci_common .ConfigurationProviderForSessionTokenWithProfile (defaultPath , profileString , privateKeyPasswordString )
424+ if err != nil {
425+ return nil , fmt .Errorf ("could not create security token based auth config provider %v" , err )
439426 }
440427 configProviders = append (configProviders , securityTokenBasedAuthConfigProvider )
441428 case strings .ToLower (globalvar .ResourcePrincipal ):
0 commit comments