Skip to content

Commit

Permalink
fix: pass standard params to storage
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Feb 3, 2024
1 parent 45a6785 commit f0f4964
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ func (a *Request) Merge(request Requester) {
}
}

var defaultAllowedParameters = []string{"grant_type", "response_type", "scope", "client_id"}

func (a *Request) Sanitize(allowedParameters []string) Requester {
b := new(Request)
allowed := map[string]bool{}
for _, v := range allowedParameters {
for _, v := range append(allowedParameters, defaultAllowedParameters...) {
allowed[v] = true
}

Expand Down
14 changes: 11 additions & 3 deletions request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ func TestSanitizeRequest(t *testing.T) {
RequestedScope: Arguments{"asdff"},
GrantedScope: []string{"asdf"},
Form: url.Values{
"foo": []string{"fasdf"},
"bar": []string{"fasdf", "faaaa"},
"baz": []string{"fasdf"},
"foo": []string{"fasdf"},
"bar": []string{"fasdf", "faaaa"},
"baz": []string{"fasdf"},
"grant_type": []string{"code"},
"response_type": []string{"id_token"},
"client_id": []string{"1234"},
"scope": []string{"read"},
},
Session: new(DefaultSession),
}
Expand All @@ -92,6 +96,10 @@ func TestSanitizeRequest(t *testing.T) {
assert.Equal(t, "fasdf", a.GetRequestForm().Get("bar"))
assert.Equal(t, []string{"fasdf", "faaaa"}, a.GetRequestForm()["bar"])
assert.Equal(t, "fasdf", a.GetRequestForm().Get("baz"))
assert.Equal(t, "code", a.GetRequestForm().Get("grant_type"))
assert.Equal(t, "id_token", a.GetRequestForm().Get("response_type"))
assert.Equal(t, "1234", a.GetRequestForm().Get("client_id"))
assert.Equal(t, "read", a.GetRequestForm().Get("scope"))
}

func TestIdentifyRequest(t *testing.T) {
Expand Down

0 comments on commit f0f4964

Please sign in to comment.