Skip to content

Commit f11344b

Browse files
Revert "CiProvider as a new OIDCIssuer type (#1679)" (#1727)
This reverts commit 66485b6.
1 parent d16be8d commit f11344b

File tree

11 files changed

+22
-1041
lines changed

11 files changed

+22
-1041
lines changed

pkg/certificate/extensions.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,69 +69,69 @@ type Extensions struct {
6969
// Deprecated
7070
// Triggering event of the Github Workflow. Matches the `event_name` claim of ID
7171
// tokens from Github Actions
72-
GithubWorkflowTrigger string `json:"GithubWorkflowTrigger,omitempty" yaml:"github-workflow-trigger,omitempty"` // OID 1.3.6.1.4.1.57264.1.2
72+
GithubWorkflowTrigger string // OID 1.3.6.1.4.1.57264.1.2
7373

7474
// Deprecated
7575
// SHA of git commit being built in Github Actions. Matches the `sha` claim of ID
7676
// tokens from Github Actions
77-
GithubWorkflowSHA string `json:"GithubWorkflowSHA,omitempty" yaml:"github-workflow-sha,omitempty"` // OID 1.3.6.1.4.1.57264.1.3
77+
GithubWorkflowSHA string // OID 1.3.6.1.4.1.57264.1.3
7878

7979
// Deprecated
8080
// Name of Github Actions Workflow. Matches the `workflow` claim of the ID
8181
// tokens from Github Actions
82-
GithubWorkflowName string `json:"GithubWorkflowName,omitempty" yaml:"github-workflow-name,omitempty"` // OID 1.3.6.1.4.1.57264.1.4
82+
GithubWorkflowName string // OID 1.3.6.1.4.1.57264.1.4
8383

8484
// Deprecated
8585
// Repository of the Github Actions Workflow. Matches the `repository` claim of the ID
8686
// tokens from Github Actions
87-
GithubWorkflowRepository string `json:"GithubWorkflowRepository,omitempty" yaml:"github-workflow-repository,omitempty"` // OID 1.3.6.1.4.1.57264.1.5
87+
GithubWorkflowRepository string // OID 1.3.6.1.4.1.57264.1.5
8888

8989
// Deprecated
9090
// Git Ref of the Github Actions Workflow. Matches the `ref` claim of the ID tokens
9191
// from Github Actions
92-
GithubWorkflowRef string `json:"GithubWorkflowRef,omitempty" yaml:"github-workflow-ref,omitempty"` // 1.3.6.1.4.1.57264.1.6
92+
GithubWorkflowRef string // 1.3.6.1.4.1.57264.1.6
9393

9494
// Reference to specific build instructions that are responsible for signing.
95-
BuildSignerURI string `json:"BuildSignerURI,omitempty" yaml:"build-signer-uri,omitempty"` // 1.3.6.1.4.1.57264.1.9
95+
BuildSignerURI string // 1.3.6.1.4.1.57264.1.9
9696

9797
// Immutable reference to the specific version of the build instructions that is responsible for signing.
98-
BuildSignerDigest string `json:"BuildSignerDigest,omitempty" yaml:"build-signer-digest,omitempty"` // 1.3.6.1.4.1.57264.1.10
98+
BuildSignerDigest string // 1.3.6.1.4.1.57264.1.10
9999

100100
// Specifies whether the build took place in platform-hosted cloud infrastructure or customer/self-hosted infrastructure.
101-
RunnerEnvironment string `json:"RunnerEnvironment,omitempty" yaml:"runner-environment,omitempty"` // 1.3.6.1.4.1.57264.1.11
101+
RunnerEnvironment string // 1.3.6.1.4.1.57264.1.11
102102

103103
// Source repository URL that the build was based on.
104-
SourceRepositoryURI string `json:"SourceRepositoryURI,omitempty" yaml:"source-repository-uri,omitempty"` // 1.3.6.1.4.1.57264.1.12
104+
SourceRepositoryURI string // 1.3.6.1.4.1.57264.1.12
105105

106106
// Immutable reference to a specific version of the source code that the build was based upon.
107-
SourceRepositoryDigest string `json:"SourceRepositoryDigest,omitempty" yaml:"source-repository-digest,omitempty"` // 1.3.6.1.4.1.57264.1.13
107+
SourceRepositoryDigest string // 1.3.6.1.4.1.57264.1.13
108108

109109
// Source Repository Ref that the build run was based upon.
110-
SourceRepositoryRef string `json:"SourceRepositoryRef,omitempty" yaml:"source-repository-ref,omitempty"` // 1.3.6.1.4.1.57264.1.14
110+
SourceRepositoryRef string // 1.3.6.1.4.1.57264.1.14
111111

112112
// Immutable identifier for the source repository the workflow was based upon.
113-
SourceRepositoryIdentifier string `json:"SourceRepositoryIdentifier,omitempty" yaml:"source-repository-identifier,omitempty"` // 1.3.6.1.4.1.57264.1.15
113+
SourceRepositoryIdentifier string // 1.3.6.1.4.1.57264.1.15
114114

115115
// Source repository owner URL of the owner of the source repository that the build was based on.
116-
SourceRepositoryOwnerURI string `json:"SourceRepositoryOwnerURI,omitempty" yaml:"source-repository-owner-uri,omitempty"` // 1.3.6.1.4.1.57264.1.16
116+
SourceRepositoryOwnerURI string // 1.3.6.1.4.1.57264.1.16
117117

118118
// Immutable identifier for the owner of the source repository that the workflow was based upon.
119-
SourceRepositoryOwnerIdentifier string `json:"SourceRepositoryOwnerIdentifier,omitempty" yaml:"source-repository-owner-identifier,omitempty"` // 1.3.6.1.4.1.57264.1.17
119+
SourceRepositoryOwnerIdentifier string // 1.3.6.1.4.1.57264.1.17
120120

121121
// Build Config URL to the top-level/initiating build instructions.
122-
BuildConfigURI string `json:"BuildConfigURI,omitempty" yaml:"build-config-uri,omitempty"` // 1.3.6.1.4.1.57264.1.18
122+
BuildConfigURI string // 1.3.6.1.4.1.57264.1.18
123123

124124
// Immutable reference to the specific version of the top-level/initiating build instructions.
125-
BuildConfigDigest string `json:"BuildConfigDigest,omitempty" yaml:"build-config-digest,omitempty"` // 1.3.6.1.4.1.57264.1.19
125+
BuildConfigDigest string // 1.3.6.1.4.1.57264.1.19
126126

127127
// Event or action that initiated the build.
128-
BuildTrigger string `json:"BuildTrigger,omitempty" yaml:"build-trigger,omitempty"` // 1.3.6.1.4.1.57264.1.20
128+
BuildTrigger string // 1.3.6.1.4.1.57264.1.20
129129

130130
// Run Invocation URL to uniquely identify the build execution.
131-
RunInvocationURI string `json:"RunInvocationURI,omitempty" yaml:"run-invocation-uri,omitempty"` // 1.3.6.1.4.1.57264.1.21
131+
RunInvocationURI string // 1.3.6.1.4.1.57264.1.21
132132

133133
// Source repository visibility at the time of signing the certificate.
134-
SourceRepositoryVisibilityAtSigning string `json:"SourceRepositoryVisibilityAtSigning,omitempty" yaml:"source-repository-visibility-at-signing,omitempty"` // 1.3.6.1.4.1.57264.1.22
134+
SourceRepositoryVisibilityAtSigning string // 1.3.6.1.4.1.57264.1.22
135135
}
136136

137137
func (e Extensions) Render() ([]pkix.Extension, error) {

pkg/challenges/challenges.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/sigstore/fulcio/pkg/config"
2828
"github.com/sigstore/fulcio/pkg/identity"
2929
"github.com/sigstore/fulcio/pkg/identity/buildkite"
30-
"github.com/sigstore/fulcio/pkg/identity/ciprovider"
3130
"github.com/sigstore/fulcio/pkg/identity/email"
3231
"github.com/sigstore/fulcio/pkg/identity/github"
3332
"github.com/sigstore/fulcio/pkg/identity/gitlabcom"
@@ -76,8 +75,6 @@ func PrincipalFromIDToken(ctx context.Context, tok *oidc.IDToken) (identity.Prin
7675
principal, err = uri.PrincipalFromIDToken(ctx, tok)
7776
case config.IssuerTypeUsername:
7877
principal, err = username.PrincipalFromIDToken(ctx, tok)
79-
case config.IssuerTypeCIProvider:
80-
principal, err = ciprovider.WorkflowPrincipalFromIDToken(ctx, tok)
8178
default:
8279
return nil, fmt.Errorf("unsupported issuer: %s", iss.Type)
8380
}

pkg/config/config.go

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"encoding/json"
2222
"errors"
2323
"fmt"
24-
"html/template"
2524
"net/http"
2625
"net/url"
2726
"os"
@@ -32,7 +31,6 @@ import (
3231

3332
"github.com/coreos/go-oidc/v3/oidc"
3433
lru "github.com/hashicorp/golang-lru"
35-
"github.com/sigstore/fulcio/pkg/certificate"
3634
fulciogrpc "github.com/sigstore/fulcio/pkg/generated/protobuf"
3735
"github.com/sigstore/fulcio/pkg/log"
3836
"github.com/spiffe/go-spiffe/v2/spiffeid"
@@ -62,33 +60,12 @@ type FulcioConfig struct {
6260
// * https://container.googleapis.com/v1/projects/mattmoor-credit/locations/us-west1-b/clusters/tenant-cluster
6361
MetaIssuers map[string]OIDCIssuer `json:"MetaIssuers,omitempty" yaml:"meta-issuers,omitempty"`
6462

65-
// It defines metadata to be used for the CIProvider identity provider principal.
66-
// The CI provider has a generic logic for ci providers, this metadata is used
67-
// to define the right behavior for each ci provider that is defined
68-
// on the configuration file
69-
CIIssuerMetadata map[string]IssuerMetadata `json:"CIIssuerMetadata,omitempty" yaml:"ci-issuer-metadata,omitempty"`
70-
7163
// verifiers is a fixed mapping from our OIDCIssuers to their OIDC verifiers.
7264
verifiers map[string][]*verifierWithConfig
7365
// lru is an LRU cache of recently used verifiers for our meta issuers.
7466
lru *lru.TwoQueueCache
7567
}
7668

77-
type IssuerMetadata struct {
78-
// Defaults contains key-value pairs that can be used for filling the templates from ExtensionTemplates
79-
// If a key cannot be found on the token claims, the template will use the defaults
80-
DefaultTemplateValues map[string]string `json:"DefaultTemplateValues,omitempty" yaml:"default-template-values,omitempty"`
81-
// ExtensionTemplates contains a mapping between certificate extension and token claim
82-
// Provide either strings following https://pkg.go.dev/text/template syntax,
83-
// e.g "{{ .url }}/{{ .repository }}"
84-
// or non-templated strings with token claim keys to be replaced,
85-
// e.g "job_workflow_sha"
86-
ExtensionTemplates certificate.Extensions `json:"ExtensionTemplates,omitempty" yaml:"extension-templates,omitempty"`
87-
// Template for the Subject Alternative Name extension
88-
// It's typically the same value as Build Signer URI
89-
SubjectAlternativeNameTemplate string `json:"SubjectAlternativeNameTemplate,omitempty" yaml:"subject-alternative-name-template,omitempty"`
90-
}
91-
9269
type OIDCIssuer struct {
9370
// The expected issuer of an OIDC token
9471
IssuerURL string `json:"IssuerURL,omitempty" yaml:"issuer-url,omitempty"`
@@ -97,8 +74,6 @@ type OIDCIssuer struct {
9774
// Used to determine the subject of the certificate and if additional
9875
// certificate values are needed
9976
Type IssuerType `json:"Type" yaml:"type,omitempty"`
100-
// CIProvider is an optional configuration to map token claims to extensions for CI workflows
101-
CIProvider string `json:"CIProvider,omitempty" yaml:"ci-provider,omitempty"`
10277
// Optional, if the issuer is in a different claim in the OIDC token
10378
IssuerClaim string `json:"IssuerClaim,omitempty" yaml:"issuer-claim,omitempty"`
10479
// The domain that must be present in the subject for 'uri' issuer types
@@ -309,7 +284,6 @@ const (
309284
IssuerTypeSpiffe = "spiffe"
310285
IssuerTypeURI = "uri"
311286
IssuerTypeUsername = "username"
312-
IssuerTypeCIProvider = "ci-provider"
313287
)
314288

315289
func parseConfig(b []byte) (cfg *FulcioConfig, err error) {
@@ -417,7 +391,7 @@ func validateConfig(conf *FulcioConfig) error {
417391
}
418392
}
419393

420-
return validateCIIssuerMetadata(conf)
394+
return nil
421395
}
422396

423397
var DefaultConfig = &FulcioConfig{
@@ -458,34 +432,6 @@ func FromContext(ctx context.Context) *FulcioConfig {
458432
return untyped.(*FulcioConfig)
459433
}
460434

461-
// It checks that the templates defined are parseable
462-
// We should check it during the service bootstrap to avoid errors further
463-
func validateCIIssuerMetadata(fulcioConfig *FulcioConfig) error {
464-
465-
checkParse := func(temp string) error {
466-
t := template.New("").Option("missingkey=error")
467-
_, err := t.Parse(temp)
468-
return err
469-
}
470-
471-
for _, ciIssuerMetadata := range fulcioConfig.CIIssuerMetadata {
472-
v := reflect.ValueOf(ciIssuerMetadata.ExtensionTemplates)
473-
for i := 0; i < v.NumField(); i++ {
474-
s := v.Field(i).String()
475-
err := checkParse(s)
476-
if err != nil {
477-
return err
478-
}
479-
}
480-
481-
err := checkParse(ciIssuerMetadata.SubjectAlternativeNameTemplate)
482-
if err != nil {
483-
return err
484-
}
485-
}
486-
return nil
487-
}
488-
489435
// Load a config from disk, or use defaults
490436
func Load(configPath string) (*FulcioConfig, error) {
491437
if _, err := os.Stat(configPath); os.IsNotExist(err) {
@@ -570,8 +516,6 @@ func issuerToChallengeClaim(issType IssuerType, challengeClaim string) string {
570516
return "email"
571517
case IssuerTypeGithubWorkflow:
572518
return "sub"
573-
case IssuerTypeCIProvider:
574-
return "sub"
575519
case IssuerTypeCodefreshWorkflow:
576520
return "sub"
577521
case IssuerTypeChainguard:

pkg/config/config_network_test.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"github.com/google/go-cmp/cmp"
2727
"github.com/google/go-cmp/cmp/cmpopts"
28-
"github.com/sigstore/fulcio/pkg/certificate"
2928
)
3029

3130
func TestLoad(t *testing.T) {
@@ -69,61 +68,6 @@ func TestLoad(t *testing.T) {
6968
}
7069
}
7170

72-
func TestParseTemplate(t *testing.T) {
73-
74-
validTemplate := "{{.foobar}}"
75-
invalidTemplate := "{{.foobar}"
76-
ciissuerMetadata := make(map[string]IssuerMetadata)
77-
ciissuerMetadata["github"] = IssuerMetadata{
78-
ExtensionTemplates: certificate.Extensions{
79-
BuildTrigger: invalidTemplate,
80-
},
81-
}
82-
fulcioConfig := &FulcioConfig{
83-
CIIssuerMetadata: ciissuerMetadata,
84-
}
85-
// BuildTrigger as a invalid template should raise an error
86-
err := validateCIIssuerMetadata(fulcioConfig)
87-
if err == nil {
88-
t.Error("invalid template should raise an error")
89-
}
90-
ciissuerMetadata["github"] = IssuerMetadata{
91-
ExtensionTemplates: certificate.Extensions{
92-
BuildTrigger: validTemplate,
93-
},
94-
}
95-
fulcioConfig = &FulcioConfig{
96-
CIIssuerMetadata: ciissuerMetadata,
97-
}
98-
// BuildTrigger as a valid template shouldn't raise an error
99-
err = validateCIIssuerMetadata(fulcioConfig)
100-
if err != nil {
101-
t.Error("valid template shouldn't raise an error, error: %w", err)
102-
}
103-
ciissuerMetadata["github"] = IssuerMetadata{
104-
SubjectAlternativeNameTemplate: invalidTemplate,
105-
}
106-
fulcioConfig = &FulcioConfig{
107-
CIIssuerMetadata: ciissuerMetadata,
108-
}
109-
// A SAN as a invalid template should raise an error
110-
err = validateCIIssuerMetadata(fulcioConfig)
111-
if err == nil {
112-
t.Error("invalid SAN should raise an error")
113-
}
114-
ciissuerMetadata["github"] = IssuerMetadata{
115-
SubjectAlternativeNameTemplate: invalidTemplate,
116-
}
117-
fulcioConfig = &FulcioConfig{
118-
CIIssuerMetadata: ciissuerMetadata,
119-
}
120-
// A SAN as a valid template should raise an error
121-
err = validateCIIssuerMetadata(fulcioConfig)
122-
if err == nil {
123-
t.Error("valid SAN shouldn't raise an error")
124-
}
125-
}
126-
12771
func TestLoadDefaults(t *testing.T) {
12872
td := t.TempDir()
12973

pkg/config/config_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,6 @@ func Test_issuerToChallengeClaim(t *testing.T) {
492492
if claim := issuerToChallengeClaim(IssuerTypeGithubWorkflow, ""); claim != "sub" {
493493
t.Fatalf("expected sub subject claim for GitHub issuer, got %s", claim)
494494
}
495-
if claim := issuerToChallengeClaim(IssuerTypeCIProvider, ""); claim != "sub" {
496-
t.Fatalf("expected sub subject claim for CI issuer, got %s", claim)
497-
}
498495
if claim := issuerToChallengeClaim(IssuerTypeGitLabPipeline, ""); claim != "sub" {
499496
t.Fatalf("expected sub subject claim for GitLab issuer, got %s", claim)
500497
}

pkg/identity/ciprovider/issuer.go

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)