Changed RegisterOAuthClient to take audience string slice as arg

This commit is contained in:
David Allen 2024-02-27 00:00:29 -07:00
parent 76992c296a
commit c700020b04
No known key found for this signature in database
GPG key ID: 1D2A29322FBB6FCB
3 changed files with 20 additions and 5 deletions

View file

@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"net/http"
"reflect"
"time"
)
@ -191,7 +192,7 @@ func Login(config *Config) error {
// extract the subject from ID token claims
var subject string
var audience string
var audience []string
var idJsonPayload map[string]any
var idJwtPayload []byte = idJwtSegments[1]
if idJwtPayload != nil {
@ -200,7 +201,13 @@ func Login(config *Config) error {
return fmt.Errorf("failed to unmarshal JWT: %v", err)
}
subject = idJsonPayload["sub"].(string)
audience = idJsonPayload["aud"].(string)
audType := reflect.ValueOf(idJsonPayload["aud"])
switch audType.Kind() {
case reflect.String:
audience = append(audience, idJsonPayload["aud"].(string))
case reflect.Array:
audience = idJsonPayload["aud"].([]string)
}
} else {
return fmt.Errorf("failed to extract subject from ID token claims")
}