Repository: zitadel/oidc (go)

Issue:
[bug]: missing client_id claim in access token JWT
### Discussed in https://github.com/zitadel/oidc/discussions/646

<div type='discussions-op-text'>

<sup>Originally posted by **duizabojul** September  4, 2024</sup>
id_token got these claims but not access_token? Is there a reason for this? [RFC tells client_id is required in access token](https://datatracker.ietf.org/doc/html/rfc9068#name-data-structure).</div>

Pull request description:
fix(oidc): set client ID to access token JWT
RFC 9068: JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens, section 2.2. https://datatracker.ietf.org/doc/html/rfc9068#name-data-structure defines `client_id` as a required claim. This fix sets the claim in the `NewAccessTokenClaims` function.

Closes #649

### Definition of Ready

- [x] I am happy with the code
- [x] Short description of the feature/issue is added in the pr description
- [x] PR is linked to the corresponding user story
- [x] Acceptance criteria are met
- [x] All open todos and follow ups are defined in a new ticket and justified
- [x] Deviations from the acceptance criteria and design are agreed with the PO and documented.
- [x] No debug or dead code
- [x] My code has no repetitions
- [x] Critical parts are tested automatically
- [x] Where possible E2E tests are implemented
- [x] Documentation/examples are up-to-date
- [x] All non-functional requirements are met
- [x] Functionality of the acceptance criteria is checked manually on the dev system.



Patch:
diff --git a/pkg/oidc/token.go b/pkg/oidc/token.go
index 5b18dac..a829df4 100644
--- a/pkg/oidc/token.go
+++ b/pkg/oidc/token.go
@@ -117,6 +117,7 @@ func NewAccessTokenClaims(issuer, subject string, audience []string, expiration
 			Expiration: FromTime(expiration),
 			IssuedAt:   FromTime(now),
 			NotBefore:  FromTime(now),
+			ClientID:   clientID,
 			JWTID:      jwtid,
 		},
 	}


Test patch:
diff --git a/pkg/oidc/token_test.go b/pkg/oidc/token_test.go
index ccc3467..7847cb5 100644
--- a/pkg/oidc/token_test.go
+++ b/pkg/oidc/token_test.go
@@ -145,6 +145,7 @@ func TestNewAccessTokenClaims(t *testing.T) {
 			Subject:    "hello@me.com",
 			Audience:   Audience{"foo"},
 			Expiration: 12345,
+			ClientID:   "foo",
 			JWTID:      "900",
 		},
 	}