mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-19 06:31:47 +00:00
auth_handler.go: only inject oauth store into handler
Previously we were injecting the whole oauth handler chain into this function, which meant we were essentially writing unit tests to test our tests. Let's push some of this logic into the source code. Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/ory/fosite"
|
||||
"github.com/ory/fosite/compose"
|
||||
"golang.org/x/oauth2"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
@@ -26,11 +26,23 @@ type IDPListGetter interface {
|
||||
func NewHandler(
|
||||
issuer string,
|
||||
idpListGetter IDPListGetter,
|
||||
oauthHelper fosite.OAuth2Provider,
|
||||
oauthStore interface{},
|
||||
generateState func() (state.State, error),
|
||||
generatePKCE func() (pkce.Code, error),
|
||||
generateNonce func() (nonce.Nonce, error),
|
||||
) http.Handler {
|
||||
oauthHelper := compose.Compose(
|
||||
&compose.Config{},
|
||||
oauthStore,
|
||||
&compose.CommonStrategy{
|
||||
// Shouldn't need any of this - we aren't doing auth code stuff, issuing ID tokens, or signing
|
||||
// anything yet.
|
||||
},
|
||||
nil, // hasher, shouldn't need this - we aren't doing any client auth...yet?
|
||||
compose.OAuth2AuthorizeExplicitFactory,
|
||||
compose.OpenIDConnectExplicitFactory,
|
||||
compose.OAuth2PKCEFactory,
|
||||
)
|
||||
return httperr.HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {
|
||||
if r.Method != http.MethodPost && r.Method != http.MethodGet {
|
||||
// https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
|
||||
|
||||
Reference in New Issue
Block a user