Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): ignore padding for base64 url encoding #95

Merged
merged 4 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions protocol/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var testAttestationOptions = []string{
"user": {
"name": "self",
"displayName": "self",
"id": "2iEAAAAAAAAAAA"
"id": "2iEAAAAAAAAAAA=="
},
"pubKeyCredParams": [
{
Expand All @@ -116,7 +116,7 @@ var testAttestationOptions = []string{
"user": {
"name": "flort",
"displayName": "flort",
"id": "1DMAAAAAAAAAAA"
"id": "1DMAAAAAAAAAAA=="
},
"pubKeyCredParams": [
{
Expand All @@ -142,7 +142,7 @@ var testAttestationOptions = []string{
"user": {
"name": "testuser1",
"displayName": "testuser1",
"id": "1zMAAAAAAAAAAA"
"id": "1zMAAAAAAAAAAA=="
},
"pubKeyCredParams": [
{
Expand Down
5 changes: 5 additions & 0 deletions protocol/base64.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ func (e *URLEncodedBase64) UnmarshalJSON(data []byte) error {
return nil
}

// TODO: Investigate this line. It is commented as trimming the leading spaces but appears to trim the leading and trailing double quotes instead.
// Trim the leading spaces
data = bytes.Trim(data, "\"")

// Trim the trailing equal characters.
data = bytes.TrimRight(data, "=")

out := make([]byte, base64.RawURLEncoding.DecodedLen(len(data)))
n, err := base64.RawURLEncoding.Decode(out, data)
if err != nil {
Expand Down