-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refresh GH action ID token during pipeline runs (#1214)
* refresh GH action ID token during pipeline runs mitigation for Azure/azure-cli#28708 Signed-off-by: Gerd Oberlechner <[email protected]> * provide env vars to gh actions Signed-off-by: Gerd Oberlechner <[email protected]> * timeout handling Signed-off-by: Gerd Oberlechner <[email protected]> --------- Signed-off-by: Gerd Oberlechner <[email protected]>
- Loading branch information
Showing
14 changed files
with
207 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package azauth | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/Azure/azure-sdk-for-go/sdk/azcore" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | ||
) | ||
|
||
func SetupAzureAuth(ctx context.Context) error { | ||
if githubAuthSupported() { | ||
err := setupGithubAzureFederationAuthRefresher(ctx) | ||
if err != nil { | ||
return fmt.Errorf("failed to setup GitHub Azure Federation Auth Refresher: %w", err) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func GetAzureTokenCredentials() (azcore.TokenCredential, error) { | ||
azCLI, err := azidentity.NewAzureCLICredential(nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
def, err := azidentity.NewDefaultAzureCredential(nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
chain, err := azidentity.NewChainedTokenCredential([]azcore.TokenCredential{azCLI, def}, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return chain, nil | ||
} |
Oops, something went wrong.