This repository has been archived by the owner on May 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 996
Fix sec vuln with list of claims #426
Closed
Waterdrips
wants to merge
6
commits into
dgrijalva:master
from
Waterdrips:waterdrips-fix-security-vuln
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a2443ed
[skip ci] Adding CODEOWNERS file
jeeves-form3 91a8377
Merge pull request #1 from form3tech-oss/terraform-provider-codeowner…
jeeves-form3 3de6896
Fix sec vuln with list of claims
Waterdrips 668ea84
change go versions in travis yaml
ah-f3 aa51f48
Fix go vet on 1.12
ah-f3 4ea2e3f
Update logix based on pr comment to check on error
ah-f3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# automatically generated by terraform - please do not edit here | ||
* @form3tech-oss/Contributors-codeowners |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
bin | ||
.idea/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,8 @@ script: | |
- go test -v ./... | ||
|
||
go: | ||
- 1.3 | ||
- 1.4 | ||
- 1.5 | ||
- 1.6 | ||
- 1.7 | ||
- 1.12 | ||
- 1.13 | ||
- 1.14 | ||
- 1.15 | ||
- tip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,15 @@ type MapClaims map[string]interface{} | |
// Compares the aud claim against cmp. | ||
// If required is false, this method will return true if the value matches or is unset | ||
func (m MapClaims) VerifyAudience(cmp string, req bool) bool { | ||
aud, _ := m["aud"].(string) | ||
aud, ok := m["aud"].([]string) | ||
if !ok { | ||
strAud, ok := m["aud"].(string) | ||
aud = append(aud, strAud) | ||
if !ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
return false | ||
} | ||
} | ||
|
||
return verifyAud(aud, cmp, req) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package jwt | ||
|
||
import "testing" | ||
|
||
func Test_mapClaims_list_aud(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
"aud": []string{"foo"}, | ||
} | ||
want := true | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
func Test_mapClaims_string_aud(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
"aud": "foo", | ||
} | ||
want := true | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
|
||
func Test_mapClaims_list_aud_no_match(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
"aud": []string{"bar"}, | ||
} | ||
want := false | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
func Test_mapClaims_string_aud_fail(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
"aud": "bar", | ||
} | ||
want := false | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
|
||
func Test_mapClaims_string_aud_no_claim(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
} | ||
want := false | ||
got := mapClaims.VerifyAudience("foo", true) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} | ||
|
||
func Test_mapClaims_string_aud_no_claim_not_required(t *testing.T){ | ||
mapClaims := MapClaims{ | ||
} | ||
want := false | ||
got := mapClaims.VerifyAudience("foo", false) | ||
|
||
if want != got { | ||
t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are this changes needed in example_test.go?
Functions should be named as Example - to have examples in godoc.
Also some external jwt-go is imported