Skip to content

Commit

Permalink
fix: Use gitlab's CI_SERVER_URL to build jwks url
Browse files Browse the repository at this point in the history
Previously the gitlab attestor had the JWKS url hard-coded to the public
instance's jwks url.  This uses the provided CI_SERVER_URL to build up
the jwks url instead.

Signed-off-by: Mikhail Swift <mikhail@testifysec.com>
  • Loading branch information
mikhailswift committed Jun 1, 2022
1 parent c59280e commit a2ea846
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions attestation/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const (
Name = "gitlab"
Type = "https://witness.dev/attestations/gitlab/v0.1"
RunType = attestation.PreRunType

jwksUrl = "https://gitlab.com/-/jwks"
)

func init() {
Expand Down Expand Up @@ -57,6 +55,7 @@ type Attestor struct {
ProjectUrl string `json:"projecturl"`
RunnerID string `json:"runnerid"`
CIHost string `json:"cihost"`
CIServerUrl string `json:"ciserverurl"`

subjects map[string]cryptoutil.DigestSet
}
Expand Down Expand Up @@ -84,6 +83,8 @@ func (a *Attestor) Attest(ctx *attestation.AttestationContext) error {
return ErrNotGitlab{}
}

a.CIServerUrl = os.Getenv("CI_SERVER_URL")
jwksUrl := fmt.Sprintf("%s/-/jwks", a.CIServerUrl)
jwtString := os.Getenv("CI_JOB_JWT")
if jwtString != "" {
a.JWT = jwt.New(jwt.WithToken(jwtString), jwt.WithJWKSUrl(jwksUrl))
Expand Down

0 comments on commit a2ea846

Please sign in to comment.