From 29d69ca2e0eabe4c9e19c37bc48a0f3788ee661f Mon Sep 17 00:00:00 2001 From: "ORZ (Paul Orzel)" Date: Fri, 20 Jun 2025 09:39:40 +0200 Subject: [PATCH] add function to marshal aud into a string if the array has a len of 1, to comply with rfc --- pkg/oidc/types.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/oidc/types.go b/pkg/oidc/types.go index 33ad2d5..5d063b1 100644 --- a/pkg/oidc/types.go +++ b/pkg/oidc/types.go @@ -35,6 +35,17 @@ func (a *Audience) UnmarshalJSON(text []byte) error { return nil } +func (a *Audience) MarshalJSON() ([]byte, error) { + len := len(*a) + if len > 1 { + return json.Marshal(*a) + } else if len == 1 { + return json.Marshal((*a)[0]) + } + + return nil, errors.New("aud is empty") +} + type Display string func (d *Display) UnmarshalText(text []byte) error {