AUTH-3537: AUDs in JWTs are now always arrays

This commit is contained in:
Michael Borkenstein 2021-05-10 12:24:45 -05:00 committed by Areg Harutyunyan
parent 75c3ca2f4a
commit bc54a7f87b
No known key found for this signature in database
GPG Key ID: 97A3DFFE8E9320B7
1 changed files with 4 additions and 9 deletions

View File

@ -46,7 +46,7 @@ type signalHandler struct {
signals []os.Signal signals []os.Signal
} }
type appJWTPayload struct { type jwtPayload struct {
Aud []string `json:"aud"` Aud []string `json:"aud"`
Email string `json:"email"` Email string `json:"email"`
Exp int `json:"exp"` Exp int `json:"exp"`
@ -57,17 +57,12 @@ type appJWTPayload struct {
Subt string `json:"sub"` Subt string `json:"sub"`
} }
type orgJWTPayload struct {
appJWTPayload
Aud string `json:"aud"`
}
type transferServiceResponse struct { type transferServiceResponse struct {
AppToken string `json:"app_token"` AppToken string `json:"app_token"`
OrgToken string `json:"org_token"` OrgToken string `json:"org_token"`
} }
func (p appJWTPayload) isExpired() bool { func (p jwtPayload) isExpired() bool {
return int(time.Now().Unix()) > p.Exp return int(time.Now().Unix()) > p.Exp
} }
@ -346,7 +341,7 @@ func GetOrgTokenIfExists(authDomain string) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
var payload orgJWTPayload var payload jwtPayload
err = json.Unmarshal(token.Payload, &payload) err = json.Unmarshal(token.Payload, &payload)
if err != nil { if err != nil {
return "", err return "", err
@ -368,7 +363,7 @@ func GetAppTokenIfExists(appInfo *AppInfo) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
var payload appJWTPayload var payload jwtPayload
err = json.Unmarshal(token.Payload, &payload) err = json.Unmarshal(token.Payload, &payload)
if err != nil { if err != nil {
return "", err return "", err