fix: Change op.tokenHandler to follow the same pattern as the rest of the endpoint handlers (#210)
inside op: provide a standard endpoint handler that uses injected data.
This commit is contained in:
parent
29904e9446
commit
2d248b1a1a
1 changed files with 33 additions and 28 deletions
|
@ -25,6 +25,12 @@ type Exchanger interface {
|
|||
|
||||
func tokenHandler(exchanger Exchanger) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
Exchange(w, r, exchanger)
|
||||
}
|
||||
}
|
||||
|
||||
//Exchange performs a token exchange appropriate for the grant type
|
||||
func Exchange(w http.ResponseWriter, r *http.Request, exchanger Exchanger) {
|
||||
grantType := r.FormValue("grant_type")
|
||||
switch grantType {
|
||||
case string(oidc.GrantTypeCode):
|
||||
|
@ -56,7 +62,6 @@ func tokenHandler(exchanger Exchanger) func(w http.ResponseWriter, r *http.Reque
|
|||
}
|
||||
RequestError(w, r, oidc.ErrUnsupportedGrantType().WithDescription("%s not supported", grantType))
|
||||
}
|
||||
}
|
||||
|
||||
//AuthenticatedTokenRequest is a helper interface for ParseAuthenticatedTokenRequest
|
||||
//it is implemented by oidc.AuthRequest and oidc.RefreshTokenRequest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue