Skip to content

Commit

Permalink
tidy: dont double encode peer ID in tokens if same as key ID
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyzimmer committed Oct 20, 2023
1 parent 9bde5d2 commit a6cea23
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/metadata/id_token_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ func (i *IDTokenServer) issueToken(w http.ResponseWriter, r *http.Request) {
Expiry: jwt.NewNumericDate(Now().UTC().Add(5 * time.Minute)),
NotBefore: jwt.NewNumericDate(Now().UTC()),
IssuedAt: jwt.NewNumericDate(Now().UTC()),
ID: peerkey.ID(),
ID: func() string {
if info.Peer.GetId() == peerkey.ID() {
// Don't include the ID if it's the same as the subject.
// Saves space and makes it easier to read.
return ":subject"
}
return peerkey.ID()
}(),
},
Groups: []string{},
}
Expand Down

0 comments on commit a6cea23

Please sign in to comment.