|
35 | 35 | // Deprecated: Use OIDSourceRepositoryRef |
36 | 36 | OIDGitHubWorkflowRef = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 57264, 1, 6} |
37 | 37 |
|
38 | | - OIDOtherName = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 57264, 1, 7} |
39 | | - OIDIssuerV2 = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 57264, 1, 8} |
| 38 | + OIDOtherName = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 57264, 1, 7} |
| 39 | + OIDIssuerV2 = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 57264, 1, 8} |
| 40 | + OIDTokenSubject = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 57264, 1, 24} |
40 | 41 |
|
41 | 42 | // CI extensions |
42 | 43 | OIDBuildSignerURI = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 57264, 1, 9} |
@@ -136,6 +137,9 @@ type Extensions struct { |
136 | 137 |
|
137 | 138 | // Deployment target for a workflow or job |
138 | 139 | DeploymentEnvironment string `json:"DeploymentEnvironment,omitempty" yaml:"deployment-environment,omitempty"` // 1.3.6.1.4.1.57264.1.23 |
| 140 | + |
| 141 | + // Raw OIDC token subject (`sub` claim). |
| 142 | + Subject string `json:"Subject,omitempty" yaml:"subject,omitempty"` // 1.3.6.1.4.1.57264.1.24 |
139 | 143 | } |
140 | 144 |
|
141 | 145 | func (e Extensions) Render() ([]pkix.Extension, error) { |
@@ -348,6 +352,16 @@ func (e Extensions) Render() ([]pkix.Extension, error) { |
348 | 352 | Value: val, |
349 | 353 | }) |
350 | 354 | } |
| 355 | + if e.Subject != "" { |
| 356 | + val, err := asn1.MarshalWithParams(e.Subject, "utf8") |
| 357 | + if err != nil { |
| 358 | + return nil, err |
| 359 | + } |
| 360 | + exts = append(exts, pkix.Extension{ |
| 361 | + Id: OIDTokenSubject, |
| 362 | + Value: val, |
| 363 | + }) |
| 364 | + } |
351 | 365 |
|
352 | 366 | return exts, nil |
353 | 367 | } |
@@ -435,6 +449,10 @@ func ParseExtensions(ext []pkix.Extension) (Extensions, error) { |
435 | 449 | if err := ParseDERString(e.Value, &out.DeploymentEnvironment); err != nil { |
436 | 450 | return Extensions{}, err |
437 | 451 | } |
| 452 | + case e.Id.Equal(OIDTokenSubject): |
| 453 | + if err := ParseDERString(e.Value, &out.Subject); err != nil { |
| 454 | + return Extensions{}, err |
| 455 | + } |
438 | 456 | } |
439 | 457 | } |
440 | 458 |
|
|
0 commit comments