@@ -66,7 +66,8 @@ async function main(): Promise<void> {
6666
6767 const tokenAuthInfo = serviceConnection as TokenServiceConnection ;
6868 tl . debug ( `Detected token credentials for '${ serviceConnection . packageSource . uri } '` ) ;
69- tl . setVariable ( "CARGO_REGISTRY_TOKEN" , tokenAuthInfo . token )
69+ tl . setVariable ( "CARGO_REGISTRY_TOKEN" , tokenAuthInfo . token ) ;
70+ tl . setVariable ( "CARGO_REGISTRY_CREDENTIAL_PROVIDER" , "cargo:token" ) ;
7071 break ;
7172 default :
7273 throw Error ( tl . loc ( 'Error_InvalidServiceConnection' , serviceConnection . packageSource . uri ) ) ;
@@ -75,7 +76,9 @@ async function main(): Promise<void> {
7576
7677 for ( let registry of Object . keys ( result . registries ) ) {
7778 const registryUrl = url . parse ( result . registries [ registry ] . index ) ;
78- let tokenName = `CARGO_REGISTRIES_${ registry . toLocaleUpperCase ( ) . replace ( / - / g, "_" ) } _TOKEN` ;
79+ const registryConfigName = registry . toLocaleUpperCase ( ) . replace ( / - / g, "_" ) ;
80+ const tokenName = `CARGO_REGISTRIES_${ registryConfigName } _TOKEN` ;
81+ const credProviderName = `CARGO_REGISTRIES_${ registryConfigName } _CREDENTIAL_PROVIDER` ;
7982 if ( registryUrl && registryUrl . host && collectionHosts . indexOf ( registryUrl . host . toLowerCase ( ) ) >= 0 ) {
8083 let currentRegistry : string ;
8184 for ( let serviceConnection of externalServiceConnections ) {
@@ -85,12 +88,14 @@ async function main(): Promise<void> {
8588 tl . debug ( `Detected username/password or PAT credentials for '${ serviceConnection . packageSource . uri } '` ) ;
8689 tl . debug ( tl . loc ( 'AddingAuthExternalRegistry' , registry , tokenName ) ) ;
8790 tl . setVariable ( tokenName , `Basic ${ base64 . encode ( utf8 . encode ( `${ usernamePasswordAuthInfo . username } :${ usernamePasswordAuthInfo . password } ` ) ) } ` ) ;
91+ tl . setVariable ( credProviderName , "cargo:token" ) ;
8892 }
8993 }
9094 // Default to internal registry if no token has been set yet
9195 if ( ! currentRegistry ) {
9296 tl . debug ( tl . loc ( 'AddingAuthRegistry' , registry , tokenName ) ) ;
9397 tl . setVariable ( tokenName , localAccesstoken ) ;
98+ tl . setVariable ( credProviderName , "cargo:token" ) ;
9499 }
95100 }
96101 }
0 commit comments