Skip to content

Commit

Permalink
Print GITHUB_URL taken from the oidc token issuer (#11747)
Browse files Browse the repository at this point in the history
* Pass repository URL as ADO parameter

* Fix unit tests

* Fix unit tests

* Setenv GITHUB_URL based on the oidc token issuer

* Revert "Fix unit tests"

This reverts commit addad01.

* Revert "Fix unit tests"

This reverts commit ea1a8f4.

* Revert "Pass repository URL as ADO parameter"

This reverts commit d97f002.

* receiver name tokenProcessor should be consistent with previous receiver name t for TokenProcessor

* print ADO githubURL variable

* Setenv GITHUB_URL based on the oidc token issuer

* don't print ADO githubURL variable

* Set GITHUB_URL to github.com

* setvariable githubUrl to github.com

* setvariable githubUrl to github.com

* Add one more print statement

* Print GITHUB_URL=https://github.com

* Use Printf instead of Println

* Revert the code used for not e2e tests
  • Loading branch information
Sawthis authored Sep 5, 2024
1 parent ebf9152 commit 74a3e27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/oidc-token-verifier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func (opts *options) extractClaims() error {
return err
}
logger.Infow("Token processor created for trusted issuer", "issuer", tokenProcessor.Issuer())
fmt.Printf("GITHUB_URL=%s\n", tokenProcessor.GetIssuer().GetGithubURL())

ctx := context.Background()
// Create a new provider using OIDC discovery to get the public keys.
Expand Down
11 changes: 11 additions & 0 deletions pkg/oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ var (
IssuerURL: "https://token.actions.githubusercontent.com",
JWKSURL: "https://token.actions.githubusercontent.com/.well-known/jwks",
ExpectedJobWorkflowRef: "kyma-project/test-infra/.github/workflows/image-builder.yml@refs/heads/main",
GithubURL: "https://github.com",
}
GithubToolsSAPOIDCIssuer = Issuer{
Name: "github-tools-sap",
IssuerURL: "https://github.tools.sap/_services/token",
JWKSURL: "https://github.tools.sap/_services/token/.well-known/jwks",
ExpectedJobWorkflowRef: "kyma/test-infra/.github/workflows/image-builder.yml@refs/heads/main",
GithubURL: "https://github.tools.sap",
}
TrustedOIDCIssuers = map[string]Issuer{GithubOIDCIssuer.IssuerURL: GithubOIDCIssuer, GithubToolsSAPOIDCIssuer.IssuerURL: GithubToolsSAPOIDCIssuer}
)
Expand Down Expand Up @@ -79,6 +81,11 @@ type Issuer struct {
IssuerURL string `json:"issuer_url" yaml:"issuer_url"`
JWKSURL string `json:"jwks_url" yaml:"jwks_url"`
ExpectedJobWorkflowRef string `json:"expected_job_workflow_ref" yaml:"expected_job_workflow_ref"`
GithubURL string `json:"github_url" yaml:"github_url"`
}

func (i Issuer) GetGithubURL() string {
return i.GithubURL
}

// VerifierConfig is the configuration for a verifier.
Expand All @@ -96,6 +103,10 @@ type TokenProcessor struct {
logger LoggerInterface
}

func (tokenProcessor *TokenProcessor) GetIssuer() Issuer {
return tokenProcessor.issuer
}

// TokenProcessorOption is a function that modifies the TokenProcessor.
type TokenProcessorOption func(*TokenProcessor) error

Expand Down

0 comments on commit 74a3e27

Please sign in to comment.