Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion protocol/task_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ type TaskAgents struct {
func (taskAgent *TaskAgent) Authorize(c *http.Client, key interface{}) (*VssOAuthTokenResponse, error) {
tokenresp := &VssOAuthTokenResponse{}
now := time.Now().UTC().Add(-30 * time.Second)
token2 := jwt.NewWithClaims(jwt.SigningMethodRS256, jwt.StandardClaims{
var method jwt.SigningMethod = jwt.SigningMethodRS256
requireFipsCryptography, hasRequireFipsCryptography := taskAgent.Properties.LookupBool("RequireFipsCryptography")
serverV2URL, _ := taskAgent.Properties.LookupString("ServerUrlV2")
if requireFipsCryptography && hasRequireFipsCryptography || serverV2URL != "" {
method = jwt.SigningMethodPS256
}
token2 := jwt.NewWithClaims(method, jwt.StandardClaims{
Subject: taskAgent.Authorization.ClientID,
Issuer: taskAgent.Authorization.ClientID,
Id: uuid.New().String(),
Expand Down
15 changes: 13 additions & 2 deletions runnerconfiguration/compat/actions_runner_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ type DotnetCredentials struct {
}

type DotnetCredentialsData struct {
ClientID string `json:"ClientId"`
AuthorizationURL string `json:"AuthorizationUrl"`
ClientID string `json:"ClientId"`
AuthorizationURL string `json:"AuthorizationUrl"`
RequireFipsCryptography bool `json:"RequireFipsCryptography"`
}

func BytesToBigInt(bytes []byte) *big.Int {
Expand Down Expand Up @@ -159,6 +160,12 @@ func ToRunnerInstance(fileAccess ConfigFileAccess) (*runnerconfiguration.RunnerI
Value: agent.UseV2Flow,
}
}
if credentials.Data.RequireFipsCryptography {
props["RequireFipsCryptography"] = protocol.PropertyValue{
Type: "System.Boolean",
Value: credentials.Data.RequireFipsCryptography,
}
}

return &runnerconfiguration.RunnerInstance{
PoolID: poolID,
Expand Down Expand Up @@ -208,11 +215,15 @@ func FromRunnerInstance(instance *runnerconfiguration.RunnerInstance, fileAccess
if agent.WorkFolder == "" {
agent.WorkFolder = "_work"
}
requireFipsCryptography, hasRequireFipsCryptography := instance.Agent.Properties.LookupBool("RequireFipsCryptography")
credentials := &DotnetCredentials{
Scheme: "OAuth",
Data: DotnetCredentialsData{
ClientID: instance.Agent.Authorization.ClientID,
AuthorizationURL: instance.Agent.Authorization.AuthorizationURL,
// serverV2URL != "" means recent GitHub Server that requires recent actions/runner
// that has received this bugfix https://github.com/actions/runner/pull/3789
RequireFipsCryptography: requireFipsCryptography && hasRequireFipsCryptography || serverV2URL != "",
},
}
if err := fileAccess.Write(".runner", agent); err != nil {
Expand Down
Loading