(workflowData *WorkflowData, workflowPermissions *Permissions)
| 223 | } |
| 224 | |
| 225 | func validateOIDCPermissions(workflowData *WorkflowData, workflowPermissions *Permissions) error { |
| 226 | if workflowData == nil { |
| 227 | return nil |
| 228 | } |
| 229 | |
| 230 | requiresIDTokenWrite := false |
| 231 | errorPrefix := "" |
| 232 | |
| 233 | if workflowData.EngineConfig != nil && workflowData.EngineConfig.Auth != nil && workflowData.EngineConfig.Auth.Type == "github-oidc" { |
| 234 | requiresIDTokenWrite = true |
| 235 | errorPrefix = "engine.auth.type: github-oidc" |
| 236 | } |
| 237 | |
| 238 | if !requiresIDTokenWrite && hasOTLPGitHubOIDCAuth(workflowData.ParsedFrontmatter, workflowData.RawFrontmatter) { |
| 239 | requiresIDTokenWrite = true |
| 240 | errorPrefix = "observability.otlp.github-app" |
| 241 | } |
| 242 | |
| 243 | if !requiresIDTokenWrite { |
| 244 | return nil |
| 245 | } |
| 246 | |
| 247 | if workflowPermissions == nil { |
| 248 | return errors.New(errorPrefix + " requires permissions.id-token: write") |
| 249 | } |
| 250 | |
| 251 | if level, exists := workflowPermissions.Get(PermissionIdToken); !exists || level != PermissionWrite { |
| 252 | return errors.New(errorPrefix + " requires permissions.id-token: write") |
| 253 | } |
| 254 | |
| 255 | return nil |
| 256 | } |
no test coverage detected