Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
50dc2f55
Unverified
Commit
50dc2f55
authored
3 years ago
by
Márk Sági-Kazár
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2433 from flant/implicit_flow_discovery
fix: Implicit Grant discovery
parents
cf78e741
57e9611f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/oauth2.go
+1
-0
1 addition, 0 deletions
server/oauth2.go
server/server.go
+9
-2
9 additions, 2 deletions
server/server.go
server/server_test.go
+39
-0
39 additions, 0 deletions
server/server_test.go
with
49 additions
and
2 deletions
server/oauth2.go
+
1
−
0
View file @
50dc2f55
...
...
@@ -128,6 +128,7 @@ const (
const
(
grantTypeAuthorizationCode
=
"authorization_code"
grantTypeRefreshToken
=
"refresh_token"
grantTypeImplicit
=
"implicit"
grantTypePassword
=
"password"
grantTypeDeviceCode
=
"urn:ietf:params:oauth:grant-type:device_code"
)
...
...
This diff is collapsed.
Click to expand it.
server/server.go
+
9
−
2
View file @
50dc2f55
...
...
@@ -213,20 +213,27 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
c
.
SupportedResponseTypes
=
[]
string
{
responseTypeCode
}
}
supportedGrant
:=
[]
string
{
grantTypeAuthorizationCode
,
grantTypeRefreshToken
,
grantTypeDeviceCode
}
// default
supportedRes
:=
make
(
map
[
string
]
bool
)
for
_
,
respType
:=
range
c
.
SupportedResponseTypes
{
switch
respType
{
case
responseTypeCode
,
responseTypeIDToken
,
responseTypeToken
:
case
responseTypeCode
,
responseTypeIDToken
:
// continue
case
responseTypeToken
:
// response_type=token is an implicit flow, let's add it to the discovery info
// https://datatracker.ietf.org/doc/html/rfc6749#section-4.2.1
supportedGrant
=
append
(
supportedGrant
,
grantTypeImplicit
)
default
:
return
nil
,
fmt
.
Errorf
(
"unsupported response_type %q"
,
respType
)
}
supportedRes
[
respType
]
=
true
}
supportedGrant
:=
[]
string
{
grantTypeAuthorizationCode
,
grantTypeRefreshToken
,
grantTypeDeviceCode
}
// default
if
c
.
PasswordConnector
!=
""
{
supportedGrant
=
append
(
supportedGrant
,
grantTypePassword
)
}
sort
.
Strings
(
supportedGrant
)
webFS
:=
web
.
FS
()
...
...
This diff is collapsed.
Click to expand it.
server/server_test.go
+
39
−
0
View file @
50dc2f55
...
...
@@ -1735,3 +1735,42 @@ func TestOAuth2DeviceFlow(t *testing.T) {
}
}
}
func
TestServerSupportedGrants
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
config
func
(
c
*
Config
)
resGrants
[]
string
}{
{
name
:
"Simple"
,
config
:
func
(
c
*
Config
)
{},
resGrants
:
[]
string
{
grantTypeAuthorizationCode
,
grantTypeRefreshToken
,
grantTypeDeviceCode
},
},
{
name
:
"With password connector"
,
config
:
func
(
c
*
Config
)
{
c
.
PasswordConnector
=
"local"
},
resGrants
:
[]
string
{
grantTypeAuthorizationCode
,
grantTypePassword
,
grantTypeRefreshToken
,
grantTypeDeviceCode
},
},
{
name
:
"With token response"
,
config
:
func
(
c
*
Config
)
{
c
.
SupportedResponseTypes
=
append
(
c
.
SupportedResponseTypes
,
responseTypeToken
)
},
resGrants
:
[]
string
{
grantTypeAuthorizationCode
,
grantTypeImplicit
,
grantTypeRefreshToken
,
grantTypeDeviceCode
},
},
{
name
:
"All"
,
config
:
func
(
c
*
Config
)
{
c
.
PasswordConnector
=
"local"
c
.
SupportedResponseTypes
=
append
(
c
.
SupportedResponseTypes
,
responseTypeToken
)
},
resGrants
:
[]
string
{
grantTypeAuthorizationCode
,
grantTypeImplicit
,
grantTypePassword
,
grantTypeRefreshToken
,
grantTypeDeviceCode
},
},
}
for
_
,
tc
:=
range
tests
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
_
,
srv
:=
newTestServer
(
context
.
TODO
(),
t
,
tc
.
config
)
require
.
Equal
(
t
,
srv
.
supportedGrantTypes
,
tc
.
resGrants
)
})
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment