Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Fix userinfo metadata base64 encoding (#443)
Browse files Browse the repository at this point in the history
* Use grpc base64 encoding

Signed-off-by: Katrina Rogan <[email protected]>

* remove check for empty user info

Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan authored Jun 9, 2022
1 parent 8f78652 commit 0b9bf4e
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 58 deletions.
3 changes: 2 additions & 1 deletion auth/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const (
DefaultAuthorizationHeader = "authorization"
BearerScheme = "Bearer"
IDTokenScheme = "IDToken"
UserInfoMDKey = "UserInfo"
// Add the -bin suffix so that the header value is automatically base64 encoded
UserInfoMDKey = "UserInfo-bin"

// https://tools.ietf.org/html/rfc8414
// This should be defined without a leading slash. If there is one, the url library's ResolveReference will make it a root path
Expand Down
22 changes: 0 additions & 22 deletions auth/encoding_utils.go

This file was deleted.

31 changes: 0 additions & 31 deletions auth/encoding_utils_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion auth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func GetHTTPRequestCookieToMetadataHandler(authCtx interfaces.AuthenticationCont
}

if len(raw) > 0 {
meta.Set(UserInfoMDKey, EncodeBase64(raw))
meta.Set(UserInfoMDKey, string(raw))
}

return meta
Expand Down
1 change: 0 additions & 1 deletion auth/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ func TestGetHTTPRequestCookieToMetadataHandler(t *testing.T) {
req.AddCookie(&idCookie)

assert.Equal(t, "IDToken a.b.c", handler(ctx, req)["authorization"][0])
assert.Equal(t, "bnVsbA", handler(ctx, req).Get(UserInfoMDKey)[0])
}

func TestGetHTTPMetadataTaggingHandler(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions auth/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ func GRPCGetIdentityFromIDToken(ctx context.Context, clientID string, provider *
}

meta := metautils.ExtractIncoming(ctx)
userInfoDecoded, _ := DecodeFromBase64(meta.Get(UserInfoMDKey))
userInfoDecoded := meta.Get(UserInfoMDKey)
userInfo := &service.UserInfoResponse{}
if len(userInfoDecoded) > 0 {
err = json.Unmarshal(userInfoDecoded, userInfo)
err = json.Unmarshal([]byte(userInfoDecoded), userInfo)
if err != nil {
logger.Infof(ctx, "Could not unmarshal user info from metadata %v", err)
}
Expand Down

0 comments on commit 0b9bf4e

Please sign in to comment.