Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
13554ee7
Commit
13554ee7
authored
Oct 12, 2016
by
Eric Chiang
Committed by
GitHub
Oct 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #601 from ericchiang/dev-allow-extra-space-in-scopes
server: allow extra spaces in scopes
parents
cf8801dc
2834da44
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
handlers.go
server/handlers.go
+1
-1
oauth2.go
server/oauth2.go
+1
-1
server_test.go
server/server_test.go
+28
-0
No files found.
server/handlers.go
View file @
13554ee7
...
...
@@ -537,7 +537,7 @@ func (s *Server) handleRefreshToken(w http.ResponseWriter, r *http.Request, clie
scopes
:=
refresh
.
Scopes
if
scope
!=
""
{
requestedScopes
:=
strings
.
Split
(
scope
,
" "
)
requestedScopes
:=
strings
.
Fields
(
scope
)
var
unauthorizedScopes
[]
string
for
_
,
s
:=
range
requestedScopes
{
...
...
server/oauth2.go
View file @
13554ee7
...
...
@@ -213,7 +213,7 @@ func parseAuthorizationRequest(s storage.Storage, supportedResponseTypes map[str
return
&
authErr
{
state
,
redirectURI
,
typ
,
fmt
.
Sprintf
(
format
,
a
...
)}
}
scopes
:=
strings
.
Split
(
r
.
Form
.
Get
(
"scope"
),
" "
)
scopes
:=
strings
.
Fields
(
r
.
Form
.
Get
(
"scope"
)
)
var
(
unrecognized
[]
string
...
...
server/server_test.go
View file @
13554ee7
...
...
@@ -195,6 +195,34 @@ func TestOAuth2CodeFlow(t *testing.T) {
return
nil
},
},
{
name
:
"refresh with extra spaces"
,
handleToken
:
func
(
ctx
context
.
Context
,
p
*
oidc
.
Provider
,
config
*
oauth2
.
Config
,
token
*
oauth2
.
Token
)
error
{
v
:=
url
.
Values
{}
v
.
Add
(
"client_id"
,
clientID
)
v
.
Add
(
"client_secret"
,
clientSecret
)
v
.
Add
(
"grant_type"
,
"refresh_token"
)
v
.
Add
(
"refresh_token"
,
token
.
RefreshToken
)
// go-oidc adds an additional space before scopes when refreshing.
// Since we support that client we choose to be more relaxed about
// scope parsing, disregarding extra whitespace.
v
.
Add
(
"scope"
,
" "
+
strings
.
Join
(
requestedScopes
,
" "
))
resp
,
err
:=
http
.
PostForm
(
p
.
TokenURL
,
v
)
if
err
!=
nil
{
return
err
}
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
!=
http
.
StatusOK
{
dump
,
err
:=
httputil
.
DumpResponse
(
resp
,
true
)
if
err
!=
nil
{
panic
(
err
)
}
return
fmt
.
Errorf
(
"unexpected response: %s"
,
dump
)
}
return
nil
},
},
{
name
:
"refresh with unauthorized scopes"
,
handleToken
:
func
(
ctx
context
.
Context
,
p
*
oidc
.
Provider
,
config
*
oauth2
.
Config
,
token
*
oauth2
.
Token
)
error
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment